mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-15 02:44:47 +01:00
Use byte values for ValeTypes instead of Varint values. Prepare for ref
values.
This commit is contained in:
parent
776cf133bc
commit
d81da1f342
@ -105,16 +105,16 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
|
||||
WasmOutputStream stream = new WasmOutputStream();
|
||||
stream.writeVaruint32( count );
|
||||
for( FunctionType type : functionTypes ) {
|
||||
stream.writeVarint( ValueType.func.getCode() );
|
||||
stream.write( ValueType.func.getCode() );
|
||||
stream.writeVaruint32( type.params.size() );
|
||||
for( ValueType valueType : type.params ) {
|
||||
stream.writeVarint( valueType.getCode() );
|
||||
stream.write( valueType.getCode() );
|
||||
}
|
||||
if( type.result == null ) {
|
||||
stream.writeVaruint32( 0 );
|
||||
} else {
|
||||
stream.writeVaruint32( 1 );
|
||||
stream.writeVarint( type.result.getCode() );
|
||||
stream.write( type.result.getCode() );
|
||||
}
|
||||
}
|
||||
wasm.writeSection( SectionType.Type, stream, null );
|
||||
@ -295,7 +295,7 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
|
||||
localsStream.writeVaruint32( locals.size() );
|
||||
for( ValueType valueType : locals ) {
|
||||
localsStream.writeVaruint32( 1 ); // TODO optimize, write the count of same types.
|
||||
localsStream.writeVarint( valueType.getCode() );
|
||||
localsStream.write( valueType.getCode() );
|
||||
}
|
||||
functionsStream.writeVaruint32( localsStream.size() + codeStream.size() + 1 );
|
||||
localsStream.writeTo( functionsStream );
|
||||
@ -692,7 +692,7 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
|
||||
break;
|
||||
case IF:
|
||||
codeStream.write( IF );
|
||||
codeStream.write( 0x40 ); // void; the return type of the block. currently we does not use it
|
||||
codeStream.write( ValueType.empty.getCode() ); // void; the return type of the block. currently we does not use it
|
||||
break;
|
||||
case ELSE:
|
||||
codeStream.write( ELSE );
|
||||
@ -705,7 +705,7 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
|
||||
break;
|
||||
case BLOCK:
|
||||
codeStream.write( BLOCK );
|
||||
codeStream.write( 0x40 ); // void; the return type of the block. currently we does not use it
|
||||
codeStream.write( ValueType.empty.getCode() ); // void; the return type of the block. currently we does not use it
|
||||
break;
|
||||
case BR:
|
||||
codeStream.write( BR );
|
||||
@ -725,7 +725,7 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
|
||||
break;
|
||||
case LOOP:
|
||||
codeStream.write( LOOP );
|
||||
codeStream.write( 0x40 ); // void; the return type of the loop. currently we does not use it
|
||||
codeStream.write( ValueType.empty.getCode() ); // void; the return type of the loop. currently we does not use it
|
||||
break;
|
||||
case UNREACHABLE:
|
||||
codeStream.write( UNREACHABLE );
|
||||
|
@ -334,4 +334,10 @@ interface InstructionOpcodes {
|
||||
static final int F64_CONVERT_U_I64 = 0xBA;
|
||||
|
||||
static final int F64_PROMOTE_F32 = 0xBB;
|
||||
|
||||
// === numerical operations ======
|
||||
|
||||
static final int REF_NULL = 0xD0;
|
||||
|
||||
static final int REF_ISNULL = 0xD1;
|
||||
}
|
||||
|
@ -19,14 +19,17 @@ package de.inetsoftware.jwebassembly.module;
|
||||
* @author Volker Berlin
|
||||
*/
|
||||
public enum ValueType {
|
||||
i32(-1),
|
||||
i64(-2),
|
||||
f32(-3),
|
||||
f64(-4),
|
||||
func(-0x20);
|
||||
// void(-0x40);
|
||||
i32(0x7f),
|
||||
i64(0x7e),
|
||||
f32(0x7d),
|
||||
f64(0x7c),
|
||||
anyfunc(0x70),
|
||||
anyref(0x6f),
|
||||
func(0x60),
|
||||
empty(0x40), // empty block_type
|
||||
;
|
||||
|
||||
private int code;
|
||||
private final int code;
|
||||
|
||||
/**
|
||||
* Create instance of the enum
|
||||
|
Loading…
x
Reference in New Issue
Block a user