Index: lib/compiler/implementation/compile_time_constants.dart |
=================================================================== |
--- lib/compiler/implementation/compile_time_constants.dart (revision 11378) |
+++ lib/compiler/implementation/compile_time_constants.dart (working copy) |
@@ -16,6 +16,7 @@ |
bool isList() => false; |
bool isMap() => false; |
bool isConstructedObject() => false; |
+ bool isFunction() => false; |
/** Returns true if the constant is null, a bool, a number or a string. */ |
bool isPrimitive() => false; |
/** Returns true if the constant is a list, a map or a constructed object. */ |
@@ -33,6 +34,31 @@ |
abstract List<Constant> getDependencies(); |
} |
+class FunctionConstant extends Constant{ |
kasperl
2012/08/27 13:17:26
Space between Constant and {.
ngeoffray
2012/08/27 14:09:09
Done.
|
+ Element element; |
+ |
+ FunctionConstant(this.element); |
+ |
+ bool isFunction() => true; |
+ |
+ bool operator ==(var other) { |
+ if (other is !FunctionConstant) return false; |
+ return other.element === element; |
+ } |
+ |
+ String toString() => element.toString(); |
+ List<Constant> getDependencies() => const <Constant>[]; |
+ DartString toDartString() { |
+ return new DartString.literal(element.name.slowToString()); |
+ } |
+ |
+ void _writeCanonicalizedJsCode(CodeBuffer buffer, ConstantHandler handler) { |
kasperl
2012/08/27 13:17:26
Don't you need to also provide an implementation o
ngeoffray
2012/08/27 14:09:09
Yes, but it will never be called because there's n
|
+ buffer.add(handler.compiler.namer.isolatePropertiesAccess(element)); |
+ } |
+ |
+ int hashCode() => element.hashCode(); |
+} |
+ |
class PrimitiveConstant extends Constant { |
abstract get value; |
const PrimitiveConstant(); |
@@ -844,6 +870,10 @@ |
error(send); |
} |
return compiler.compileVariable(element); |
+ } else if (Elements.isStaticOrTopLevelFunction(element) |
+ && send.isPropertyAccess) { |
+ compiler.codegenWorld.staticFunctionsNeedingGetter.add(element); |
kasperl
2012/08/27 13:17:26
Could this registration happen later in the codege
ngeoffray
2012/08/27 14:09:09
It has to be done here, the codegen only handles u
|
+ return new FunctionConstant(element); |
} else if (send.isPrefix) { |
assert(send.isOperator); |
Constant receiverConstant = evaluate(send.receiver); |