Differences From Artifact [bca45e855c0f4664]:
- File
polemy/valueconv.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 [cd634c9bb4b6ba14]:
- File
polemy/valueconv.d
- 2010-11-24 13:22:04 - part of checkin [f9c31f3cd8] on branch trunk - Fixed the null dereference bug when directly wrote "case 1 when 2: 3" in REPL. It was due to null LexPosition in the AST. Now AST.pos !is null is an invariant of AST. (user: kinaba) [annotate]
18 18 {
19 19 auto fn = tt.access!StrValue(ValueLayer, "filename");
20 20 auto ln = tt.access!IntValue(ValueLayer, "lineno");
21 21 auto cl = tt.access!IntValue(ValueLayer, "column");
22 22 if(fn !is null && ln !is null && cl !is null)
23 23 return new LexPosition(fn.data,cast(int)ln.data.toInt,cast(int)cl.data.toInt);
24 24 }
25 - return null;
25 + return LexPosition.dummy;
26 26 }
27 27
28 28 /// Experimental!! Convert Polemy value to D Value
29 29
30 30 T polemy2d(T)(Value _v, LexPosition callpos=null)
31 31 {
32 32 static if(is(T==BigInt))
................................................................................
141 141 return lst;
142 142 }
143 143 else
144 144 static if(is(T : AST))
145 145 {
146 146 assert( typeid(e) == typeid(T), text("abstracted: ", typeid(e), " vs ", typeid(T)) );
147 147 auto t = new Table;
148 - t.set("pos", ValueLayer, ast2table(e.pos,rec));
148 + if(e.pos is null) // special treatment
149 + {
150 + Table post = new Table;
151 + post.set("filename", ValueLayer, new StrValue("nullpo"));
152 + post.set("lineno", ValueLayer, new IntValue(0));
153 + post.set("column", ValueLayer, new IntValue(0));
154 + t.set("pos", ValueLayer, post);
155 + }
156 + else
157 + t.set("pos", ValueLayer, ast2table(e.pos,rec));
149 158 t.set("is" , ValueLayer, new StrValue(typeid(e).name.split(".")[$-1]));
150 159 foreach(i,m; e.tupleof)
151 160 static if(is(typeof(m) : AST))
152 161 t.set(e.tupleof[i].stringof.split(".")[$-1], ValueLayer, rec(m));
153 162 else
154 163 t.set(e.tupleof[i].stringof.split(".")[$-1], ValueLayer, ast2table(m,rec));
155 164 return t;