| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 library rasta.kernel_visitor; | 5 library rasta.kernel_visitor; |
| 6 | 6 |
| 7 import 'package:kernel/ast.dart' as ir; | 7 import 'package:kernel/ast.dart' as ir; |
| 8 | 8 |
| 9 import 'package:kernel/accessors.dart' show | 9 import 'package:kernel/accessors.dart' show |
| 10 Accessor, | 10 Accessor, |
| (...skipping 2713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2724 kernel.functionToIr(thisConstructor), buildArguments(arguments)); | 2724 kernel.functionToIr(thisConstructor), buildArguments(arguments)); |
| 2725 } | 2725 } |
| 2726 } | 2726 } |
| 2727 | 2727 |
| 2728 @override | 2728 @override |
| 2729 ir.ThisExpression visitThisGet(Identifier node, _) { | 2729 ir.ThisExpression visitThisGet(Identifier node, _) { |
| 2730 return new ir.ThisExpression(); | 2730 return new ir.ThisExpression(); |
| 2731 } | 2731 } |
| 2732 | 2732 |
| 2733 @override | 2733 @override |
| 2734 ir.Throw visitThisInvoke( | 2734 ir.MethodInvocation visitThisInvoke( |
| 2735 Send node, | 2735 Send node, |
| 2736 NodeList arguments, | 2736 NodeList arguments, |
| 2737 CallStructure callStructure, | 2737 CallStructure callStructure, |
| 2738 _) { | 2738 _) { |
| 2739 return buildUnsupported(node, "ThisInvoke"); | 2739 return buildCall(new ir.ThisExpression(), callStructure, arguments); |
| 2740 } | 2740 } |
| 2741 | 2741 |
| 2742 Accessor buildThisPropertyAccessor(Name name) { | 2742 Accessor buildThisPropertyAccessor(Name name) { |
| 2743 return new ThisPropertyAccessor(kernel.nameToIrName(name)); | 2743 return new ThisPropertyAccessor(kernel.nameToIrName(name)); |
| 2744 } | 2744 } |
| 2745 | 2745 |
| 2746 @override | 2746 @override |
| 2747 ir.Expression visitThisPropertyGet(Send node, Name name, _) { | 2747 ir.Expression visitThisPropertyGet(Send node, Name name, _) { |
| 2748 return buildThisPropertyAccessor(name).buildSimpleRead(); | 2748 return buildThisPropertyAccessor(name).buildSimpleRead(); |
| 2749 } | 2749 } |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2969 ir.VariableDeclaration variable = | 2969 ir.VariableDeclaration variable = |
| 2970 structure.dispatch(declVisitor, node, null); | 2970 structure.dispatch(declVisitor, node, null); |
| 2971 variables.add(variable); | 2971 variables.add(variable); |
| 2972 return variable; | 2972 return variable; |
| 2973 } | 2973 } |
| 2974 }); | 2974 }); |
| 2975 if (variables.length == 1) return variables.single; | 2975 if (variables.length == 1) return variables.single; |
| 2976 return new VariableDeclarations(variables); | 2976 return new VariableDeclarations(variables); |
| 2977 } | 2977 } |
| 2978 | 2978 |
| 2979 ir.Throw buildUnsupported(Node node, String name) { | |
| 2980 // TODO(ahe): Do this: | |
| 2981 // throw new Unsupported("Kernel IR not yet implemented for '$name'."); | |
| 2982 if (const bool.fromEnvironment("verbose")) { | |
| 2983 print("Kernel IR not yet implemented for '$name'."); | |
| 2984 } | |
| 2985 return new ir.Throw( | |
| 2986 new ir.StringLiteral("Kernel IR not yet implemented for '$name'.")); | |
| 2987 } | |
| 2988 | |
| 2989 IrFunction buildFunction() { | 2979 IrFunction buildFunction() { |
| 2990 return kernel.compiler.reporter.withCurrentElement(currentElement, () { | 2980 return kernel.compiler.reporter.withCurrentElement(currentElement, () { |
| 2991 if (kernel.isSyntheticError(currentElement)) { | 2981 if (kernel.isSyntheticError(currentElement)) { |
| 2992 kernel.internalError( | 2982 kernel.internalError( |
| 2993 currentElement, | 2983 currentElement, |
| 2994 "Can't build synthetic function element: $currentElement"); | 2984 "Can't build synthetic function element: $currentElement"); |
| 2995 } else if (currentElement.isMalformed) { | 2985 } else if (currentElement.isMalformed) { |
| 2996 ir.FunctionNode node = buildFunctionNode(currentElement, null); | 2986 ir.FunctionNode node = buildFunctionNode(currentElement, null); |
| 2997 if (currentElement.isGenerativeConstructor) { | 2987 if (currentElement.isGenerativeConstructor) { |
| 2998 return new IrFunction.constructor( | 2988 return new IrFunction.constructor( |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3055 : this(null, true, node, initializers); | 3045 : this(null, true, node, initializers); |
| 3056 | 3046 |
| 3057 accept(ir.Visitor v) => throw "unsupported"; | 3047 accept(ir.Visitor v) => throw "unsupported"; |
| 3058 | 3048 |
| 3059 visitChildren(ir.Visitor v) => throw "unsupported"; | 3049 visitChildren(ir.Visitor v) => throw "unsupported"; |
| 3060 | 3050 |
| 3061 String toString() { | 3051 String toString() { |
| 3062 return "IrFunction($kind, $isConstructor, $node, $initializers)"; | 3052 return "IrFunction($kind, $isConstructor, $node, $initializers)"; |
| 3063 } | 3053 } |
| 3064 } | 3054 } |
| OLD | NEW |