UNPKG

cql-execution

Version:

An execution framework for the Clinical Quality Language (CQL)

83 lines (67 loc) 2.36 kB
// Generated by CoffeeScript 1.12.7 (function() { var Expression, UnimplementedExpression, build, typeIsArray, extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; build = require('./builder').build; typeIsArray = require('../util/util').typeIsArray; module.exports.Expression = Expression = (function() { function Expression(json) { var op; if (json.operand != null) { op = build(json.operand); if (typeIsArray(json.operand)) { this.args = op; } else { this.arg = op; } } if (json.localId != null) { this.localId = json.localId; } } Expression.prototype.execute = function(ctx) { var execValue; if (this.localId != null) { execValue = this.exec(ctx); ctx.rootContext().setLocalIdWithResult(this.localId, execValue); return execValue; } else { return this.exec(ctx); } }; Expression.prototype.exec = function(ctx) { return this; }; Expression.prototype.execArgs = function(ctx) { var arg, i, len, ref, results; switch (false) { case this.args == null: ref = this.args; results = []; for (i = 0, len = ref.length; i < len; i++) { arg = ref[i]; results.push(arg.execute(ctx)); } return results; case this.arg == null: return this.arg.execute(ctx); default: return null; } }; return Expression; })(); module.exports.UnimplementedExpression = UnimplementedExpression = (function(superClass) { extend(UnimplementedExpression, superClass); function UnimplementedExpression(json1) { this.json = json1; UnimplementedExpression.__super__.constructor.apply(this, arguments); } UnimplementedExpression.prototype.exec = function(ctx) { throw new Error("Unimplemented Expression: " + this.json.type); }; return UnimplementedExpression; })(Expression); }).call(this); //# sourceMappingURL=expression.js.map