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

Unified Diff: sky/specs/script.md

Issue 946513006: Specs: pass the current <script> to the module library init() (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 | « sky/specs/modules.md ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/specs/script.md
diff --git a/sky/specs/script.md b/sky/specs/script.md
index 857f2c00f1ca6d5571e557aa027bc6bf6b85df12..4004283159ed787187667169ebb5eb24d20e19f2 100644
--- a/sky/specs/script.md
+++ b/sky/specs/script.md
@@ -26,9 +26,9 @@ import 'dart:mirrors';
abstract class AutomaticMetadata {
const AutomaticMetadata();
- void init(DeclarationMirror target, Module module);
+ void init(DeclarationMirror target, Module module, ScriptElement script);
- static void runLibrary(LibraryMirror library, Module module) {
+ static void runLibrary(LibraryMirror library, Module module, ScriptElement script) {
library.declarations.values.toList() /* ..sort((DeclarationMirror a, DeclarationMirror b) {
bool aHasLocation;
try {
@@ -55,7 +55,7 @@ abstract class AutomaticMetadata {
..forEach((DeclarationMirror d) {
d.metadata.forEach((InstanceMirror i) {
if (i.reflectee is AutomaticMetadata)
- i.reflectee.run(d, module);
+ i.reflectee.run(d, module, script);
});
});
}
@@ -63,16 +63,17 @@ abstract class AutomaticMetadata {
class AutomaticFunction extends AutomaticMetadata {
const AutomaticFunction();
- void init(DeclarationMirror target, Module module) {
+ void init(DeclarationMirror target, Module module, ScriptElement script) {
assert(target is MethodMirror);
MethodMirror f = target as MethodMirror;
assert(!f.isAbstract);
assert(f.isRegularMethod);
assert(f.isTopLevel);
assert(f.isStatic);
- assert(f.parameters.length == 0);
+ assert(f.parameters.length == 1);
+ assert(f.parameters[0].type == ScriptElement);
assert(f.returnType == currentMirrorSystem().voidType);
- (f.owner as LibraryMirror).invoke(f.simpleName, []);
+ (f.owner as LibraryMirror).invoke(f.simpleName, [script]);
}
}
const autorun = const AutomaticFunction();
« no previous file with comments | « sky/specs/modules.md ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698