Mercurial Hosting > luan
comparison src/luan/interp/ConcatExpr.java @ 48:64ecb7a3aad7
rename Lua to Luan
git-svn-id: https://luan-java.googlecode.com/svn/trunk@49 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Fri, 28 Dec 2012 03:29:12 +0000 |
parents | e3624b7cd603 |
children | 8ede219cd111 |
comparison
equal
deleted
inserted
replaced
47:659c7139e903 | 48:64ecb7a3aad7 |
---|---|
1 package luan.interp; | 1 package luan.interp; |
2 | 2 |
3 import luan.Lua; | 3 import luan.Luan; |
4 import luan.LuaFunction; | 4 import luan.LuanFunction; |
5 import luan.LuaException; | 5 import luan.LuanException; |
6 import luan.LuaSource; | 6 import luan.LuanSource; |
7 | 7 |
8 | 8 |
9 final class ConcatExpr extends BinaryOpExpr { | 9 final class ConcatExpr extends BinaryOpExpr { |
10 | 10 |
11 ConcatExpr(LuaSource.Element se,Expr op1,Expr op2) { | 11 ConcatExpr(LuanSource.Element se,Expr op1,Expr op2) { |
12 super(se,op1,op2); | 12 super(se,op1,op2); |
13 } | 13 } |
14 | 14 |
15 @Override public Object eval(LuaStateImpl lua) throws LuaException { | 15 @Override public Object eval(LuanStateImpl lua) throws LuanException { |
16 Object o1 = op1.eval(lua); | 16 Object o1 = op1.eval(lua); |
17 Object o2 = op2.eval(lua); | 17 Object o2 = op2.eval(lua); |
18 String s1 = Lua.asString(o1); | 18 String s1 = Luan.asString(o1); |
19 String s2 = Lua.asString(o2); | 19 String s2 = Luan.asString(o2); |
20 if( s1 != null && s2 != null ) | 20 if( s1 != null && s2 != null ) |
21 return s1 + s2; | 21 return s1 + s2; |
22 LuaFunction fn = lua.getBinHandler(se,"__concat",o1,o2); | 22 LuanFunction fn = lua.getBinHandler(se,"__concat",o1,o2); |
23 if( fn != null ) | 23 if( fn != null ) |
24 return Lua.first(lua.call(fn,se,"__concat",o1,o2)); | 24 return Luan.first(lua.call(fn,se,"__concat",o1,o2)); |
25 String type = s1==null ? Lua.type(o1) : Lua.type(o2); | 25 String type = s1==null ? Luan.type(o1) : Luan.type(o2); |
26 throw new LuaException( lua, se, "attempt to concatenate a " + type + " value" ); | 26 throw new LuanException( lua, se, "attempt to concatenate a " + type + " value" ); |
27 } | 27 } |
28 } | 28 } |