Diff
Not logged in

Differences From Artifact [c94ffd3733368117]:

To Artifact [eb7f695558db6c0f]:


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