Diff
Not logged in

Differences From Artifact [01c119756ed23ca5]:

To Artifact [fe3f0c39a200a0bc]:


41 41 { 42 42 Value delegate(immutable LexPosition pos, string lay, Value[]) data; 43 43 44 44 mixin SimpleConstructor; 45 45 alias data call; 46 46 override string toString() const { return sprintf!"(function:%s:%s)"(data.ptr,data.funcptr); } 47 47 } 48 + 49 +class UndValue : Value 50 +{ 51 + mixin SimpleClass; 52 + override string toString() const { return "<undefined>"; } 53 +} 48 54 49 55 /// Layer ID 50 56 51 57 alias string Layer; 52 58 53 59 /// Context (variable environment) 54 60 /// Simlar to prototype chain of ECMAScript etc. ................................................................................ 66 72 if( setIfExist(i, lay, v) ) 67 73 return; 68 74 data[i][lay] = v; 69 75 } 70 76 71 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!"variable %s is not set in layer %s"(i,lay)); 74 82 return data[i][lay]; 83 + } 75 84 if( prototype is null ) 76 85 throw new RuntimeException(pos, sprintf!"variable %s not found"(i)); 77 - return prototype.get(i, lay); 86 + return prototype.get(i, lay, pos); 78 87 } 79 88 80 89 private: 81 90 Table prototype; 82 91 Kind kind; 83 92 Value[Layer][string] data; 84 93