Commits

Steve Losh committed 19bd05e

Semicolons, ===, and other JS horsefuckery.

  • Participants
  • Parent commits 3a11283

Comments (0)

Files changed (1)

 //    B. Pass the AST to escodegen to get a hunk of text back representing the
 //       Javascript code.
 //    C. Write that code to standard out (or a file or whatever).
-//    D. Evaluate the code (this is important for real macros, if you don't
+//    D. Evaluate the code (this is important for real macros -- if you don't
 //       understand why, turn back now).
 //
 //  So for example, if we have an Alienscript file with:
     },
     "defmacro": function(elements) {
         var name = elements[0];
-        var fnexpr = slice(elements, 1)
+        var fnexpr = slice(elements, 1);
 
         name = grow(name).name;
 
 
         return { type: "CallExpression", callee: {
                     type: "MemberExpression", computed: true,
-                    object: obj, property: method,
+                    object: obj, property: method
                  }, arguments: args };
     },
     "symbol": function(elements) {
                  prefix: true, argument: elements[0] };
     },
     "+": function(elements) {
-        if (elements.length == 0) {
+        if (elements.length === 0) {
             return { type: "Literal", value: 0 };
-        } else if (elements.length == 1) {
+        } else if (elements.length === 1) {
             return elements[0];
         } else {
             return { type: "BinaryExpression", operator: "+",
         }
     },
     "*": function(elements) {
-        if (elements.length == 0) {
+        if (elements.length === 0) {
             return { type: "Literal", value: 1 };
-        } else if (elements.length == 1) {
+        } else if (elements.length === 1) {
             return elements[0];
         } else {
             return { type: "BinaryExpression", operator: "*",
         }
     },
     "/": function(elements) {
-        if (elements.length == 0) {
+        if (elements.length === 0) {
             return { type: "Literal", value: 1 };
-        } else if (elements.length == 1) {
+        } else if (elements.length === 1) {
             return elements[0];
         } else {
             return { type: "BinaryExpression", operator: "/",
         }
     },
     "-": function(elements) {
-        if (elements.length == 0) {
+        if (elements.length === 0) {
             return { type: "Literal", value: 0 };
-        } else if (elements.length == 1) {
+        } else if (elements.length === 1) {
             return { type: "UnaryExpression", operator: "-",
                      prefix: true,
                      argument: elements[0] };
-        } else if (elements.length == 2) {
+        } else if (elements.length === 2) {
             return { type: "BinaryExpression", operator: "-",
                      left: elements[0], right: elements[1] };
         } else {
         }
     },
     ">": function(elements) {
-        if (elements.length == 2) {
+        if (elements.length === 2) {
             return { type: "BinaryExpression", operator: ">",
                      left: elements[0], right: elements[1] };
         } else {
         }
     },
     "<": function(elements) {
-        if (elements.length == 2) {
+        if (elements.length === 2) {
             return { type: "BinaryExpression", operator: "<",
                      left: elements[0], right: elements[1] };
         } else {
         }
     },
     ">=": function(elements) {
-        if (elements.length == 2) {
+        if (elements.length === 2) {
             return { type: "BinaryExpression", operator: ">=",
                      left: elements[0], right: elements[1] };
         } else {
         }
     },
     "<=": function(elements) {
-        if (elements.length == 2) {
+        if (elements.length === 2) {
             return { type: "BinaryExpression", operator: "<=",
                      left: elements[0], right: elements[1] };
         } else {
         }
     },
     "=": function(elements) {
-        if (elements.length == 2) {
+        if (elements.length === 2) {
             return { type: "BinaryExpression", operator: "===",
                      left: elements[0], right: elements[1] };
         } else {
         var idx = elements[1];
 
         return { type: "MemberExpression", computed: true,
-                 object: obj, property: idx }
+                 object: obj, property: idx };
     },
     "def": function(elements) {
         var name = elements[0];
         }
 
         return { type: "ConditionalExpression", test: cond,
-                 consequent: then, alternate: otherwise }
+                 consequent: then, alternate: otherwise };
     }
 };
 
     ctx['macros'] = macros;
     ctx['Symbol'] = Symbol;
     return ctx;
-}
+};
 var compile = function(filename, ctx, verbose) {
     if (verbose) {
         console.log('// Parsing file ' + filename + ' -----------------------');