OLD | NEW |
1 // Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Fletch 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 library fletchc.debug_info_constructor_codegen; | 5 library fletchc.debug_info_constructor_codegen; |
6 | 6 |
7 import 'package:compiler/src/elements/elements.dart'; | 7 import 'package:compiler/src/elements/elements.dart'; |
8 import 'package:compiler/src/resolution/resolution.dart'; | 8 import 'package:compiler/src/resolution/resolution.dart'; |
9 import 'package:compiler/src/tree/tree.dart'; | 9 import 'package:compiler/src/tree/tree.dart'; |
10 import 'package:compiler/src/universe/universe.dart'; | 10 import 'package:compiler/src/universe/universe.dart'; |
11 | 11 |
12 import 'package:compiler/src/dart2jslib.dart' show | 12 import 'package:compiler/src/dart2jslib.dart' show |
13 Registry; | 13 Registry; |
14 | 14 |
15 import 'package:compiler/src/dart_types.dart' show | 15 import 'package:compiler/src/dart_types.dart' show |
16 DartType; | 16 DartType; |
17 | 17 |
18 import 'package:compiler/src/util/util.dart' show | 18 import 'package:compiler/src/util/util.dart' show |
19 Spannable; | 19 Spannable; |
20 | 20 |
21 import 'bytecode_builder.dart'; | 21 import 'bytecode_builder.dart'; |
22 import 'closure_environment.dart'; | 22 import 'closure_environment.dart'; |
23 import 'codegen_visitor.dart'; | 23 import 'codegen_visitor.dart'; |
24 | 24 |
25 import 'compiled_function.dart' show | 25 import 'fletch_function_builder.dart' show |
26 CompiledFunction; | 26 FletchFunctionBuilder; |
27 | 27 |
28 import 'compiled_class.dart' show | 28 import 'fletch_class_builder.dart' show |
29 CompiledClass; | 29 FletchClassBuilder; |
30 | 30 |
31 import 'fletch_backend.dart'; | 31 import 'fletch_backend.dart'; |
32 import 'fletch_context.dart'; | 32 import 'fletch_context.dart'; |
33 import 'constructor_codegen.dart'; | 33 import 'constructor_codegen.dart'; |
34 import 'lazy_field_initializer_codegen.dart'; | 34 import 'lazy_field_initializer_codegen.dart'; |
35 import 'debug_info_lazy_field_initializer_codegen.dart'; | 35 import 'debug_info_lazy_field_initializer_codegen.dart'; |
36 | 36 |
37 class DebugInfoConstructorCodegen extends ConstructorCodegen { | 37 class DebugInfoConstructorCodegen extends ConstructorCodegen { |
38 final FletchCompiler compiler; | 38 final FletchCompiler compiler; |
39 | 39 |
40 // Regenerate the bytecode in a fresh buffer separately from the compiled | 40 // Regenerate the bytecode in a fresh buffer separately from the compiled |
41 // function. If we did not create a separate buffer, the bytecode would | 41 // function. If we did not create a separate buffer, the bytecode would |
42 // be appended to the compiled function builder and we would get a compiled | 42 // be appended to the compiled function builder and we would get a compiled |
43 // function with incorrect bytecode. | 43 // function with incorrect bytecode. |
44 final BytecodeBuilder debugBuilder; | 44 final BytecodeBuilder debugBuilder; |
45 | 45 |
46 DebugInfoConstructorCodegen(CompiledFunction compiledFunction, | 46 DebugInfoConstructorCodegen(FletchFunctionBuilder functionBuilder, |
47 FletchContext context, | 47 FletchContext context, |
48 TreeElements elements, | 48 TreeElements elements, |
49 Registry registry, | 49 Registry registry, |
50 ClosureEnvironment closureEnvironment, | 50 ClosureEnvironment closureEnvironment, |
51 ConstructorElement constructor, | 51 ConstructorElement constructor, |
52 CompiledClass compiledClass, | 52 FletchClassBuilder classBuilder, |
53 this.compiler) | 53 this.compiler) |
54 : debugBuilder = new BytecodeBuilder(compiledFunction.arity), | 54 : debugBuilder = new BytecodeBuilder(functionBuilder.arity), |
55 super(compiledFunction, context, elements, registry, | 55 super(functionBuilder, context, elements, registry, |
56 closureEnvironment, constructor, compiledClass); | 56 closureEnvironment, constructor, classBuilder); |
57 | 57 |
58 BytecodeBuilder get builder => debugBuilder; | 58 BytecodeBuilder get builder => debugBuilder; |
59 | 59 |
60 LazyFieldInitializerCodegen lazyFieldInitializerCodegenFor( | 60 LazyFieldInitializerCodegen lazyFieldInitializerCodegenFor( |
61 CompiledFunction function, | 61 FletchFunctionBuilder function, |
62 FieldElement field) { | 62 FieldElement field) { |
63 TreeElements elements = field.resolvedAst.elements; | 63 TreeElements elements = field.resolvedAst.elements; |
64 return new DebugInfoLazyFieldInitializerCodegen( | 64 return new DebugInfoLazyFieldInitializerCodegen( |
65 function, | 65 function, |
66 context, | 66 context, |
67 elements, | 67 elements, |
68 null, | 68 null, |
69 context.backend.createClosureEnvironment(field, elements), | 69 context.backend.createClosureEnvironment(field, elements), |
70 field, | 70 field, |
71 compiler, | 71 compiler, |
72 builder); | 72 builder); |
73 } | 73 } |
74 | 74 |
75 void recordDebugInfo(Node node) { | 75 void recordDebugInfo(Node node) { |
76 compiledFunction.debugInfo.addLocation(compiler, builder.byteSize, node); | 76 functionBuilder.debugInfo.addLocation(compiler, builder.byteSize, node); |
77 } | 77 } |
78 | 78 |
79 void pushVariableDeclaration(LocalValue value) { | 79 void pushVariableDeclaration(LocalValue value) { |
80 super.pushVariableDeclaration(value); | 80 super.pushVariableDeclaration(value); |
81 compiledFunction.debugInfo.pushScope(builder.byteSize, value); | 81 functionBuilder.debugInfo.pushScope(builder.byteSize, value); |
82 } | 82 } |
83 | 83 |
84 void popVariableDeclaration(Element element) { | 84 void popVariableDeclaration(Element element) { |
85 super.popVariableDeclaration(element); | 85 super.popVariableDeclaration(element); |
86 compiledFunction.debugInfo.popScope(builder.byteSize); | 86 functionBuilder.debugInfo.popScope(builder.byteSize); |
87 } | 87 } |
88 | 88 |
89 void registerDynamicInvocation(Selector selector) { } | 89 void registerDynamicInvocation(Selector selector) { } |
90 void registerDynamicGetter(Selector selector) { } | 90 void registerDynamicGetter(Selector selector) { } |
91 void registerDynamicSetter(Selector selector) { } | 91 void registerDynamicSetter(Selector selector) { } |
92 void registerStaticInvocation(FunctionElement function) { } | 92 void registerStaticInvocation(FunctionElement function) { } |
93 void registerInstantiatedClass(ClassElement klass) { } | 93 void registerInstantiatedClass(ClassElement klass) { } |
94 | 94 |
95 void doFieldInitializerSet(Send node, FieldElement field) { | 95 void doFieldInitializerSet(Send node, FieldElement field) { |
96 recordDebugInfo(node); | 96 recordDebugInfo(node); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 void visitForValue(Node node) { | 163 void visitForValue(Node node) { |
164 recordDebugInfo(node); | 164 recordDebugInfo(node); |
165 super.visitForValue(node); | 165 super.visitForValue(node); |
166 } | 166 } |
167 | 167 |
168 void visitForEffect(Node node) { | 168 void visitForEffect(Node node) { |
169 recordDebugInfo(node); | 169 recordDebugInfo(node); |
170 super.visitForEffect(node); | 170 super.visitForEffect(node); |
171 } | 171 } |
172 } | 172 } |
OLD | NEW |