|
23 | 23 | * DAMAGE. |
24 | 24 | */ |
25 | 25 | package hscript; |
| 26 | +import haxe.PosInfos; |
26 | 27 | import hscript.Expr; |
27 | 28 |
|
28 | 29 | private enum Stop { |
@@ -63,10 +64,18 @@ class Interp { |
63 | 64 | variables.set("null",null); |
64 | 65 | variables.set("true",true); |
65 | 66 | variables.set("false",false); |
66 | | - variables.set("trace",function(e) haxe.Log.trace(Std.string(e),cast { fileName : "hscript", lineNumber : 0 })); |
| 67 | + variables.set("trace",function(e) haxe.Log.trace(Std.string(e), posInfos())); |
67 | 68 | initOps(); |
68 | 69 | } |
69 | 70 |
|
| 71 | + public function posInfos(): PosInfos { |
| 72 | + #if hscriptPos |
| 73 | + if (curExpr != null) |
| 74 | + return cast { fileName : curExpr.origin, lineNumber : curExpr.line }; |
| 75 | + #end |
| 76 | + return cast { fileName : "hscript", lineNumber : 0 }; |
| 77 | + } |
| 78 | + |
70 | 79 | function initOps() { |
71 | 80 | var me = this; |
72 | 81 | #if haxe3 |
@@ -275,7 +284,7 @@ class Interp { |
275 | 284 |
|
276 | 285 | inline function error(e : #if hscriptPos ErrorDef #else Error #end ) : Dynamic { |
277 | 286 | #if hscriptPos |
278 | | - throw new Error(e, curExpr.pmin, curExpr.pmax); |
| 287 | + throw new Error(e, curExpr.pmin, curExpr.pmax, curExpr.origin, curExpr.line); |
279 | 288 | #else |
280 | 289 | throw e; |
281 | 290 | #end |
@@ -447,16 +456,16 @@ class Interp { |
447 | 456 | } |
448 | 457 | return f; |
449 | 458 | case EArrayDecl(arr): |
450 | | - if (arr.length > 0 && arr[0].match(Expr.EBinop("=>", _))) { |
| 459 | + if (arr.length > 0 && edef(arr[0]).match(EBinop("=>", _))) { |
451 | 460 | var isAllString:Bool = true; |
452 | 461 | var isAllInt:Bool = true; |
453 | 462 | var isAllObject:Bool = true; |
454 | 463 | var isAllEnum:Bool = true; |
455 | 464 | var keys:Array<Dynamic> = []; |
456 | 465 | var values:Array<Dynamic> = []; |
457 | 466 | for (e in arr) { |
458 | | - switch(e) { |
459 | | - case Expr.EBinop("=>", eKey, eValue): { |
| 467 | + switch(edef(e)) { |
| 468 | + case EBinop("=>", eKey, eValue): { |
460 | 469 | var key:Dynamic = expr(eKey); |
461 | 470 | var value:Dynamic = expr(eValue); |
462 | 471 | isAllString = isAllString && Std.is(key, String); |
|
0 commit comments