Chromium Code Reviews| Index: pkg/compiler/lib/src/native/behavior.dart |
| diff --git a/pkg/compiler/lib/src/native/behavior.dart b/pkg/compiler/lib/src/native/behavior.dart |
| index 5cd5c604a5781d66908c40a3325f1adccba1e586..fd3eee3825bf21d4a08d42558406c4800fea4b99 100644 |
| --- a/pkg/compiler/lib/src/native/behavior.dart |
| +++ b/pkg/compiler/lib/src/native/behavior.dart |
| @@ -214,30 +214,36 @@ class NativeBehavior { |
| return behavior; |
| } |
| - static NativeBehavior ofJsEmbeddedGlobalCall(Send jsGlobalCall, |
| - Compiler compiler, |
| - resolver) { |
| + static NativeBehavior _ofMacroOrEmbeddedGlobal(Send jsMacroOrGlobalCall, |
| + Compiler compiler, |
| + ResolverVisitor resolver, |
| + {bool isMacro}) { |
| // The first argument of a JS-embedded global call is a string encoding |
| // the type of the code. |
| // |
| // 'Type1|Type2'. A union type. |
| // '=Object'. A JavaScript Object, no subtype. |
| - Link<Node> argNodes = jsGlobalCall.arguments; |
| + String macroOrGlobal = isMacro ? "macro" : "embedded global"; |
| + |
| + Link<Node> argNodes = jsMacroOrGlobalCall.arguments; |
| if (argNodes.isEmpty) { |
| - compiler.internalError(jsGlobalCall, |
| - "JS embedded global expression has no type."); |
| + compiler.internalError(jsMacroOrGlobalCall, |
| + "JS $macroOrGlobal expression has no type."); |
| } |
| // We don't check the given name. That needs to be done at a later point. |
|
herhut
2015/02/26 08:50:28
For macros, the name has to be a literal. Otherwis
floitsch
2015/03/18 17:43:01
We are switching to enums and shared string-litera
|
| // This is, because we want to allow non-literals as names. |
| if (argNodes.tail.isEmpty) { |
| - compiler.internalError(jsGlobalCall, 'Embedded Global is missing name'); |
| + compiler.internalError(jsMacroOrGlobalCall, |
| + 'JS $macroOrGlobal is missing name'); |
| } |
| - if (!argNodes.tail.tail.isEmpty) { |
| - compiler.internalError(argNodes.tail.tail.head, |
| - 'Embedded Global has more than 2 arguments'); |
| + if (!isMacro) { |
| + if (!argNodes.tail.tail.isEmpty) { |
| + compiler.internalError(argNodes.tail.tail.head, |
| + 'JS embedded global has more than 2 arguments'); |
| + } |
| } |
| LiteralString specLiteral = argNodes.head.asLiteralString(); |
| @@ -256,10 +262,10 @@ class NativeBehavior { |
| typeString, |
| compiler, |
| (name) => resolver.resolveTypeFromString(specLiteral, name), |
| - jsGlobalCall); |
| + jsMacroOrGlobalCall); |
| } |
| - processSpecString(compiler, jsGlobalCall, |
| + processSpecString(compiler, jsMacroOrGlobalCall, |
| specString, |
| resolveType: resolveType, |
| typesReturned: behavior.typesReturned, |
| @@ -270,6 +276,20 @@ class NativeBehavior { |
| return behavior; |
| } |
| + static NativeBehavior ofJsCompilerMacroCall(Send jsMacroCall, |
| + Compiler compiler, |
| + ResolverVisitor resolver) { |
| + return _ofMacroOrEmbeddedGlobal( |
| + jsMacroCall, compiler, resolver, isMacro: true); |
| + } |
| + |
| + static NativeBehavior ofJsEmbeddedGlobalCall(Send jsGlobalCall, |
| + Compiler compiler, |
| + ResolverVisitor resolver) { |
| + return _ofMacroOrEmbeddedGlobal( |
| + jsGlobalCall, compiler, resolver, isMacro: false); |
| + } |
| + |
| static NativeBehavior ofMethod(FunctionElement method, Compiler compiler) { |
| FunctionType type = method.computeType(compiler); |
| var behavior = new NativeBehavior(); |