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

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

Issue 1185633003: cps-ir: Support foreign code. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Status file updates. 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; 5 library dart2js.ir_builder;
6 6
7 import '../compile_time_constants.dart' show BackendConstantEnvironment; 7 import '../compile_time_constants.dart' show BackendConstantEnvironment;
8 import '../constants/constant_system.dart'; 8 import '../constants/constant_system.dart';
9 import '../constants/expressions.dart'; 9 import '../constants/expressions.dart';
10 import '../constants/values.dart' show ConstantValue, PrimitiveConstantValue; 10 import '../constants/values.dart' show ConstantValue, PrimitiveConstantValue;
11 import '../dart_types.dart'; 11 import '../dart_types.dart';
12 import '../dart2jslib.dart'; 12 import '../dart2jslib.dart';
13 import '../elements/elements.dart'; 13 import '../elements/elements.dart';
14 import '../io/source_information.dart'; 14 import '../io/source_information.dart';
15 import '../tree/tree.dart' as ast; 15 import '../tree/tree.dart' as ast;
16 import '../closure.dart' hide ClosureScope; 16 import '../closure.dart' hide ClosureScope;
17 import '../universe/universe.dart' show SelectorKind; 17 import '../universe/universe.dart' show SelectorKind;
18 import 'cps_ir_nodes.dart' as ir; 18 import 'cps_ir_nodes.dart' as ir;
19 import 'cps_ir_builder_task.dart' show DartCapturedVariables, 19 import 'cps_ir_builder_task.dart' show DartCapturedVariables,
20 GlobalProgramInformation; 20 GlobalProgramInformation;
21 21
22 import '../js/js.dart' as js show Template;
23 import '../native/native.dart' show NativeBehavior;
24
22 /// A mapping from variable elements to their compile-time values. 25 /// A mapping from variable elements to their compile-time values.
23 /// 26 ///
24 /// Map elements denoted by parameters and local variables to the 27 /// Map elements denoted by parameters and local variables to the
25 /// [ir.Primitive] that is their value. Parameters and locals are 28 /// [ir.Primitive] that is their value. Parameters and locals are
26 /// assigned indexes which can be used to refer to them. 29 /// assigned indexes which can be used to refer to them.
27 class Environment { 30 class Environment {
28 /// A map from locals to their environment index. 31 /// A map from locals to their environment index.
29 final Map<Local, int> variable2index; 32 final Map<Local, int> variable2index;
30 33
31 /// A reverse map from environment indexes to the variable. 34 /// A reverse map from environment indexes to the variable.
(...skipping 2351 matching lines...) Expand 10 before | Expand all | Expand 10 after
2383 ir.Primitive buildReifyTypeVariable(TypeVariableType variable) { 2386 ir.Primitive buildReifyTypeVariable(TypeVariableType variable) {
2384 ir.Primitive typeArgument = buildTypeVariableAccess(variable); 2387 ir.Primitive typeArgument = buildTypeVariableAccess(variable);
2385 return addPrimitive(new ir.ReifyRuntimeType(typeArgument)); 2388 return addPrimitive(new ir.ReifyRuntimeType(typeArgument));
2386 } 2389 }
2387 2390
2388 ir.Primitive buildInvocationMirror(Selector selector, 2391 ir.Primitive buildInvocationMirror(Selector selector,
2389 List<ir.Primitive> arguments) { 2392 List<ir.Primitive> arguments) {
2390 return addPrimitive(new ir.CreateInvocationMirror(selector, arguments)); 2393 return addPrimitive(new ir.CreateInvocationMirror(selector, arguments));
2391 } 2394 }
2392 2395
2396 ir.Primitive buildForeignCode(js.Template codeTemplate,
2397 List<ir.Primitive> arguments,
2398 NativeBehavior behavior,
2399 {Element dependency}) {
2400 return _continueWithExpression((k) => new ir.ForeignCode(
2401 codeTemplate,
2402 program.getTypeMaskForForeign(behavior),
2403 arguments,
2404 k,
2405 behavior,
2406 dependency: dependency));
2407 }
2408
2393 @override 2409 @override
2394 ir.Primitive buildTypeOperator(ir.Primitive value, 2410 ir.Primitive buildTypeOperator(ir.Primitive value,
2395 DartType type, 2411 DartType type,
2396 {bool isTypeTest}) { 2412 {bool isTypeTest}) {
2397 assert(isOpen); 2413 assert(isOpen);
2398 assert(isTypeTest != null); 2414 assert(isTypeTest != null);
2399 2415
2400 if (type.isMalformed) { 2416 if (type.isMalformed) {
2401 FunctionElement helper = program.throwTypeErrorHelper; 2417 FunctionElement helper = program.throwTypeErrorHelper;
2402 ErroneousElement element = type.element; 2418 ErroneousElement element = type.element;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
2519 final DartType type; 2535 final DartType type;
2520 final LocalVariableElement exceptionVariable; 2536 final LocalVariableElement exceptionVariable;
2521 final LocalVariableElement stackTraceVariable; 2537 final LocalVariableElement stackTraceVariable;
2522 final SubbuildFunction buildCatchBlock; 2538 final SubbuildFunction buildCatchBlock;
2523 2539
2524 CatchClauseInfo({this.type, 2540 CatchClauseInfo({this.type,
2525 this.exceptionVariable, 2541 this.exceptionVariable,
2526 this.stackTraceVariable, 2542 this.stackTraceVariable,
2527 this.buildCatchBlock}); 2543 this.buildCatchBlock});
2528 } 2544 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698