diff src/luan/interp/LuaCompiler.java @ 40:e3624b7cd603

implement stack trace git-svn-id: https://luan-java.googlecode.com/svn/trunk@41 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Fri, 21 Dec 2012 10:45:54 +0000
parents 5cf15507d77e
children
line wrap: on
line diff
--- a/src/luan/interp/LuaCompiler.java	Thu Dec 20 02:54:06 2012 +0000
+++ b/src/luan/interp/LuaCompiler.java	Fri Dec 21 10:45:54 2012 +0000
@@ -8,22 +8,25 @@
 import luan.LuaFunction;
 import luan.LuaState;
 import luan.LuaException;
+import luan.LuaSource;
+import luan.LuaElement;
 
 
 public final class LuaCompiler {
 	private LuaCompiler() {}  // never
 
-	public static LuaFunction compile(LuaState lua,String src) throws LuaException {
+	public static LuaFunction compile(LuaState lua,LuaSource src) throws LuaException {
 		LuaParser parser = Parboiled.createParser(LuaParser.class);
-		ParsingResult<?> result = new ReportingParseRunner(parser.Target()).run(src);
+		parser.source = src;
+		ParsingResult<?> result = new ReportingParseRunner(parser.Target()).run(src.text);
 //		ParsingResult<?> result = new TracingParseRunner(parser.Target()).run(src);
 		if( result.hasErrors() )
-			throw new LuaException( ErrorUtils.printParseErrors(result) );
+			throw new LuaException( lua, null, ErrorUtils.printParseErrors(result) );
 		Object resultValue = result.resultValue;
 		if( resultValue instanceof Expressions ) {
 			final Expressions expressions = (Expressions)resultValue;
 			return new LuaFunction() {
-				public Object[] call(LuaState lua,Object... args) throws LuaException {
+				public Object[] call(LuaState lua,Object[] args) throws LuaException {
 					return expressions.eval((LuaStateImpl)lua);
 				}
 			};