changeset 51:28dfd91a816c

various small issues git-svn-id: https://luan-java.googlecode.com/svn/trunk@52 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Fri, 28 Dec 2012 20:43:06 +0000
parents 272b6f1d7dac
children 0c0f2b107099
files src/luan/LuanSource.java src/luan/interp/LuanParser.java src/luan/lib/JavaLib.java src/luan/tools/WebShell.java
diffstat 4 files changed, 17 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/luan/LuanSource.java	Fri Dec 28 19:48:43 2012 +0000
+++ b/src/luan/LuanSource.java	Fri Dec 28 20:43:06 2012 +0000
@@ -20,6 +20,9 @@
 				throw new NullPointerException("source is null");
 			this.source = source;
 			this.start = start;
+			while( Character.isWhitespace(source.text.charAt(end-1)) ) {
+				end--;
+			}
 			this.end = end;
 		}
 
--- a/src/luan/interp/LuanParser.java	Fri Dec 28 19:48:43 2012 +0000
+++ b/src/luan/interp/LuanParser.java	Fri Dec 28 20:43:06 2012 +0000
@@ -162,16 +162,17 @@
 			FirstOf(
 				Sequence(
 					ExpList(),
-					EOI,
-					push( new ReturnStmt( se(start.get()), (Expressions)pop() ) )
+					push( new ReturnStmt( se(start.get()), (Expressions)pop() ) ),
+					push( newChunk(start.get()) ),
+					EOI
 				),
 				Sequence(
 					action( frame.isVarArg = true ),
 					Block(),
+					push( newChunk(start.get()) ),
 					EOI
 				)
-			),
-			push( newChunk(start.get()) )
+			)
 		);
 	}
 
--- a/src/luan/lib/JavaLib.java	Fri Dec 28 19:48:43 2012 +0000
+++ b/src/luan/lib/JavaLib.java	Fri Dec 28 20:43:06 2012 +0000
@@ -187,11 +187,17 @@
 	}
 
 	public static Static getClass(LuanState luan,String name) throws LuanException {
+		Class cls;
 		try {
-			return new Static( Class.forName(name) );
+			cls = Class.forName(name);
 		} catch(ClassNotFoundException e) {
-			throw new LuanException(luan,LuanElement.JAVA,e);
+			try {
+				cls = Thread.currentThread().getContextClassLoader().loadClass(name);
+			} catch(ClassNotFoundException e2) {
+				throw new LuanException(luan,LuanElement.JAVA,e);
+			}
 		}
+		return new Static(cls);
 	}
 
 	public static void importClass(LuanState luan,String name) throws LuanException {
--- a/src/luan/tools/WebShell.java	Fri Dec 28 19:48:43 2012 +0000
+++ b/src/luan/tools/WebShell.java	Fri Dec 28 20:43:06 2012 +0000
@@ -27,7 +27,7 @@
 public class WebShell extends HttpServlet {
 	private static final Logger logger = LoggerFactory.getLogger(WebShell.class);
 
-	protected LuanState newLuanState() {
+	protected LuanState newLuanState() throws LuanException {
 		LuanState luan =  LuanCompiler.newLuanState();
 		BasicLib.register(luan);
 		JavaLib.register(luan);