Skip to content

Commit

Permalink
✨ fix Node.createNode
Browse files Browse the repository at this point in the history
  • Loading branch information
mohayonao committed Jul 9, 2014
1 parent a39b721 commit d348f10
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/sc/lang/compiler/node/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@

var Syntax = sc.lang.compiler.Syntax;

var Node = {
sc.lang.compiler.Node = {
createAssignmentExpression: function(operator, left, right, remain) {
var node = {
type: Syntax.AssignmentExpression,
operator: operator,
left: left,
right: right
};

if (remain) {
node.remain = remain;
}

return node;
},
createBinaryExpression: function(operator, left, right) {
Expand All @@ -25,9 +27,11 @@
left: left,
right: right
};

if (operator.adverb) {
node.adverb = operator.adverb;
}

return node;
},
createBlockExpression: function(body) {
Expand All @@ -37,13 +41,18 @@
};
},
createCallExpression: function(callee, method, args, stamp) {
return {
var node = {
type: Syntax.CallExpression,
stamp: stamp,
callee: callee,
method: method,
args: args,
method: method
};

if (args) {
node.args = args;
}

return node;
},
createEnvironmentExpression: function(id) {
return {
Expand All @@ -52,12 +61,11 @@
};
},
createFunctionExpression: function(args, body, opts) {
var node;

node = {
var node = {
type: Syntax.FunctionExpression,
body: body
};

if (args) {
node.args = args;
}
Expand All @@ -70,6 +78,7 @@
if (opts.blockList) {
node.blockList = true;
}

return node;
},
createIdentifier: function(name) {
Expand All @@ -83,9 +92,11 @@
type: Syntax.ListExpression,
elements: elements
};

if (immutable) {
node.immutable = !!immutable;
}

return node;
},
createLiteral: function(token) {
Expand Down Expand Up @@ -152,6 +163,4 @@
};
}
};

sc.lang.compiler.Node = Node;
})(sc);

0 comments on commit d348f10

Please sign in to comment.