Differences From Artifact [01c119756ed23ca5]:
- File
polemy/value.d
- 2010-11-09 14:59:36 - part of checkin [7465fcdd7f] on branch trunk - layered function invocation (user: kinaba) [annotate]
To Artifact [fe3f0c39a200a0bc]:
- File
polemy/value.d
- 2010-11-13 12:16:47 - part of checkin [5afe8e3f26] on branch trunk - Memoization on non "@v" layer. Now simplest metalevel computation works!! Also, added -l option. (user: kinaba) [annotate]
41 { 41 {
42 Value delegate(immutable LexPosition pos, string lay, Value[]) data; 42 Value delegate(immutable LexPosition pos, string lay, Value[]) data;
43 43
44 mixin SimpleConstructor; 44 mixin SimpleConstructor;
45 alias data call; 45 alias data call;
46 override string toString() const { return sprintf!"(function:%s:%s)"(dat 46 override string toString() const { return sprintf!"(function:%s:%s)"(dat
47 } 47 }
> 48
> 49 class UndValue : Value
> 50 {
> 51 mixin SimpleClass;
> 52 override string toString() const { return "<undefined>"; }
> 53 }
48 54
49 /// Layer ID 55 /// Layer ID
50 56
51 alias string Layer; 57 alias string Layer;
52 58
53 /// Context (variable environment) 59 /// Context (variable environment)
54 /// Simlar to prototype chain of ECMAScript etc. 60 /// Simlar to prototype chain of ECMAScript etc.
................................................................................................................................................................................
66 if( setIfExist(i, lay, v) ) 72 if( setIfExist(i, lay, v) )
67 return; 73 return;
68 data[i][lay] = v; 74 data[i][lay] = v;
69 } 75 }
70 76
71 Value get(string i, Layer lay, in LexPosition pos=null) 77 Value get(string i, Layer lay, in LexPosition pos=null)
72 { 78 {
73 if( i in data ) | 79 if( i in data ) {
> 80 if( lay !in data[i] )
> 81 throw genex!RuntimeException(pos, sprintf!"varia
74 return data[i][lay]; 82 return data[i][lay];
> 83 }
75 if( prototype is null ) 84 if( prototype is null )
76 throw new RuntimeException(pos, sprintf!"variable %s not 85 throw new RuntimeException(pos, sprintf!"variable %s not
77 return prototype.get(i, lay); | 86 return prototype.get(i, lay, pos);
78 } 87 }
79 88
80 private: 89 private:
81 Table prototype; 90 Table prototype;
82 Kind kind; 91 Kind kind;
83 Value[Layer][string] data; 92 Value[Layer][string] data;
84 93