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

Side by Side Diff: sky/specs/script.md

Issue 908263002: Specs: found a way to make @autorun work (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 unified diff | Download patch
« no previous file with comments | « sky/specs/modules.md ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 Sky Script Language 1 Sky Script Language
2 =================== 2 ===================
3 3
4 The Sky script language is Dart. 4 The Sky script language is Dart.
5 5
6 The way that Sky integrates the module system with its script language 6 The way that Sky integrates the module system with its script language
7 is described in [modules.md](modules.md). 7 is described in [modules.md](modules.md).
8 8
9 When an method defined as ``external`` receives an argument, it must 9 When an method defined as ``external`` receives an argument, it must
10 type-check it, and, if the argument's value is the wrong type, then it 10 type-check it, and, if the argument's value is the wrong type, then it
(...skipping 18 matching lines...) Expand all
29 The ``@nonnull`` annotation does nothing in code not marked 29 The ``@nonnull`` annotation does nothing in code not marked
30 ``external``, but it has been included anyway for documentation 30 ``external``, but it has been included anyway for documentation
31 purposes. It indicates places where providing a null is a contract 31 purposes. It indicates places where providing a null is a contract
32 violation and that results are therefore likely to be poor. 32 violation and that results are therefore likely to be poor.
33 33
34 The following definitions are exposed in ``sky:core``: 34 The following definitions are exposed in ``sky:core``:
35 35
36 ```dart 36 ```dart
37 abstract class AutomaticMetadata { 37 abstract class AutomaticMetadata {
38 const AutomaticMetadata(); 38 const AutomaticMetadata();
39 void init(DeclarationMirror target) { } 39 void init(DeclarationMirror target, Module module);
40
41 static void runLibrary(LibraryMirror library, Module module) {
42 library.declarations.values.toList()..sort((DeclarationMirror a, Declaration Mirror b) {
43 bool aHasLocation;
44 try {
45 aHasLocation = a.location != null;
46 } catch(e) {
47 aHasLocation = false;
48 }
49 bool bHasLocation;
50 try {
51 bHasLocation = b.location != null;
52 } catch(e) {
53 bHasLocation = false;
54 }
55 if (!aHasLocation)
56 return bHasLocation ? 1 : 0;
57 if (!bHasLocation)
58 return -1;
59 if (a.location.sourceUri != b.location.sourceUri)
60 return a.location.sourceUri.toString().compareTo(b.location.sourceUri.to String());
61 if (a.location.line != b.location.line)
62 return a.location.line - b.location.line;
63 return a.location.column - b.location.column;
64 })
65 ..forEach((DeclarationMirror d) {
66 d.metadata.forEach((InstanceMirror i) {
67 if (i.reflectee is AutomaticMetadata)
68 i.reflectee.run(d, module);
69 });
70 });
71 }
40 } 72 }
41 73
42 /*
43 class AutomaticFunction extends AutomaticMetadata { 74 class AutomaticFunction extends AutomaticMetadata {
44 const AutomaticFunction(); 75 const AutomaticFunction();
45 void init(DeclarationMirror target) { 76 void init(DeclarationMirror target, Module module) {
46 assert(target is MethodMirror); 77 assert(target is MethodMirror);
47 MethodMirror f = target as MethodMirror; 78 MethodMirror f = target as MethodMirror;
48 assert(!f.isAbstract); 79 assert(!f.isAbstract);
49 assert(f.isRegularMethod); 80 assert(f.isRegularMethod);
50 assert(f.isTopLevel); 81 assert(f.isTopLevel);
51 assert(f.isStatic); 82 assert(f.isStatic);
52 assert(f.parameters.length == 0); 83 assert(f.parameters.length == 0);
53 assert(f.returnType == currentMirrorSystem().voidType); 84 assert(f.returnType == currentMirrorSystem().voidType);
54 (f.owner as LibraryMirror).invoke(f.simpleName, []); 85 (f.owner as LibraryMirror).invoke(f.simpleName, []);
55 } 86 }
56 } 87 }
57 const autorun = const AutomaticFunction(); 88 const autorun = const AutomaticFunction();
58 */
59 ``` 89 ```
60 90
61 Extensions 91 Extensions
62 ---------- 92 ----------
63 93
64 The following as-yet unimplemented features of the Dart language are 94 The following as-yet unimplemented features of the Dart language are
65 assumed to exist: 95 assumed to exist:
66 96
67 * It is assumed that a subclass can define a constructor by reference 97 * It is assumed that a subclass can define a constructor by reference
68 to a superclass' constructor, wherein the subclass' constructor has 98 to a superclass' constructor, wherein the subclass' constructor has
(...skipping 29 matching lines...) Expand all
98 List<T> _exceptions; 128 List<T> _exceptions;
99 void add(T exception) { 129 void add(T exception) {
100 if (_exceptions == null) 130 if (_exceptions == null)
101 _exceptions = new List<T>(); 131 _exceptions = new List<T>();
102 _exceptions.add(exception); 132 _exceptions.add(exception);
103 } 133 }
104 int get length => _exceptions == null ? 0 : _exceptions.length; 134 int get length => _exceptions == null ? 0 : _exceptions.length;
105 Iterator<T> iterator() => _exceptions.iterator(); 135 Iterator<T> iterator() => _exceptions.iterator();
106 } 136 }
107 ``` 137 ```
OLDNEW
« 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