Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix codegeneration indentation.

  • Loading branch information...
commit 55a4afcc14cb0242552575b2a330a54e0c740edb 1 parent 7df9677
@zaach zaach authored
Showing with 14 additions and 14 deletions.
  1. +9 −9 lib/js/codegen.js
  2. +5 −5 lib/objj/codegen.js
View
18 lib/js/codegen.js
@@ -32,7 +32,7 @@ var codegens = exports.nodes = {
'GetterSetterProp': function GetterSetterProp_codegen (lvl) {
return this.op+" "+this.name
+' ('+ this.children[0].toJS() + ') '
- +'{\n'+idt(lvl)+genStmts(this.children.slice(1), lvl+1) +'\n'+idt(lvl-1)+'}';
+ +'{\n'+idt(lvl)+genStmts(this.children.slice(1), lvl) +'\n'+idt(lvl-1)+'}';
},
'ObjectExpr': function ObjectExpr_codegen (lvl) {
return this.children.length ? "{\n"+idt(lvl)+this.children.map(function(node){return node.toJS(lvl+1)}).join(',\n'+idt(lvl))+'\n'+idt(lvl-1)+'}':
@@ -142,17 +142,17 @@ var codegens = exports.nodes = {
'{ }';
},
'VarDecl': function VarDecl_codegen (lvl) {
- return "var "+this.children.map(function(node){return node.toJS(lvl+1);}).join(',\n'+idt(lvl));
+ return "var "+this.children.map(function(node){return node.toJS(lvl);}).join(',\n'+idt(lvl+1));
},
'ConstDecl': function ConstDecl_codegen (lvl) {
- return "const "+this.children.map(function(node){return node.toJS(lvl+1);}).join(',\n'+idt(lvl));
+ return "const "+this.children.map(function(node){return node.toJS(lvl);}).join(',\n'+idt(lvl+1));
},
'InitPatt': function InitPatt_codegen (lvl) {
- return this.children[0].toJS(lvl+1) +' = '+
- this.children[1].toJS(lvl+1);
+ return this.children[0].toJS(lvl) +' = '+
+ this.children[1].toJS(lvl);
},
'IfStmt': function IfStmt_codegen (lvl) {
- return 'if (' + this.children[0].toJS(lvl+1) +') '+ this.children[1].blockgen(lvl)
+ return 'if (' + this.children[0].toJS(lvl+1) +') '+ this.children[1].blockgen(lvl+1)
+ (this.children[2].nodeType === 'EmptyStmt' ? '' :
' else '+this.children[2].blockgen(lvl));
},
@@ -181,7 +181,7 @@ var codegens = exports.nodes = {
return 'return' + (this.children.length ? ' '+this.children[0].toJS(lvl+1) : '');
},
'WithStmt': function WithStmt_codegen (lvl) {
- return 'with (' +this.children[0].toJS() + ') ' + this.children[1].blockgen(lvl+1);
+ return 'with (' +this.children[0].toJS() + ') ' + this.children[1].blockgen(lvl);
},
'SwitchStmt': function SwitchStmt_codegen (lvl) {
return 'switch ('+this.children[0].toJS()+') {\n'+idt(lvl)
@@ -215,12 +215,12 @@ var codegens = exports.nodes = {
'FunctionDecl': function FunctionDecl_codegen (lvl) {
return 'function ' + this.children[0].toJS() +' ('
+this.children[1].toJS(lvl+1) + ') '
- +'{\n'+idt(lvl)+genStmts(this.children.slice(2), lvl+1) +'\n'+idt(lvl-1)+'}';
+ +'{\n'+idt(lvl)+genStmts(this.children.slice(2), lvl) +'\n'+idt(lvl-1)+'}';
},
'FunctionExpr': function FunctionExpr_codegen (lvl) {
return 'function' + (this.children[0].nodeType === 'Empty' ? '' : ' '+this.children[0].toJS()) +' ('
+this.children[1].toJS() + ') '
- +'{\n'+idt(lvl)+genStmts(this.children.slice(2), lvl+1) +'\n'+idt(lvl-1)+'}';
+ +'{\n'+idt(lvl)+genStmts(this.children.slice(2), lvl) +'\n'+idt(lvl-1)+'}';
},
'ParamDecl': function ParamDecl_codegen (lvl) {
return this.children.map(function(node){return node.toJS(lvl)}).join(', ');
View
10 lib/objj/codegen.js
@@ -24,7 +24,7 @@ var codegens = exports.nodes = {
(this.children[0].nodeType == 'IdPatt' ? this.children[0].toJS() +'"' :
this.children.map(function(node){return node.name}).join(':')+':", '+
this.children.map(function(node){
- return node.toJS(lvl+1);
+ return node.toJS(lvl);
}).join(', ')
)+
')';
@@ -37,7 +37,7 @@ var codegens = exports.nodes = {
return '{var $objj_className = "'+this.name+'"'+
', the_class = objj_allocateClassPair('+
(this.children[0].nodeType == 'Empty' ?
- 'Nil' : this.children[0].toJS(lvl+1))+
+ 'Nil' : this.children[0].toJS(lvl))+
', $objj_className)'+
',\nmeta_class = the_class.isa;'+
this.children[1].toJS(lvl)+ // instance vars
@@ -58,7 +58,7 @@ var codegens = exports.nodes = {
'CPInstanceVars': function CPInstanceVars_codegen (lvl) {
return this.children.length ?
('class_addIvars(the_class, ['+
- this.children.map(function(node){return node.toJS(lvl+1)}).join(', ')+
+ this.children.map(function(node){return node.toJS(lvl)}).join(', ')+
']);') :
'';
},
@@ -76,7 +76,7 @@ var codegens = exports.nodes = {
this.children[0].name+'(self, _cmd)'
)+
'\n{ with(self)\n{\n'+idt(lvl)+
- this.children.slice(1).map(function(node){return node.blockgen(lvl+1)}).join('\n'+idt(lvl))+
+ this.children.slice(1).map(function(node){return node.blockgen(lvl)}).join('\n'+idt(lvl))+
'\n}\n},["'+this.type+'"'+
(selectors ? (', "'+
this.children[0].children.map(function(node){return node.type}).join('", "')+'"') : '') +'])'+
@@ -93,7 +93,7 @@ var codegens = exports.nodes = {
this.children[0].name+'(self, _cmd)'
)+
'\n{ with(self)\n{\n'+idt(lvl)+
- this.children.slice(1).map(function(node){return node.blockgen(lvl+1)}).join('\n'+idt(lvl))+
+ this.children.slice(1).map(function(node){return node.blockgen(lvl)}).join('\n'+idt(lvl))+
'\n}\n},["'+this.type+'"'+
(selectors ? (', "'+
this.children[0].children.map(function(node){return node.type}).join('", "')+'"') : '') +'])'+
Please sign in to comment.
Something went wrong with that request. Please try again.