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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart

Issue 1198293002: dart2js: Use an abstract Name class for names in the generated JavaScript ast. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fix tests Created 5 years, 6 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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.ir_builder_task; 5 library dart2js.ir_builder_task;
6 6
7 import '../closure.dart' as closurelib; 7 import '../closure.dart' as closurelib;
8 import '../closure.dart' hide ClosureScope; 8 import '../closure.dart' hide ClosureScope;
9 import '../constants/expressions.dart'; 9 import '../constants/expressions.dart';
10 import '../dart_types.dart'; 10 import '../dart_types.dart';
11 import '../dart2jslib.dart'; 11 import '../dart2jslib.dart';
12 import '../elements/elements.dart'; 12 import '../elements/elements.dart';
13 import '../elements/modelx.dart' show SynthesizedConstructorElementX, 13 import '../elements/modelx.dart' show SynthesizedConstructorElementX,
14 ConstructorBodyElementX, FunctionSignatureX; 14 ConstructorBodyElementX, FunctionSignatureX;
15 import '../io/source_information.dart'; 15 import '../io/source_information.dart';
16 import '../js_backend/js_backend.dart' show JavaScriptBackend; 16 import '../js_backend/js_backend.dart' show JavaScriptBackend,
17 SyntheticConstantKind;
17 import '../resolution/semantic_visitor.dart'; 18 import '../resolution/semantic_visitor.dart';
18 import '../resolution/operators.dart' as op; 19 import '../resolution/operators.dart' as op;
19 import '../tree/tree.dart' as ast; 20 import '../tree/tree.dart' as ast;
20 import '../universe/universe.dart' show SelectorKind, CallStructure; 21 import '../universe/universe.dart' show SelectorKind, CallStructure;
21 import '../constants/values.dart' show ConstantValue; 22 import '../constants/values.dart' show ConstantValue;
22 import 'cps_ir_nodes.dart' as ir; 23 import 'cps_ir_nodes.dart' as ir;
23 import 'cps_ir_builder.dart'; 24 import 'cps_ir_builder.dart';
24 import '../native/native.dart' show NativeBehavior; 25 import '../native/native.dart' show NativeBehavior;
25 26
26 // TODO(karlklose): remove. 27 // TODO(karlklose): remove.
27 import '../js/js.dart' as js show js, Template, Expression; 28 import '../js/js.dart' as js show js, Template, Expression, Name;
28 import '../ssa/ssa.dart' show TypeMaskFactory; 29 import '../ssa/ssa.dart' show TypeMaskFactory;
29 import '../types/types.dart' show TypeMask; 30 import '../types/types.dart' show TypeMask;
30 import '../util/util.dart'; 31 import '../util/util.dart';
31 32
32 import 'package:_internal/compiler/js_lib/shared/embedded_names.dart' 33 import 'package:_internal/compiler/js_lib/shared/embedded_names.dart'
33 show JsBuiltin, JsGetName; 34 show JsBuiltin, JsGetName;
34 import '../constants/values.dart'; 35 import '../constants/values.dart';
35 36
36 typedef void IrBuilderCallback(Element element, ir.FunctionDefinition irNode); 37 typedef void IrBuilderCallback(Element element, ir.FunctionDefinition irNode);
37 38
(...skipping 2976 matching lines...) Expand 10 before | Expand all | Expand 10 after
3014 3015
3015 case 'JS_BUILTIN': 3016 case 'JS_BUILTIN':
3016 // The first argument is a description of the type and effect of the 3017 // The first argument is a description of the type and effect of the
3017 // builtin, which has already been analyzed in the frontend. The second 3018 // builtin, which has already been analyzed in the frontend. The second
3018 // argument must be a [JsBuiltin] value. All other arguments are 3019 // argument must be a [JsBuiltin] value. All other arguments are
3019 // values used by the JavaScript template that is associated with the 3020 // values used by the JavaScript template that is associated with the
3020 // builtin. 3021 // builtin.
3021 validateArgumentCount(minimum: 2); 3022 validateArgumentCount(minimum: 2);
3022 3023
3023 ast.Node builtin = argumentNodes.tail.head; 3024 ast.Node builtin = argumentNodes.tail.head;
3024 JsBuiltin value = getEnumValue(argumentNodes.tail.head, 3025 JsBuiltin value = getEnumValue(builtin, backend.jsBuiltinEnum,
3025 backend.jsBuiltinEnum, JsBuiltin.values); 3026 JsBuiltin.values);
3026 js.Template template = backend.emitter.builtinTemplateFor(value); 3027 js.Template template = backend.emitter.builtinTemplateFor(value);
3027 List<ir.Primitive> arguments = 3028 List<ir.Primitive> arguments =
3028 argumentNodes.skip(2).mapToList(visit, growable: false); 3029 argumentNodes.skip(2).mapToList(visit, growable: false);
3029 return irBuilder.buildForeignCode(template, arguments, behavior); 3030 return irBuilder.buildForeignCode(template, arguments, behavior);
3030 3031
3031 case 'JS_EMBEDDED_GLOBAL': 3032 case 'JS_EMBEDDED_GLOBAL':
3032 validateArgumentCount(exactly: 2); 3033 validateArgumentCount(exactly: 2);
3033 3034
3034 String name = expectStringConstant(argumentNodes.tail.head); 3035 String name = expectStringConstant(argumentNodes.tail.head);
3035 js.Expression access = 3036 js.Expression access =
(...skipping 18 matching lines...) Expand all
3054 3055
3055 case 'JS_EFFECT': 3056 case 'JS_EFFECT':
3056 return irBuilder.buildNullConstant(); 3057 return irBuilder.buildNullConstant();
3057 3058
3058 case 'JS_GET_NAME': 3059 case 'JS_GET_NAME':
3059 validateArgumentCount(exactly: 1); 3060 validateArgumentCount(exactly: 1);
3060 3061
3061 ast.Node argument = argumentNodes.head; 3062 ast.Node argument = argumentNodes.head;
3062 JsGetName id = getEnumValue(argument, backend.jsGetNameEnum, 3063 JsGetName id = getEnumValue(argument, backend.jsGetNameEnum,
3063 JsGetName.values); 3064 JsGetName.values);
3064 String name = backend.namer.getNameForJsGetName(argument, id); 3065 js.Name name = backend.namer.getNameForJsGetName(argument, id);
3065 return irBuilder.buildStringConstant(name); 3066 ConstantValue nameConstant =
3067 new SyntheticConstantValue(SyntheticConstantKind.NAME,
3068 js.js.quoteName(name));
3069
3070 return irBuilder.buildConstant(nameConstant);
3066 3071
3067 case 'JS_GET_FLAG': 3072 case 'JS_GET_FLAG':
3068 validateArgumentCount(exactly: 1); 3073 validateArgumentCount(exactly: 1);
3069 3074
3070 String name = expectStringConstant(argumentNodes.first); 3075 String name = expectStringConstant(argumentNodes.first);
3071 bool value = false; 3076 bool value = false;
3072 switch (name) { 3077 switch (name) {
3073 case 'MUST_RETAIN_METADATA': 3078 case 'MUST_RETAIN_METADATA':
3074 value = backend.mustRetainMetadata; 3079 value = backend.mustRetainMetadata;
3075 break; 3080 break;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
3186 } 3191 }
3187 3192
3188 processSetStatic(ir.SetStatic node) { 3193 processSetStatic(ir.SetStatic node) {
3189 node.body = replacementFor(node.body); 3194 node.body = replacementFor(node.body);
3190 } 3195 }
3191 3196
3192 processContinuation(ir.Continuation node) { 3197 processContinuation(ir.Continuation node) {
3193 node.body = replacementFor(node.body); 3198 node.body = replacementFor(node.body);
3194 } 3199 }
3195 } 3200 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698