OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 dart2js.js_emitter; | 5 part of dart2js.js_emitter; |
6 | 6 |
7 class ParameterStubGenerator { | 7 class ParameterStubGenerator { |
8 static final Set<Selector> emptySelectorSet = new Set<Selector>(); | 8 static final Set<Selector> emptySelectorSet = new Set<Selector>(); |
9 | 9 |
10 final Namer namer; | 10 final Namer namer; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 } else { | 93 } else { |
94 int index = names.indexOf(element.name); | 94 int index = names.indexOf(element.name); |
95 if (index != -1) { | 95 if (index != -1) { |
96 indexOfLastOptionalArgumentInParameters = count; | 96 indexOfLastOptionalArgumentInParameters = count; |
97 // The order of the named arguments is not the same as the | 97 // The order of the named arguments is not the same as the |
98 // one in the real method (which is in Dart source order). | 98 // one in the real method (which is in Dart source order). |
99 argumentsBuffer[count] = js('#', jsName); | 99 argumentsBuffer[count] = js('#', jsName); |
100 parametersBuffer[optionalParameterStart + index] = | 100 parametersBuffer[optionalParameterStart + index] = |
101 new jsAst.Parameter(jsName); | 101 new jsAst.Parameter(jsName); |
102 } else { | 102 } else { |
103 ConstantExpression constant = handler.getConstantForVariable(element); | 103 ConstantValue value = handler.getConstantValueForVariable(element); |
104 if (constant == null) { | 104 if (value == null) { |
105 argumentsBuffer[count] = | 105 argumentsBuffer[count] = |
106 emitter.constantReference(new NullConstantValue()); | 106 emitter.constantReference(new NullConstantValue()); |
107 } else { | 107 } else { |
108 ConstantValue value = constant.value; | |
109 if (!value.isNull) { | 108 if (!value.isNull) { |
110 // If the value is the null constant, we should not pass it | 109 // If the value is the null constant, we should not pass it |
111 // down to the native method. | 110 // down to the native method. |
112 indexOfLastOptionalArgumentInParameters = count; | 111 indexOfLastOptionalArgumentInParameters = count; |
113 } | 112 } |
114 argumentsBuffer[count] = emitter.constantReference(value); | 113 argumentsBuffer[count] = emitter.constantReference(value); |
115 } | 114 } |
116 } | 115 } |
117 } | 116 } |
118 count++; | 117 count++; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 generateParameterStub(member, selector, null); | 272 generateParameterStub(member, selector, null); |
274 if (stub != null) { | 273 if (stub != null) { |
275 stubs.add(stub); | 274 stubs.add(stub); |
276 } | 275 } |
277 } | 276 } |
278 } | 277 } |
279 | 278 |
280 return stubs; | 279 return stubs; |
281 } | 280 } |
282 } | 281 } |
OLD | NEW |