Browse Source

Added column to StackItem.FilePos (#662) (#6665)

* added column to StackItem.FilePos (#662)

* Changed column type to `Null<Int>`

* Changed column type for php

* support column pos on eval

* made column optional in StackItem.FilePos
Alexander Kuzmenko 8 years ago
parent
commit
ea5f8ed0d4
3 changed files with 14 additions and 9 deletions
  1. 2 2
      src/macro/eval/evalStdLib.ml
  2. 9 4
      std/haxe/CallStack.hx
  3. 3 3
      std/php/_std/haxe/CallStack.hx

+ 2 - 2
src/macro/eval/evalStdLib.ml

@@ -561,8 +561,8 @@ module StdCallStack = struct
 		let l = DynArray.create () in
 		List.iter (fun (pos,kind) ->
 			let file_pos s =
-				let line = Lexer.get_error_line pos in
-				encode_enum_value key_haxe_StackItem 2 [|s;encode_string pos.pfile;vint line|] None
+				let line1,col1,_,_ = Lexer.get_pos_coords pos in
+				encode_enum_value key_haxe_StackItem 2 [|s;encode_string pos.pfile;vint line1;vint col1|] None
 			in
 			match kind with
 			| EKLocalFunction i ->

+ 9 - 4
std/haxe/CallStack.hx

@@ -27,7 +27,7 @@ package haxe;
 enum StackItem {
 	CFunction;
 	Module( m : String );
-	FilePos( s : Null<StackItem>, file : String, line : Int );
+	FilePos( s : Null<StackItem>, file : String, line : Int, ?column : Null<Int> );
 	Method( classname : String, method : String );
 	LocalFunction( ?v : Int );
 }
@@ -57,7 +57,7 @@ class CallStack {
 						method = Method(className, methodName);
 					}
 				}
-				stack.push(FilePos(method, site.getFileName(), site.getLineNumber()));
+				stack.push(FilePos(method, site.getFileName(), site.getLineNumber(), site.getColumnNumber()));
 			}
 			return stack;
 		}
@@ -246,7 +246,7 @@ class CallStack {
 		case Module(m):
 			b.add("module ");
 			b.add(m);
-		case FilePos(s,file,line):
+		case FilePos(s,file,line,col):
 			if( s != null ) {
 				itemToString(b,s);
 				b.add(" (");
@@ -254,6 +254,10 @@ class CallStack {
 			b.add(file);
 			b.add(" line ");
 			b.add(line);
+			if(col != null) {
+				b.add(" column ");
+				b.add(col);
+			}
 			if( s != null ) b.add(")");
 		case Method(cname,meth):
 			b.add(cname);
@@ -330,7 +334,8 @@ class CallStack {
 						var meth = path.pop();
 						var file = rie10.matched(2);
 						var line = Std.parseInt(rie10.matched(3));
-						m.push(FilePos( meth == "Anonymous function" ? LocalFunction() : meth == "Global code" ? null : Method(path.join("."),meth), file, line ));
+						var column = Std.parseInt(rie10.matched(4));
+						m.push(FilePos( meth == "Anonymous function" ? LocalFunction() : meth == "Global code" ? null : Method(path.join("."),meth), file, line, column ));
 					} else
 						m.push(Module(StringTools.trim(line))); // A little weird, but better than nothing
 				}

+ 3 - 3
std/php/_std/haxe/CallStack.hx

@@ -10,7 +10,7 @@ private typedef NativeTrace = NativeIndexedArray<NativeAssocArray<Dynamic>>;
 enum StackItem {
 	CFunction;
 	Module( m : String );
-	FilePos( s : Null<StackItem>, file : String, line : Int );
+	FilePos( s : Null<StackItem>, file : String, line : Int, ?column : Null<Int> );
 	Method( classname : String, method : String );
 	LocalFunction( ?v : Int );
 }
@@ -61,7 +61,7 @@ class CallStack {
 			case Module(m):
 				b.add("module ");
 				b.add(m);
-			case FilePos(s,file,line):
+			case FilePos(s,file,line,_):
 				if( s != null ) {
 					itemToString(b,s);
 					b.add(" (");
@@ -152,4 +152,4 @@ class CallStack {
 		return result;
 	}
 
-}
+}