aboutsummaryrefslogtreecommitdiff
path: root/lib/mozilla-ast.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mozilla-ast.js')
-rw-r--r--lib/mozilla-ast.js35
1 files changed, 16 insertions, 19 deletions
diff --git a/lib/mozilla-ast.js b/lib/mozilla-ast.js
index 8e66c916..dace808a 100644
--- a/lib/mozilla-ast.js
+++ b/lib/mozilla-ast.js
@@ -43,11 +43,9 @@
"use strict";
-(function(){
-
- var normalize_directives = function(body) {
+(function() {
+ function normalize_directives(body) {
var in_directive = true;
-
for (var i = 0; i < body.length; i++) {
if (in_directive && body[i] instanceof AST_Statement && body[i].body instanceof AST_String) {
body[i] = new AST_Directive({
@@ -59,9 +57,8 @@
in_directive = false;
}
}
-
return body;
- };
+ }
var MOZ_TO_ME = {
Program: function(M) {
@@ -129,7 +126,7 @@
return new AST_Array({
start : my_start_token(M),
end : my_end_token(M),
- elements : M.elements.map(function(elem){
+ elements : M.elements.map(function(elem) {
return elem === null ? new AST_Hole() : from_moz(elem);
})
});
@@ -138,7 +135,7 @@
return new AST_Object({
start : my_start_token(M),
end : my_end_token(M),
- properties : M.properties.map(function(prop){
+ properties : M.properties.map(function(prop) {
prop.type = "Property";
return from_moz(prop)
})
@@ -480,7 +477,7 @@
endpos : range ? range[0] : moznode.start,
raw : raw_token(moznode),
});
- };
+ }
function my_end_token(moznode) {
var loc = moznode.loc, end = loc && loc.end;
@@ -495,7 +492,7 @@
endpos : range ? range[1] : moznode.end,
raw : raw_token(moznode),
});
- };
+ }
function map(moztype, mytype, propmap) {
var moz_to_me = "function From_Moz_" + moztype + "(M){\n";
@@ -507,7 +504,7 @@
me_to_moz += "return {\n" +
"type: " + JSON.stringify(moztype);
- if (propmap) propmap.split(/\s*,\s*/).forEach(function(prop){
+ if (propmap) propmap.split(/\s*,\s*/).forEach(function(prop) {
var m = /([a-z0-9$_]+)(=|@|>|%)([a-z0-9$_]+)/i.exec(prop);
if (!m) throw new Error("Can't understand property map: " + prop);
var moz = m[1], how = m[2], my = m[3];
@@ -550,7 +547,7 @@
);
MOZ_TO_ME[moztype] = moz_to_me;
def_to_moz(mytype, me_to_moz);
- };
+ }
var FROM_MOZ_STACK = null;
@@ -559,9 +556,9 @@
var ret = node != null ? MOZ_TO_ME[node.type](node) : null;
FROM_MOZ_STACK.pop();
return ret;
- };
+ }
- AST_Node.from_mozilla_ast = function(node){
+ AST_Node.from_mozilla_ast = function(node) {
var save_stack = FROM_MOZ_STACK;
FROM_MOZ_STACK = [];
var ast = from_moz(node);
@@ -600,24 +597,24 @@
}
}
return moznode;
- };
+ }
function def_to_moz(mytype, handler) {
mytype.DEFMETHOD("to_mozilla_ast", function() {
return set_moz_loc(this, handler(this));
});
- };
+ }
function to_moz(node) {
return node != null ? node.to_mozilla_ast() : null;
- };
+ }
function to_moz_block(node) {
return {
type: "BlockStatement",
body: node.body.map(to_moz)
};
- };
+ }
function to_moz_scope(type, node) {
var body = node.body.map(to_moz);
@@ -628,5 +625,5 @@
type: type,
body: body
};
- };
+ }
})();