Diff
Not logged in

Differences From Artifact [c94ffd3733368117]:

To Artifact [eb7f695558db6c0f]:


2 * Authors: k.inaba 2 * Authors: k.inaba 3 * License: NYSL 0.9982 http://www.kmonos.net/nysl/ 3 * License: NYSL 0.9982 http://www.kmonos.net/nysl/ 4 * 4 * 5 * Runtime data structures for Polemy programming language. 5 * Runtime data structures for Polemy programming language. 6 */ 6 */ 7 module polemy.runtime; 7 module polemy.runtime; 8 import polemy._common; 8 import polemy._common; > 9 import polemy.lex : LexPosition; > 10 import std.stdio; 9 11 10 class PolemyRuntimeException : Exception 12 class PolemyRuntimeException : Exception 11 { 13 { 12 this(string msg) { super(msg); } 14 this(string msg) { super(msg); } 13 } 15 } 14 16 15 abstract class Value 17 abstract class Value 16 { 18 { 17 } 19 } > 20 > 21 class UndefinedValue : Value > 22 { > 23 mixin SimpleConstructor; > 24 mixin SimpleCompare; > 25 } 18 26 19 class IntValue : Value 27 class IntValue : Value 20 { 28 { 21 BigInt data; 29 BigInt data; 22 mixin SimpleConstructor; 30 mixin SimpleConstructor; 23 mixin SimpleCompare; 31 mixin SimpleCompare; 24 } 32 } ................................................................................................................................................................................ 26 class StrValue : Value 34 class StrValue : Value 27 { 35 { 28 string data; 36 string data; 29 mixin SimpleConstructor; 37 mixin SimpleConstructor; 30 mixin SimpleCompare; 38 mixin SimpleCompare; 31 } 39 } 32 40 33 abstract class FunValue : Value | 41 class FunValue : Value 34 { 42 { 35 Value call(Value[] args); | 43 Value delegate(immutable LexPosition pos, Value[]) data; > 44 mixin SimpleConstructor; > 45 Value call(immutable LexPosition pos, Value[] args) { return data(pos,ar 36 } 46 } 37 < 38 class PrimitiveFunction : FunValue < 39 { < 40 Value delegate(Value[]) data; < 41 mixin SimpleConstructor; < 42 override Value call(Value[] args) { return data(args); } < 43 } < 44 < > 47 import std.stdio; 45 class Context 48 class Context 46 { 49 { 47 Context parent; 50 Context parent; 48 Value[string] table; 51 Value[string] table; 49 this(Context parent = null) { this.parent = parent; } 52 this(Context parent = null) { this.parent = parent; } 50 53 51 void add(string i, Value v) 54 void add(string i, Value v)