Skip to content

Commit

Permalink
Direct CompoundExpression evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
jfirebaugh committed Oct 9, 2017
1 parent d7e7681 commit 29a84cb
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 83 deletions.
10 changes: 3 additions & 7 deletions src/style-spec/expression/compound_expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import type { Value } from './values';

type Varargs = {| type: Type |};
type Signature = Array<Type> | Varargs;
type Evaluate = (EvaluationContext, Array<Expression>) => Value;
type Evaluate = (EvaluationContext) => Value;
type Definition = [Type, Signature, Evaluate] |
{|type: Type, overloads: Array<[Signature, Evaluate]>|};

class CompoundExpression implements Expression {
key: string;
name: string;
type: Type;
_evaluate: Evaluate;
evaluate: (ctx: EvaluationContext) => any;
args: Array<Expression>;

static definitions: { [string]: Definition };
Expand All @@ -28,14 +28,10 @@ class CompoundExpression implements Expression {
this.key = key;
this.name = name;
this.type = type;
this._evaluate = evaluate;
this.evaluate = evaluate;
this.args = args;
}

evaluate(ctx: EvaluationContext) {
return this._evaluate(ctx, this.args);
}

serialize() {
const name = this.name;
const args = this.args.map(e => e.serialize());
Expand Down
Loading

0 comments on commit 29a84cb

Please sign in to comment.