Chromium Code Reviews| 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 class ConstantEmitter { | 7 class ConstantEmitter { |
| 8 ConstantReferenceEmitter _referenceEmitter; | 8 ConstantReferenceEmitter _referenceEmitter; |
| 9 ConstantLiteralEmitter _literalEmitter; | 9 ConstantLiteralEmitter _literalEmitter; |
| 10 | 10 |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 233 } | 233 } |
| 234 | 234 |
| 235 jsAst.Expression visitList(ListConstantValue constant) { | 235 jsAst.Expression visitList(ListConstantValue constant) { |
| 236 List<jsAst.Expression> elements = _array(constant.entries); | 236 List<jsAst.Expression> elements = _array(constant.entries); |
| 237 jsAst.ArrayInitializer array = new jsAst.ArrayInitializer(elements); | 237 jsAst.ArrayInitializer array = new jsAst.ArrayInitializer(elements); |
| 238 jsAst.Expression value = makeConstantListTemplate.instantiate([array]); | 238 jsAst.Expression value = makeConstantListTemplate.instantiate([array]); |
| 239 return maybeAddTypeArguments(constant.type, value); | 239 return maybeAddTypeArguments(constant.type, value); |
| 240 } | 240 } |
| 241 | 241 |
| 242 jsAst.Expression getJsConstructor(ClassElement element) { | 242 jsAst.Expression getJsConstructor(ClassElement element) { |
| 243 return namer.elementAccess(element); | 243 return backend.emitter.globalPropertyAccess(element); |
|
floitsch
2014/12/03 17:02:24
emitter.constructorAccess
zarah
2014/12/05 08:22:49
Done.
| |
| 244 } | 244 } |
| 245 | 245 |
| 246 jsAst.Expression visitMap(JavaScriptMapConstant constant) { | 246 jsAst.Expression visitMap(JavaScriptMapConstant constant) { |
| 247 jsAst.Expression jsMap() { | 247 jsAst.Expression jsMap() { |
| 248 List<jsAst.Property> properties = <jsAst.Property>[]; | 248 List<jsAst.Property> properties = <jsAst.Property>[]; |
| 249 for (int i = 0; i < constant.length; i++) { | 249 for (int i = 0; i < constant.length; i++) { |
| 250 StringConstantValue key = constant.keys[i]; | 250 StringConstantValue key = constant.keys[i]; |
| 251 if (key.primitiveValue == JavaScriptMapConstant.PROTO_PROPERTY) { | 251 if (key.primitiveValue == JavaScriptMapConstant.PROTO_PROPERTY) { |
| 252 continue; | 252 continue; |
| 253 } | 253 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 315 } | 315 } |
| 316 | 316 |
| 317 jsAst.Expression value = | 317 jsAst.Expression value = |
| 318 new jsAst.New(getJsConstructor(classElement), arguments); | 318 new jsAst.New(getJsConstructor(classElement), arguments); |
| 319 return maybeAddTypeArguments(constant.type, value); | 319 return maybeAddTypeArguments(constant.type, value); |
| 320 } | 320 } |
| 321 | 321 |
| 322 JavaScriptBackend get backend => compiler.backend; | 322 JavaScriptBackend get backend => compiler.backend; |
| 323 | 323 |
| 324 jsAst.PropertyAccess getHelperProperty(Element helper) { | 324 jsAst.PropertyAccess getHelperProperty(Element helper) { |
| 325 return backend.namer.elementAccess(helper); | 325 return backend.emitter.globalPropertyAccess(helper); |
|
floitsch
2014/12/03 17:02:24
staticFunctionAccess
zarah
2014/12/05 08:22:49
Done.
| |
| 326 } | 326 } |
| 327 | 327 |
| 328 jsAst.Expression visitType(TypeConstantValue constant) { | 328 jsAst.Expression visitType(TypeConstantValue constant) { |
| 329 DartType type = constant.representedType; | 329 DartType type = constant.representedType; |
| 330 String name = namer.getRuntimeTypeName(type.element); | 330 String name = namer.getRuntimeTypeName(type.element); |
| 331 jsAst.Expression typeName = new jsAst.LiteralString("'$name'"); | 331 jsAst.Expression typeName = new jsAst.LiteralString("'$name'"); |
| 332 return new jsAst.Call(getHelperProperty(backend.getCreateRuntimeType()), | 332 return new jsAst.Call(getHelperProperty(backend.getCreateRuntimeType()), |
| 333 [typeName]); | 333 [typeName]); |
| 334 } | 334 } |
| 335 | 335 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 380 return new jsAst.Call(getHelperProperty(backend.getSetRuntimeTypeInfo()), | 380 return new jsAst.Call(getHelperProperty(backend.getSetRuntimeTypeInfo()), |
| 381 [value, argumentList]); | 381 [value, argumentList]); |
| 382 } | 382 } |
| 383 return value; | 383 return value; |
| 384 } | 384 } |
| 385 | 385 |
| 386 jsAst.Expression visitDeferred(DeferredConstantValue constant) { | 386 jsAst.Expression visitDeferred(DeferredConstantValue constant) { |
| 387 return constantEmitter.reference(constant.referenced); | 387 return constantEmitter.reference(constant.referenced); |
| 388 } | 388 } |
| 389 } | 389 } |
| OLD | NEW |