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

Unified Diff: frog/leg/native_handler.dart

Issue 9537007: Implement native getters and setters and move supported tests to 'native'. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | frog/tests/frog/frog.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/leg/native_handler.dart
===================================================================
--- frog/leg/native_handler.dart (revision 4737)
+++ frog/leg/native_handler.dart (working copy)
@@ -128,13 +128,28 @@
});
String foreignParameters = Strings.join(arguments, ',');
- String methodName = builder.compiler.namer.instanceMethodName(
- element.name, parameters.parameterCount);
+ String dartMethodName;
kasperl 2012/02/29 10:16:38 I guess this almost calls for an abstraction with
ngeoffray 2012/02/29 10:19:19 We have the element, but I'm not sure I want to po
+ String nativeMethodName = element.name.slowToString();
+ String nativeMethodCall;
+ if (element.kind == ElementKind.FUNCTION) {
+ dartMethodName = builder.compiler.namer.instanceMethodName(
+ element.name, parameters.parameterCount);
+ nativeMethodCall = '$receiver$nativeMethodName($foreignParameters)';
+ } else if (element.kind == ElementKind.GETTER) {
+ dartMethodName = builder.compiler.namer.getterName(element.name);
+ nativeMethodCall = '$receiver$nativeMethodName';
+ } else if (element.kind == ElementKind.SETTER) {
+ dartMethodName = builder.compiler.namer.setterName(element.name);
+ nativeMethodCall = '$receiver$nativeMethodName = $foreignParameters';
+ } else {
+ builder.compiler.internalError('unexpected kind: "${element.kind}"',
+ element: element);
+ }
+
HInstruction thenInstruction;
void visitThen() {
- SourceString jsCode = new SourceString(
- '$receiver${element.name.slowToString()}($foreignParameters)');
+ SourceString jsCode = new SourceString(nativeMethodCall);
thenInstruction =
new HForeign(jsCode, const SourceString('Object'), inputs);
builder.add(thenInstruction);
@@ -148,7 +163,7 @@
} else {
// If the method is an instance method, we generate the following code:
// function(params) {
- // return Object.getPrototypeOf(this).hasOwnProperty(methodName))
+ // return Object.getPrototypeOf(this).hasOwnProperty(dartMethodName))
// ? this.methodName(params)
// : Object.prototype.methodName.call(this, params);
// }
@@ -161,7 +176,8 @@
// method does not have subclasses.
HInstruction elseInstruction;
void visitElse() {
- SourceString jsCode = new SourceString('Object.prototype.$methodName');
+ SourceString jsCode =
+ new SourceString('Object.prototype.$dartMethodName');
HInstruction instruction =
new HForeign(jsCode, const SourceString('Object'), []);
builder.add(instruction);
@@ -175,7 +191,7 @@
}
HLiteral literal = builder.graph.addNewLiteralString(
- new DartString.literal('$methodName'));
+ new DartString.literal('$dartMethodName'));
SourceString jsCode = new SourceString(
'Object.getPrototypeOf(\$0).hasOwnProperty(\$1)');
builder.push(new HForeign(
« no previous file with comments | « no previous file | frog/tests/frog/frog.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698