Pre-process out assert()
authorRyan Dahl <ry@tinyclouds.org>
Fri, 28 Jan 2011 00:35:35 +0000 (16:35 -0800)
committerRyan Dahl <ry@tinyclouds.org>
Fri, 28 Jan 2011 00:38:49 +0000 (16:38 -0800)
src/node.js
wscript

index a2a5f3f..0012b40 100644 (file)
     return startup._lazyConstants;
   };
 
+  var assert;
   startup.processAssert = function() {
-    process.assert = function(x, msg) {
-      if (!x) {
-        throw new Error(msg || 'assertion error');
-      }
+    // Note that calls to assert() are pre-processed out by JS2C for the
+    // normal build of node. They persist only in the node_g build.
+    // Similarly for debug().
+    assert = process.assert = function(x, msg) {
+      if (!x) throw new Error(msg || 'assertion error');
     };
   };
 
     process.removeListener = function(type, listener) {
       var ret = removeListener.apply(this, arguments);
       if (isSignal(type)) {
-        process.assert(signalWatchers.hasOwnProperty(type));
+        assert(signalWatchers.hasOwnProperty(type));
 
         if (this.listeners(type).length === 0) {
           signalWatchers[type].stop();
diff --git a/wscript b/wscript
index bc07ba3..2fb8f9a 100644 (file)
--- a/wscript
+++ b/wscript
@@ -601,6 +601,7 @@ def build(bld):
   make_macros(macros_loc_debug, "")  # leave debug(x) as is in debug build
   # replace debug(x) with nothing in release build
   make_macros(macros_loc_default, "macro debug(x) = ;\n")
+  make_macros(macros_loc_default, "macro assert(x) = ;\n")
 
   if not bld.env["USE_DTRACE"]:
     make_macros(macros_loc_default, "macro DTRACE_HTTP_SERVER_RESPONSE(x) = ;\n");