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

Unified Diff: sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart

Issue 12276002: Add a small JS parser to ease the building of ASTs (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove def() method, analyzer doesn't like it. Created 7 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
Index: sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart
diff --git a/sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart b/sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart
index 9c96a802db7d2750ecf599ba3a9645cdbb4f5e69..6500fc3c50fa71bcaad225523c79e5b8823729b0 100644
--- a/sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart
@@ -249,11 +249,10 @@ function(cls, desc) {
jsAst.Statement body,
List<jsAst.Parameter> parameters) {
return js.if_(
- js['Object']['getPrototypeOf']('this')['hasOwnProperty'](
- js.string(methodName)),
+ js['(Object.getPrototypeOf(this)).hasOwnProperty("$methodName")'],
body,
js.return_(
- js['Object']['prototype'][methodName]['call'](
+ js['Object.prototype.$methodName.call'](
<jsAst.Expression>[js['this']]..addAll(
parameters.map((param) => js[param.name])))));
}
@@ -479,13 +478,13 @@ function(cls, desc) {
if (element.isObject(compiler)) continue;
String name = backend.namer.operatorIs(element);
addProperty(name,
- js.fun([], js.return_(new jsAst.LiteralBool(false))));
+ js.fun([], js.return_(js['false'])));
}
}
emitIsChecks();
jsAst.Expression makeCallOnThis(String functionName) {
- return js.fun([], js.return_(js[functionName]('this')));
+ return js.fun([], js.return_(js['$functionName(this)']));
}
// In order to have the toString method on every native class,
@@ -503,7 +502,7 @@ function(cls, desc) {
String equalsName = backend.namer.publicInstanceMethodNameByArity(
const SourceString('=='), 1);
addProperty(equalsName, js.fun(['a'],
- js.return_(js.strictEquals(new jsAst.This(), js['a']))));
+ js.return_(js['this === a'])));
// If the native emitter has been asked to take care of the
// noSuchMethod handlers, we do that now.
@@ -523,11 +522,7 @@ function(cls, desc) {
null)]),
js['table'],
new jsAst.ExpressionStatement(
- js[defPropName](
- [js['Object']['prototype'],
- js['key'],
- new jsAst.PropertyAccess(js['table'],
- js['key'])]))))(
+ js['$defPropName(Object.prototype, key, table[key])'])))(
new jsAst.ObjectInitializer(objectProperties));
if (emitter.compiler.enableMinification) targetBuffer.add(';');
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart ('k') | tests/compiler/dart2js/js_parser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698