krl-compiler
Advanced tools
Comparing version 0.13.0 to 0.14.0
{ | ||
"name": "krl-compiler", | ||
"version": "0.13.0", | ||
"version": "0.14.0", | ||
"description": "KRL compiler", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -125,2 +125,9 @@ var _ = require("lodash"); | ||
}, | ||
"ConditionalExpression": function(ast, comp, e){ | ||
return e("ternary", | ||
comp(ast.test), | ||
comp(ast.consequent), | ||
comp(ast.alternate) | ||
); | ||
}, | ||
"Function": function(ast, comp, e){ | ||
@@ -195,2 +202,12 @@ var body = _.map(ast.params, function(param, i){ | ||
if(!_.isEmpty(ast.global)){ | ||
_.each(ast.global, function(g){ | ||
if(!g || g.type !== "Declaration"){ | ||
throw new Error("Ruleset.global should only be declarations"); | ||
} | ||
if(g.left && g.left.type === "DomainIdentifier"){ | ||
if(g.left.domain === "ent"){ | ||
throw new Error("Cannot set ent:* vars in the global scope"); | ||
} | ||
} | ||
}); | ||
rs.global = e("fn", ["ctx"], comp(ast.global)); | ||
@@ -197,0 +214,0 @@ } |
19565
547