OLD | NEW |
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 part of js_backend; | 5 part of js_backend; |
6 | 6 |
7 typedef void Recompile(Element element); | 7 typedef void Recompile(Element element); |
8 | 8 |
9 class ReturnInfo { | 9 class ReturnInfo { |
10 HType returnType; | 10 HType returnType; |
(...skipping 26 matching lines...) Expand all Loading... |
37 // Note that lazy initializers are treated like functions (but are not | 37 // Note that lazy initializers are treated like functions (but are not |
38 // of type [FunctionElement]. | 38 // of type [FunctionElement]. |
39 addCompiledFunction(Element function) => compiledFunctions.add(function); | 39 addCompiledFunction(Element function) => compiledFunctions.add(function); |
40 } | 40 } |
41 | 41 |
42 class OptionalParameterTypes { | 42 class OptionalParameterTypes { |
43 final List<SourceString> names; | 43 final List<SourceString> names; |
44 final List<HType> types; | 44 final List<HType> types; |
45 | 45 |
46 OptionalParameterTypes(int optionalArgumentsCount) | 46 OptionalParameterTypes(int optionalArgumentsCount) |
47 : names = new List<SourceString>(optionalArgumentsCount), | 47 : names = new List<SourceString>.fixedLength(optionalArgumentsCount), |
48 types = new List<HType>(optionalArgumentsCount); | 48 types = new List<HType>.fixedLength(optionalArgumentsCount); |
49 | 49 |
50 int get length => names.length; | 50 int get length => names.length; |
51 SourceString name(int index) => names[index]; | 51 SourceString name(int index) => names[index]; |
52 HType type(int index) => types[index]; | 52 HType type(int index) => types[index]; |
53 int indexOf(SourceString name) => names.indexOf(name); | 53 int indexOf(SourceString name) => names.indexOf(name); |
54 | 54 |
55 HType typeFor(SourceString name) { | 55 HType typeFor(SourceString name) { |
56 int index = indexOf(name); | 56 int index = indexOf(name); |
57 if (index == -1) return null; | 57 if (index == -1) return null; |
58 return type(index); | 58 return type(index); |
59 } | 59 } |
60 | 60 |
61 void update(int index, SourceString name, HType type) { | 61 void update(int index, SourceString name, HType type) { |
62 names[index] = name; | 62 names[index] = name; |
63 types[index] = type; | 63 types[index] = type; |
64 } | 64 } |
65 | 65 |
66 String toString() => "OptionalParameterTypes($names, $types)"; | 66 String toString() => "OptionalParameterTypes($names, $types)"; |
67 } | 67 } |
68 | 68 |
69 class HTypeList { | 69 class HTypeList { |
70 final List<HType> types; | 70 final List<HType> types; |
71 final List<SourceString> namedArguments; | 71 final List<SourceString> namedArguments; |
72 | 72 |
73 HTypeList(int length) | 73 HTypeList(int length) |
74 : types = new List<HType>(length), | 74 : types = new List<HType>.fixedLength(length), |
75 namedArguments = null; | 75 namedArguments = null; |
76 HTypeList.withNamedArguments(int length, this.namedArguments) | 76 HTypeList.withNamedArguments(int length, this.namedArguments) |
77 : types = new List<HType>(length); | 77 : types = new List<HType>.fixedLength(length); |
78 const HTypeList.withAllUnknown() | 78 const HTypeList.withAllUnknown() |
79 : types = null, | 79 : types = null, |
80 namedArguments = null; | 80 namedArguments = null; |
81 | 81 |
82 factory HTypeList.fromStaticInvocation(HInvokeStatic node, HTypeMap types) { | 82 factory HTypeList.fromStaticInvocation(HInvokeStatic node, HTypeMap types) { |
83 bool allUnknown = true; | 83 bool allUnknown = true; |
84 for (int i = 1; i < node.inputs.length; i++) { | 84 for (int i = 1; i < node.inputs.length; i++) { |
85 if (types[node.inputs[i]] != HType.UNKNOWN) { | 85 if (types[node.inputs[i]] != HType.UNKNOWN) { |
86 allUnknown = false; | 86 allUnknown = false; |
87 break; | 87 break; |
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1138 print("Inferred return types:"); | 1138 print("Inferred return types:"); |
1139 print("----------------------"); | 1139 print("----------------------"); |
1140 dumpReturnTypes(); | 1140 dumpReturnTypes(); |
1141 print(""); | 1141 print(""); |
1142 print("Inferred field types:"); | 1142 print("Inferred field types:"); |
1143 print("------------------------"); | 1143 print("------------------------"); |
1144 fieldTypes.dump(); | 1144 fieldTypes.dump(); |
1145 print(""); | 1145 print(""); |
1146 } | 1146 } |
1147 } | 1147 } |
OLD | NEW |