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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_emitter/model.dart

Issue 661783002: dart2js: Add support for static fields to new emitter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library dart2js.new_js_emitter.model; 5 library dart2js.new_js_emitter.model;
6 6
7 import '../js/js.dart' as js show Expression; 7 import '../js/js.dart' as js show Expression;
8 import '../constants/values.dart' show ConstantValue; 8 import '../constants/values.dart' show ConstantValue;
9 9
10 class Program { 10 class Program {
(...skipping 17 matching lines...) Expand all
28 /** 28 /**
29 * This class represents one output file. 29 * This class represents one output file.
30 * 30 *
31 * If no library is deferred, there is only one [Output] of type [MainOutput]. 31 * If no library is deferred, there is only one [Output] of type [MainOutput].
32 */ 32 */
33 abstract class Output { 33 abstract class Output {
34 bool get isMainOutput => mainOutput == this; 34 bool get isMainOutput => mainOutput == this;
35 MainOutput get mainOutput; 35 MainOutput get mainOutput;
36 final List<Library> libraries; 36 final List<Library> libraries;
37 final List<Constant> constants; 37 final List<Constant> constants;
38 // TODO(floitsch): should we move static fields into libraries or classes?
39 final List<StaticField> staticNonFinalFields;
38 40
39 /// Output file name without extension. 41 /// Output file name without extension.
40 final String outputFileName; 42 final String outputFileName;
41 43
42 Output(this.outputFileName, 44 Output(this.outputFileName,
43 this.libraries, 45 this.libraries,
46 this.staticNonFinalFields,
44 this.constants); 47 this.constants);
45 } 48 }
46 49
47 /** 50 /**
48 * The main output file. 51 * The main output file.
49 * 52 *
50 * This code emitted from this [Output] must be loaded first. It can then load 53 * This code emitted from this [Output] must be loaded first. It can then load
51 * other [DeferredOutput]s. 54 * other [DeferredOutput]s.
52 */ 55 */
53 class MainOutput extends Output { 56 class MainOutput extends Output {
54 final js.Expression main; 57 final js.Expression main;
55 final List<Holder> holders; 58 final List<Holder> holders;
56 59
57 MainOutput(String outputFileName, 60 MainOutput(String outputFileName,
58 this.main, 61 this.main,
59 List<Library> libraries, 62 List<Library> libraries,
63 List<StaticField> staticNonFinalFields,
60 List<Constant> constants, 64 List<Constant> constants,
61 this.holders) 65 this.holders)
62 : super(outputFileName, libraries, constants); 66 : super(outputFileName, libraries, staticNonFinalFields, constants);
63 67
64 MainOutput get mainOutput => this; 68 MainOutput get mainOutput => this;
65 } 69 }
66 70
67 /** 71 /**
68 * An output (file) for deferred code. 72 * An output (file) for deferred code.
69 */ 73 */
70 class DeferredOutput extends Output { 74 class DeferredOutput extends Output {
71 final MainOutput mainOutput; 75 final MainOutput mainOutput;
72 final String name; 76 final String name;
73 77
74 List<Holder> get holders => mainOutput.holders; 78 List<Holder> get holders => mainOutput.holders;
75 79
76 DeferredOutput(String outputFileName, 80 DeferredOutput(String outputFileName,
77 this.name, 81 this.name,
78 this.mainOutput, 82 this.mainOutput,
79 List<Library> libraries, 83 List<Library> libraries,
84 List<StaticField> staticNonFinalFields,
80 List<Constant> constants) 85 List<Constant> constants)
81 : super(outputFileName, libraries, constants); 86 : super(outputFileName, libraries, staticNonFinalFields, constants);
82 } 87 }
83 88
84 class Constant { 89 class Constant {
85 final String name; 90 final String name;
86 final Holder holder; 91 final Holder holder;
87 final ConstantValue value; 92 final ConstantValue value;
88 93
89 Constant(this.name, this.holder, this.value); 94 Constant(this.name, this.holder, this.value);
90 } 95 }
91 96
92 class Library { 97 class Library {
93 final String uri; 98 final String uri;
94 final List<StaticMethod> statics; 99 final List<StaticMethod> statics;
95 final List<Class> classes; 100 final List<Class> classes;
96 Library(this.uri, this.statics, this.classes); 101 Library(this.uri, this.statics, this.classes);
97 } 102 }
98 103
104 class StaticField {
105 final String name;
106 final Holder holder;
floitsch 2014/10/16 14:27:55 The holder for static fields in the "isolate" obje
kasperl 2014/10/17 06:47:04 Maybe add this as a comment in the code?
floitsch 2014/10/17 09:25:56 Done.
107 final js.Expression code;
108 final bool isFinal;
109 final bool isLazy;
110
111 StaticField(this.name, this.holder, this.code,
112 this.isFinal, this.isLazy);
113 }
114
99 class Class { 115 class Class {
100 final String name; 116 final String name;
101 final Holder holder; 117 final Holder holder;
102 Class superclass; 118 Class superclass;
103 final List<Method> methods; 119 final List<Method> methods;
104 Class(this.name, this.holder, this.methods); 120 Class(this.name, this.holder, this.methods);
105 121
106 void setSuperclass(Class superclass) { 122 void setSuperclass(Class superclass) {
107 this.superclass = superclass; 123 this.superclass = superclass;
108 } 124 }
109 125
110 String get superclassName 126 String get superclassName
111 => (superclass == null) ? "" : superclass.name; 127 => (superclass == null) ? "" : superclass.name;
112 int get superclassHolderIndex 128 int get superclassHolderIndex
113 => (superclass == null) ? 0 : superclass.holder.index; 129 => (superclass == null) ? 0 : superclass.holder.index;
114 } 130 }
115 131
116 class Method { 132 class Method {
117 final String name; 133 final String name;
118 final js.Expression code; 134 final js.Expression code;
119 Method(this.name, this.code); 135 Method(this.name, this.code);
120 } 136 }
121 137
122 class StaticMethod extends Method { 138 class StaticMethod extends Method {
123 final Holder holder; 139 final Holder holder;
124 StaticMethod(String name, this.holder, js.Expression code) 140 StaticMethod(String name, this.holder, js.Expression code)
125 : super(name, code); 141 : super(name, code);
126 } 142 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698