Add support for evaluating individual expressions

This commit is contained in:
Jen Thakar 2018-04-14 11:39:24 -07:00
parent 9939b70ffb
commit 04fc1e46c8
2 changed files with 16 additions and 1 deletions

View File

@ -61,6 +61,14 @@ Future<EvaluateResult> evaluateAsync(Stylesheet stylesheet,
logger: logger)
.run(stylesheet);
/// Evaluates a single [expression] in [environment]
Future<Value> evaluateExpressionAsync(
Expression expression, AsyncEnvironment environment) {
var evaluator = new _EvaluateVisitor();
return evaluator._withEnvironment(
environment, () => expression.accept(evaluator));
}
/// A visitor that executes Sass code to produce a CSS tree.
class _EvaluateVisitor
implements

View File

@ -5,7 +5,7 @@
// DO NOT EDIT. This file was generated from async_evaluate.dart.
// See tool/synchronize.dart for details.
//
// Checksum: 9b5790272f09f8932a01ef9bfa0fd4ebc6b75eaa
// Checksum: 4eb54f9170b6c2a337afb7c86502a1a78a0e280f
import 'dart:math' as math;
@ -65,6 +65,13 @@ EvaluateResult evaluate(Stylesheet stylesheet,
logger: logger)
.run(stylesheet);
/// Evaluates a single [expression] in [environment]
Value evaluateExpression(Expression expression, Environment environment) {
var evaluator = new _EvaluateVisitor();
return evaluator._withEnvironment(
environment, () => expression.accept(evaluator));
}
/// A visitor that executes Sass code to produce a CSS tree.
class _EvaluateVisitor
implements StatementVisitor<Value>, ExpressionVisitor<Value> {