Chromium Code Reviews| Index: frog/leg/emitter.dart |
| diff --git a/frog/leg/emitter.dart b/frog/leg/emitter.dart |
| index 72978c3ba56c52ee7eee034138013b934fe5eb7e..81ac64aa97a2c6e5913cf02444c6b4e1d4e12778 100644 |
| --- a/frog/leg/emitter.dart |
| +++ b/frog/leg/emitter.dart |
| @@ -370,6 +370,57 @@ function(child, parent) { |
| } |
| } |
| + void emitGetterMethod(StringBuffer buffer, |
|
ngeoffray
2012/02/17 10:19:26
emitCallStubForGetter
floitsch
2012/02/17 13:19:32
Done.
|
| + ClassElement enclosingClass, |
| + Element member, |
| + Set<Selector> selectors) { |
| + |
| + String prototype = |
| + "${namer.isolatePropertyAccess(enclosingClass)}.prototype"; |
| + String getter; |
| + if (member.kind == ElementKind.GETTER) { |
| + getter = "this.${namer.getterName(member.name)}()"; |
| + } else { |
| + getter = "this.${namer.instanceFieldName(member.name)}"; |
| + } |
| + for (Selector selector in selectors) { |
| + String invocationName = |
| + namer.instanceMethodInvocationName(member.name, selector); |
| + SourceString callName = Namer.CLOSURE_INVOCATION_NAME; |
| + String closureCallName = |
| + namer.instanceMethodInvocationName(callName, selector); |
| + List<String> arguments = <String>[]; |
| + for (int i = 0; i < selector.argumentCount; i++) { |
| + arguments.add("arg$i"); |
| + } |
| + String joined = Strings.join(arguments, ", "); |
| + buffer.add("$prototype.$invocationName = function($joined) {\n"); |
| + buffer.add(" return $getter.$closureCallName($joined);\n"); |
| + buffer.add("};\n"); |
| + } |
| + } |
| + |
| + void emitGetterMethods(StringBuffer buffer) { |
|
ngeoffray
2012/02/17 10:19:26
emitCallStubForGetters
floitsch
2012/02/17 13:19:32
Done.
|
| + for (ClassElement classElement in compiler.universe.instantiatedClasses) { |
| + for (ClassElement currentClass = classElement; |
| + currentClass !== null; |
| + currentClass = currentClass.superclass) { |
| + // TODO(floitsch): we don't need to deal with members that have been |
| + // overwritten by subclasses. |
| + for (Element member in currentClass.members) { |
| + if (!member.isInstanceMember()) continue; |
| + if (member.kind == ElementKind.GETTER || |
| + member.kind == ElementKind.FIELD) { |
| + Set<Selector> selectors = |
| + compiler.universe.invokedNames[member.name]; |
| + if (selectors == null || selectors.isEmpty()) continue; |
| + emitGetterMethod(buffer, currentClass, member, selectors); |
| + } |
| + } |
| + } |
| + } |
| + } |
| + |
| void emitStaticNonFinalFieldInitializations(StringBuffer buffer) { |
| // Adds initializations inside the Isolate constructor. |
| // Example: |
| @@ -463,6 +514,7 @@ function(child, parent) { |
| emitStaticFunctions(buffer); |
| emitStaticFunctionGetters(buffer); |
| emitDynamicFunctionGetters(buffer); |
| + emitGetterMethods(buffer); |
| emitStaticFinalFieldInitializations(buffer); |
| buffer.add('var ${namer.CURRENT_ISOLATE} = new ${namer.ISOLATE}();\n'); |
| Element main = compiler.mainApp.find(Compiler.MAIN); |