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

Unified Diff: pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart

Issue 2938193003: Revert "Towards compiling Hello World!" and "Compile and run Hello World!" (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder_kernel.dart ('k') | pkg/compiler/lib/src/ssa/optimize.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart
diff --git a/pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart b/pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart
index 095473111da3e46b1ac898d69c8bdefc30223e6c..aac72e4c6a36765689035ee2202ca3f89edf8ee0 100644
--- a/pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart
+++ b/pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:js_runtime/shared/embedded_names.dart';
import 'package:kernel/ast.dart' as ir;
import '../closure.dart';
@@ -16,6 +17,7 @@ import '../elements/jumps.dart';
import '../elements/modelx.dart';
import '../elements/resolution_types.dart';
import '../elements/types.dart';
+import '../js/js.dart' as js;
import '../js_backend/js_backend.dart';
import '../kernel/element_map.dart';
import '../kernel/kernel.dart';
@@ -239,6 +241,35 @@ class KernelAstAdapter extends KernelToElementMapMixin
});
}
+ js.Name getNameForJsGetName(ir.Node argument, ConstantValue constant) {
+ int index = _extractEnumIndexFromConstantValue(
+ constant, _compiler.resolution.commonElements.jsGetNameEnum);
+ if (index == null) return null;
+ return _backend.namer
+ .getNameForJsGetName(getNode(argument), JsGetName.values[index]);
+ }
+
+ js.Template getJsBuiltinTemplate(ConstantValue constant) {
+ int index = _extractEnumIndexFromConstantValue(
+ constant, _compiler.resolution.commonElements.jsBuiltinEnum);
+ if (index == null) return null;
+ return _backend.emitter.builtinTemplateFor(JsBuiltin.values[index]);
+ }
+
+ int _extractEnumIndexFromConstantValue(
+ ConstantValue constant, ClassEntity classElement) {
+ if (constant is ConstructedConstantValue) {
+ if (constant.type.element == classElement) {
+ assert(constant.fields.length == 1 || constant.fields.length == 2);
+ ConstantValue indexConstant = constant.fields.values.first;
+ if (indexConstant is IntConstantValue) {
+ return indexConstant.primitiveValue;
+ }
+ }
+ }
+ return null;
+ }
+
DartType getDartType(ir.DartType type) {
return _typeConverter.convert(type);
}
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder_kernel.dart ('k') | pkg/compiler/lib/src/ssa/optimize.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698