Improve bytcode generation.

This commit is contained in:
James Roseborough
2009-11-02 05:38:36 +00:00
parent 05e6fa5774
commit c78d789cdc
4 changed files with 1057 additions and 870 deletions

View File

@@ -56,6 +56,14 @@ public class LuaString extends LuaValue {
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() {
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 -----------------------

File diff suppressed because it is too large Load Diff