mca-compiler
Version:
Compiles MCA code to MCIL
14 lines (13 loc) • 598 B
JavaScript
exports.type = "ComparisonExpression";
exports.call = function(node, ctx, execute) {
var left = execute(node.left);
var right = execute(node.right);
switch (node.operator) {
case '==': return ctx.strictEqual(left, right);
case '!=': return ctx.notStrictEqual(left, right);
case '>=': return ctx.castNumber(left) >= ctx.castNumber(right);
case '<=': return ctx.castNumber(left) <= ctx.castNumber(right);
case '>': return ctx.castNumber(left) > ctx.castNumber(right);
case '<': return ctx.castNumber(left) < ctx.castNumber(right);
}
};