Browse Source

extend -D absolute_path option

Now arbitrary traces (such as exceptions, invalid calls) show
absolute paths when running neko and that option has
been used when compiling.

Also fix typo
Marc Weber 12 years ago
parent
commit
a396bc108a
2 changed files with 18 additions and 13 deletions
  1. 1 1
      common.ml
  2. 17 12
      genneko.ml

+ 1 - 1
common.ml

@@ -205,7 +205,7 @@ module Define = struct
 		| Last (* must be last *)
 
 	let infos = function
-		| AbsolutePath -> ("absolute_path","Print absoluate file path in trace output")
+		| AbsolutePath -> ("absolute_path","Print absolute file path in trace output")
 		| AdvancedTelemetry -> ("advanced-telemetry","Allow the SWF to be measured with Monocle tool")
 		| As3 -> ("as3","Defined when outputing flash9 as3 source code")
 		| CheckXmlProxy -> ("check_xml_proxy","Check the used fields of the xml proxy")

+ 17 - 12
genneko.ml

@@ -50,20 +50,25 @@ let pos ctx p =
 		| false ->
 			try
 				Hashtbl.find files p.pfile
-			with Not_found -> try
-				(* lookup relative path *)
-				let len = String.length p.pfile in
-				let base = List.find (fun path ->
-					let l = String.length path in
-					len > l && String.sub p.pfile 0 l = path
-				) ctx.com.Common.class_path in
-				let l = String.length base in
-				let path = String.sub p.pfile l (len - l) in
+			with Not_found ->
+				let path = (match Common.defined ctx.com Common.Define.AbsolutePath with
+				| true -> if (Filename.is_relative p.pfile)
+					then Filename.concat (Sys.getcwd()) p.pfile
+					else p.pfile
+				| false -> try
+					(* lookup relative path *)
+					let len = String.length p.pfile in
+					let base = List.find (fun path ->
+						let l = String.length path in
+						len > l && String.sub p.pfile 0 l = path
+					) ctx.com.Common.class_path in
+					let l = String.length base in
+					String.sub p.pfile l (len - l)
+
+					with Not_found -> p.pfile
+				) in
 				Hashtbl.add files p.pfile path;
 				path
-			with Not_found ->
-				Hashtbl.add files p.pfile p.pfile;
-				p.pfile
 	) in
 	{
 		psource = file;