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 auto fn = tt.access!StrValue(ValueLayer, "filename"); 19 auto fn = tt.access!StrValue(ValueLayer, "filename");
20 auto ln = tt.access!IntValue(ValueLayer, "lineno"); 20 auto ln = tt.access!IntValue(ValueLayer, "lineno");
21 auto cl = tt.access!IntValue(ValueLayer, "column"); 21 auto cl = tt.access!IntValue(ValueLayer, "column");
22 if(fn !is null && ln !is null && cl !is null) 22 if(fn !is null && ln !is null && cl !is null)
23 return new LexPosition(fn.data,cast(int)ln.data.toInt,ca 23 return new LexPosition(fn.data,cast(int)ln.data.toInt,ca
24 } 24 }
25 return null; | 25 return LexPosition.dummy;
26 } 26 }
27 27
28 /// Experimental!! Convert Polemy value to D Value 28 /// Experimental!! Convert Polemy value to D Value
29 29
30 T polemy2d(T)(Value _v, LexPosition callpos=null) 30 T polemy2d(T)(Value _v, LexPosition callpos=null)
31 { 31 {
32 static if(is(T==BigInt)) 32 static if(is(T==BigInt))
................................................................................................................................................................................
141 return lst; 141 return lst;
142 } 142 }
143 else 143 else
144 static if(is(T : AST)) 144 static if(is(T : AST))
145 { 145 {
146 assert( typeid(e) == typeid(T), text("abstracted: ", typeid(e), 146 assert( typeid(e) == typeid(T), text("abstracted: ", typeid(e),
147 auto t = new Table; 147 auto t = new Table;
> 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
148 t.set("pos", ValueLayer, ast2table(e.pos,rec)); | 157 t.set("pos", ValueLayer, ast2table(e.pos,rec));
149 t.set("is" , ValueLayer, new StrValue(typeid(e).name.split(".")[ 158 t.set("is" , ValueLayer, new StrValue(typeid(e).name.split(".")[
150 foreach(i,m; e.tupleof) 159 foreach(i,m; e.tupleof)
151 static if(is(typeof(m) : AST)) 160 static if(is(typeof(m) : AST))
152 t.set(e.tupleof[i].stringof.split(".")[$-1], Val 161 t.set(e.tupleof[i].stringof.split(".")[$-1], Val
153 else 162 else
154 t.set(e.tupleof[i].stringof.split(".")[$-1], Val 163 t.set(e.tupleof[i].stringof.split(".")[$-1], Val
155 return t; 164 return t;