Improve bytcode generation.
This commit is contained in:
@@ -56,6 +56,14 @@ public class LuaString extends LuaValue {
|
|||||||
this.m_length = bytes.length;
|
this.m_length = bytes.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static LuaString valueOf(char[] bytes) {
|
||||||
|
int n = bytes.length;
|
||||||
|
byte[] b = new byte[n];
|
||||||
|
for ( int i=0; i<n; i++ )
|
||||||
|
b[i] = (byte) bytes[i];
|
||||||
|
return new LuaString(b, 0, n);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isstring() {
|
public boolean isstring() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -400,6 +408,23 @@ public class LuaString extends LuaValue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isValidUtf8() {
|
||||||
|
int i,j,n,b,e=0;
|
||||||
|
for ( i=m_offset,j=m_offset+m_length,n=0; i<j; ++n ) {
|
||||||
|
int c = m_bytes[i++];
|
||||||
|
if ( c >= 0 ) continue;
|
||||||
|
if ( ((c & 0xE0) == 0xC0)
|
||||||
|
&& i<j
|
||||||
|
&& (m_bytes[i++] & 0xC0) == 0x80) continue;
|
||||||
|
if ( ((c & 0xF0) == 0xE0)
|
||||||
|
&& i+1<j
|
||||||
|
&& (m_bytes[i++] & 0xC0) == 0x80
|
||||||
|
&& (m_bytes[i++] & 0xC0) == 0x80) continue;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// --------------------- number conversion -----------------------
|
// --------------------- number conversion -----------------------
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -24,7 +24,6 @@ package org.luaj.vm2;
|
|||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
import org.luaj.vm2.CompatibiltyTest.LuaJCCompatibilityTest;
|
|
||||||
import org.luaj.vm2.WeakTableTest.WeakKeyTableTest;
|
import org.luaj.vm2.WeakTableTest.WeakKeyTableTest;
|
||||||
import org.luaj.vm2.WeakTableTest.WeakKeyValueTableTest;
|
import org.luaj.vm2.WeakTableTest.WeakKeyValueTableTest;
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ package org.luaj.vm2;
|
|||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
|
import org.luaj.vm2.compiler.LuaC;
|
||||||
import org.luaj.vm2.luajc.JavaBytecodeCompiler;
|
import org.luaj.vm2.luajc.JavaBytecodeCompiler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -62,7 +63,6 @@ public class CompatibiltyTest {
|
|||||||
suite.addTest( new TestSuite( JseCompatibilityTest.class, "JSE Tests" ) );
|
suite.addTest( new TestSuite( JseCompatibilityTest.class, "JSE Tests" ) );
|
||||||
suite.addTest( new TestSuite( JmeCompatibilityTest.class, "JME Tests" ) );
|
suite.addTest( new TestSuite( JmeCompatibilityTest.class, "JME Tests" ) );
|
||||||
suite.addTest( new TestSuite( JseBytecodeTest.class, "JSE Bytecode Tests" ) );
|
suite.addTest( new TestSuite( JseBytecodeTest.class, "JSE Bytecode Tests" ) );
|
||||||
suite.addTest( new TestSuite( LuaJCCompatibilityTest.class, "LuaJC Gen Tests" ) );
|
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,6 +82,7 @@ public class CompatibiltyTest {
|
|||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
System.setProperty("JME", "false");
|
System.setProperty("JME", "false");
|
||||||
|
LuaC.install();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static class JseBytecodeTest extends CompatibiltyTestSuite {
|
public static class JseBytecodeTest extends CompatibiltyTestSuite {
|
||||||
@@ -93,16 +94,7 @@ public class CompatibiltyTest {
|
|||||||
System.setProperty("JME", "false");
|
System.setProperty("JME", "false");
|
||||||
JavaBytecodeCompiler.install();
|
JavaBytecodeCompiler.install();
|
||||||
}
|
}
|
||||||
}
|
// not supported on this platform - don't test
|
||||||
public static class LuaJCCompatibilityTest extends CompatibiltyTestSuite {
|
|
||||||
public LuaJCCompatibilityTest() {
|
|
||||||
super(ScriptDrivenTest.PlatformType.LUAJIT);
|
|
||||||
}
|
|
||||||
protected void setUp() throws Exception {
|
|
||||||
super.setUp();
|
|
||||||
System.setProperty("JME", "false");
|
|
||||||
}
|
|
||||||
// skipping - not supported yet
|
|
||||||
public void testDebugLib() {}
|
public void testDebugLib() {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user