Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Unified Diff: lib/src/codegen/ast_builder.dart

Issue 961513002: Flesh out dynamic invocation code (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Streamline ++ and -- in fallback case Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/src/codegen/js_codegen.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/codegen/ast_builder.dart
diff --git a/lib/src/codegen/ast_builder.dart b/lib/src/codegen/ast_builder.dart
index 8193a3e9b8c2b2b2a678b5109ef076f9cbbaa144..df0c572dfcabe84253c63b41dc897211f7192ede 100644
--- a/lib/src/codegen/ast_builder.dart
+++ b/lib/src/codegen/ast_builder.dart
@@ -63,6 +63,10 @@ class AstBuilder {
return RawAstBuilder.nullLiteral();
}
+ static IntegerLiteral integerLiteral(int i) {
+ return RawAstBuilder.integerLiteral(i);
+ }
+
static StringLiteral stringLiteral(String s) {
return RawAstBuilder.simpleStringLiteral(s);
}
@@ -91,13 +95,26 @@ class AstBuilder {
return parenthesizedExpression(exp);
}
- static BinaryExpression binaryExpression(
- Expression l, String oper, Expression r) {
- if (oper == "==") return RawAstBuilder.equalityExpression(l, r);
+ static Token _binaryOperation(String oper) {
+ switch (oper) {
+ case '==':
+ return new Token(TokenType.EQ_EQ, 0);
+ case '+':
+ return new Token(TokenType.PLUS, 0);
+ case '-':
+ return new Token(TokenType.MINUS, 0);
+ }
+ // TODO(vsm): Add cases as needed.
assert(false);
return null;
}
+ static BinaryExpression binaryExpression(
+ Expression l, String oper, Expression r) {
+ Token token = _binaryOperation(oper);
+ return RawAstBuilder.binaryExpression(l, token, r);
+ }
+
static ConditionalExpression conditionalExpression(
Expression cond, Expression tExp, Expression fExp) {
return RawAstBuilder.conditionalExpression(cond, tExp, fExp);
@@ -252,6 +269,11 @@ class RawAstBuilder {
return new NullLiteral(n);
}
+ static IntegerLiteral integerLiteral(int i) {
+ StringToken token = new StringToken(TokenType.INT, '$i', 0);
+ return new IntegerLiteral(token, i);
+ }
+
static SimpleStringLiteral simpleStringLiteral(String s) {
StringToken token = new StringToken(TokenType.STRING, "\"" + s + "\"", 0);
return new SimpleStringLiteral(token, s);
@@ -278,9 +300,9 @@ class RawAstBuilder {
return new ParenthesizedExpression(lp, exp, rp);
}
- static BinaryExpression equalityExpression(Expression l, Expression r) {
- var eq = new Token(TokenType.EQ_EQ, 0);
- return new BinaryExpression(l, eq, r);
+ static BinaryExpression binaryExpression(
+ Expression l, Token op, Expression r) {
+ return new BinaryExpression(l, op, r);
}
static ConditionalExpression conditionalExpression(
« no previous file with comments | « no previous file | lib/src/codegen/js_codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698