Differences From Artifact [70a85e9a66eddacd]:
- File
polemy/layer.d
- 2010-11-24 11:20:42 - part of checkin [153a14cec0] on branch trunk - if-then-else without {}s. some cosmetic changes (user: kinaba) [annotate]
To Artifact [e37c83f645af4d82]:
- File
polemy/layer.d
- 2010-11-26 05:03:10 - part of checkin [207cea338a] on branch trunk - changed hiding mechanizem of x in let x = ... for @macro layer. Old: set(x,ValueLayer,undefined) Nee: set(x,NoopLayer,null) (user: kinaba) [annotate]
9 9
10 10 /// Type for the layer ID
11 11
12 12 alias string Layer;
13 13
14 14 enum : Layer
15 15 {
16 - SystemLayer = "(system)", /// Predefined layer for internal data
16 + LiftLayer = "(lift)", /// Predefined layer for storing lift functions
17 + NoopLayer = "(noop)", /// Predefined layer for just allocating a slot for table
17 18 ValueLayer = "@value", /// Predefined layer for normal run
18 19 MacroLayer = "@macro", /// Predefined layer for macro run (@lay() changes layer)
19 20 RawMacroLayer = "(rawmacro)", /// Predefined layer for macro run (@lay() becomes AST)
20 21 }
21 22
22 23 /// True if it is a user-defined layer
23 24
24 25 bool isUserDefinedLayer( Layer lay )
25 26 {
26 - return lay!=SystemLayer && lay!=ValueLayer && lay!=MacroLayer && lay!=RawMacroLayer;
27 + return lay!=NoopLayer && lay!=LiftLayer && lay!=ValueLayer && lay!=MacroLayer && lay!=RawMacroLayer;
27 28 }
28 29
29 30 unittest
30 31 {
31 - assert( !isUserDefinedLayer(SystemLayer) );
32 + assert( !isUserDefinedLayer(NoopLayer) );
33 + assert( !isUserDefinedLayer(LiftLayer) );
32 34 assert( !isUserDefinedLayer(ValueLayer) );
33 35 assert( !isUserDefinedLayer(MacroLayer) );
34 36 assert( !isUserDefinedLayer(RawMacroLayer) );
35 37 assert( isUserDefinedLayer("@foo") );
36 38 }
37 39
38 40 /// True if it is macro-like layer that basically generates syntax tree
................................................................................
40 42 bool isASTLayer( Layer lay )
41 43 {
42 44 return lay==MacroLayer || lay==RawMacroLayer;
43 45 }
44 46
45 47 unittest
46 48 {
47 - assert( !isASTLayer(SystemLayer) );
49 + assert( !isASTLayer(NoopLayer) );
50 + assert( !isASTLayer(LiftLayer) );
48 51 assert( !isASTLayer(ValueLayer) );
49 52 assert( isASTLayer(MacroLayer) );
50 53 assert( isASTLayer(RawMacroLayer) );
51 54 }
52 55
53 56 /// True if in the specified layer @lay(...) has no effect and merely produces a syntax tree
54 57
................................................................................
55 58 bool isNoLayerChangeLayer( Layer lay )
56 59 {
57 60 return lay==RawMacroLayer;
58 61 }
59 62
60 63 unittest
61 64 {
62 - assert( !isNoLayerChangeLayer(SystemLayer) );
65 + assert( !isNoLayerChangeLayer(NoopLayer) );
66 + assert( !isNoLayerChangeLayer(LiftLayer) );
63 67 assert( !isNoLayerChangeLayer(ValueLayer) );
64 68 assert( !isNoLayerChangeLayer(MacroLayer) );
65 69 assert( isNoLayerChangeLayer(RawMacroLayer) );
66 70 }
67 71
68 72 /// True if do macro expanstion
69 73
................................................................................
70 74 bool isMacroLayer( Layer lay )
71 75 {
72 76 return lay==MacroLayer || lay==RawMacroLayer;
73 77 }
74 78
75 79 unittest
76 80 {
77 - assert( !isMacroLayer(SystemLayer) );
81 + assert( !isMacroLayer(NoopLayer) );
82 + assert( !isMacroLayer(LiftLayer) );
78 83 assert( !isMacroLayer(ValueLayer) );
79 84 assert( isMacroLayer(MacroLayer) );
80 85 assert( isMacroLayer(RawMacroLayer) );
81 86 }