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

Side by Side Diff: dart/lib/compiler/implementation/ssa/builder.dart

Issue 10377166: Prepare to have more than one universe. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 class Interceptors { 5 class Interceptors {
6 Compiler compiler; 6 Compiler compiler;
7 Interceptors(Compiler this.compiler); 7 Interceptors(Compiler this.compiler);
8 8
9 SourceString mapOperatorToMethodName(Operator op) { 9 SourceString mapOperatorToMethodName(Operator op) {
10 String name = op.source.stringValue; 10 String name = op.source.stringValue;
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 if (body.constructor == constructor) { 850 if (body.constructor == constructor) {
851 bodyElement = backendMember; 851 bodyElement = backendMember;
852 break; 852 break;
853 } 853 }
854 } 854 }
855 } 855 }
856 if (bodyElement === null) { 856 if (bodyElement === null) {
857 bodyElement = new ConstructorBodyElement(constructor); 857 bodyElement = new ConstructorBodyElement(constructor);
858 TreeElements treeElements = 858 TreeElements treeElements =
859 compiler.resolver.resolveMethodElement(constructor); 859 compiler.resolver.resolveMethodElement(constructor);
860 compiler.addToWorkList(bodyElement, treeElements); 860 compiler.enqueuer.codegen.addToWorkList(bodyElement, treeElements);
861 classElement.backendMembers = 861 classElement.backendMembers =
862 classElement.backendMembers.prepend(bodyElement); 862 classElement.backendMembers.prepend(bodyElement);
863 } 863 }
864 assert(bodyElement.kind === ElementKind.GENERATIVE_CONSTRUCTOR_BODY); 864 assert(bodyElement.kind === ElementKind.GENERATIVE_CONSTRUCTOR_BODY);
865 return bodyElement; 865 return bodyElement;
866 } 866 }
867 867
868 void inlineSuperOrRedirect(FunctionElement constructor, 868 void inlineSuperOrRedirect(FunctionElement constructor,
869 Selector selector, 869 Selector selector,
870 Link<Node> arguments, 870 Link<Node> arguments,
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
1480 if (nestedClosureData === null) { 1480 if (nestedClosureData === null) {
1481 // TODO(floitsch): we can only assume that the reason for not having a 1481 // TODO(floitsch): we can only assume that the reason for not having a
1482 // closure data here is, because the function is inside an initializer. 1482 // closure data here is, because the function is inside an initializer.
1483 compiler.unimplemented("Closures inside initializers", node: node); 1483 compiler.unimplemented("Closures inside initializers", node: node);
1484 } 1484 }
1485 assert(nestedClosureData !== null); 1485 assert(nestedClosureData !== null);
1486 assert(nestedClosureData.closureClassElement !== null); 1486 assert(nestedClosureData.closureClassElement !== null);
1487 ClassElement closureClassElement = 1487 ClassElement closureClassElement =
1488 nestedClosureData.closureClassElement; 1488 nestedClosureData.closureClassElement;
1489 FunctionElement callElement = nestedClosureData.callElement; 1489 FunctionElement callElement = nestedClosureData.callElement;
1490 compiler.addToWorkList(callElement, elements); 1490 compiler.enqueuer.codegen.addToWorkList(callElement, elements);
1491 compiler.registerInstantiatedClass(closureClassElement); 1491 compiler.registerInstantiatedClass(closureClassElement);
1492 assert(closureClassElement.members.isEmpty()); 1492 assert(closureClassElement.members.isEmpty());
1493 1493
1494 List<HInstruction> capturedVariables = <HInstruction>[]; 1494 List<HInstruction> capturedVariables = <HInstruction>[];
1495 for (Element member in closureClassElement.backendMembers) { 1495 for (Element member in closureClassElement.backendMembers) {
1496 // The backendMembers also contains the call method(s). We are only 1496 // The backendMembers also contains the call method(s). We are only
1497 // interested in the fields. 1497 // interested in the fields.
1498 if (member.kind == ElementKind.FIELD) { 1498 if (member.kind == ElementKind.FIELD) {
1499 Element capturedLocal = nestedClosureData.capturedFieldMapping[member]; 1499 Element capturedLocal = nestedClosureData.capturedFieldMapping[member];
1500 assert(capturedLocal != null); 1500 assert(capturedLocal != null);
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1912 bool isNot = false; 1912 bool isNot = false;
1913 // TODO(ngeoffray): Duplicating pattern in resolver. We should 1913 // TODO(ngeoffray): Duplicating pattern in resolver. We should
1914 // add a new kind of node. 1914 // add a new kind of node.
1915 if (typeAnnotation == null) { 1915 if (typeAnnotation == null) {
1916 typeAnnotation = argument.asSend().receiver; 1916 typeAnnotation = argument.asSend().receiver;
1917 isNot = true; 1917 isNot = true;
1918 } 1918 }
1919 1919
1920 Type type = elements.getType(typeAnnotation); 1920 Type type = elements.getType(typeAnnotation);
1921 HInstruction typeInfo = null; 1921 HInstruction typeInfo = null;
1922 if (compiler.universe.rti.hasTypeArguments(type)) { 1922 if (compiler.codegenWorld.rti.hasTypeArguments(type)) {
1923 HInstruction typeInfoGetter = 1923 HInstruction typeInfoGetter =
1924 new HStatic(interceptors.getGetRuntimeTypeInfo()); 1924 new HStatic(interceptors.getGetRuntimeTypeInfo());
1925 add(typeInfoGetter); 1925 add(typeInfoGetter);
1926 typeInfo = new HInvokeStatic(Selector.INVOCATION_1, 1926 typeInfo = new HInvokeStatic(Selector.INVOCATION_1,
1927 <HInstruction>[typeInfoGetter, 1927 <HInstruction>[typeInfoGetter,
1928 expression]); 1928 expression]);
1929 add(typeInfo); 1929 add(typeInfo);
1930 } 1930 }
1931 if (type.element.kind === ElementKind.TYPE_VARIABLE) { 1931 if (type.element.kind === ElementKind.TYPE_VARIABLE) {
1932 // TODO(karlklose): We emulate the frog behavior and answer 1932 // TODO(karlklose): We emulate the frog behavior and answer
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
2332 HType elementType = computeType(element); 2332 HType elementType = computeType(element);
2333 HInstruction newInstance = new HInvokeStatic(selector, inputs, elementType); 2333 HInstruction newInstance = new HInvokeStatic(selector, inputs, elementType);
2334 push(newInstance); 2334 push(newInstance);
2335 2335
2336 TypeAnnotation annotation = getTypeAnnotationFromSend(node); 2336 TypeAnnotation annotation = getTypeAnnotationFromSend(node);
2337 Type type = elements.getType(annotation); 2337 Type type = elements.getType(annotation);
2338 generateSetRuntimeTypeInformation(newInstance, type); 2338 generateSetRuntimeTypeInformation(newInstance, type);
2339 } 2339 }
2340 2340
2341 generateSetRuntimeTypeInformation(HInstruction instance, Type type) { 2341 generateSetRuntimeTypeInformation(HInstruction instance, Type type) {
2342 if (compiler.universe.rti.hasTypeArguments(type)) { 2342 if (compiler.codegenWorld.rti.hasTypeArguments(type)) {
2343 String typeString = compiler.universe.rti.asJsString(type); 2343 String typeString = compiler.codegenWorld.rti.asJsString(type);
2344 HInstruction typeInfo = new HForeign(new LiteralDartString(typeString), 2344 HInstruction typeInfo = new HForeign(new LiteralDartString(typeString),
2345 new LiteralDartString('Object'), 2345 new LiteralDartString('Object'),
2346 <HInstruction>[]); 2346 <HInstruction>[]);
2347 add(typeInfo); 2347 add(typeInfo);
2348 HInstruction typeInfoSetter = 2348 HInstruction typeInfoSetter =
2349 new HStatic(interceptors.getSetRuntimeTypeInfo()); 2349 new HStatic(interceptors.getSetRuntimeTypeInfo());
2350 add(typeInfoSetter); 2350 add(typeInfoSetter);
2351 Selector setSelector = Selector.INVOCATION_2; 2351 Selector setSelector = Selector.INVOCATION_2;
2352 var inputs = <HInstruction>[typeInfoSetter, instance, typeInfo]; 2352 var inputs = <HInstruction>[typeInfoSetter, instance, typeInfo];
2353 add(new HInvokeStatic(setSelector, inputs)); 2353 add(new HInvokeStatic(setSelector, inputs));
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after
3376 <HInstruction>[target, input], 3376 <HInstruction>[target, input],
3377 HType.STRING)); 3377 HType.STRING));
3378 return builder.pop(); 3378 return builder.pop();
3379 } 3379 }
3380 3380
3381 HInstruction result(Node node) { 3381 HInstruction result(Node node) {
3382 flushLiterals(node); 3382 flushLiterals(node);
3383 return prefix; 3383 return prefix;
3384 } 3384 }
3385 } 3385 }
OLDNEW
« no previous file with comments | « dart/lib/compiler/implementation/scanner/scanner_task.dart ('k') | dart/lib/compiler/implementation/ssa/closure.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698