mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
wasm: fixing debug C generator
This commit is contained in:
parent
fc3d92f58d
commit
7806a699c5
|
@ -1064,20 +1064,24 @@ class WasmCRenderingVisitor implements WasmExpressionVisitor {
|
||||||
public void visit(WasmFill expression) {
|
public void visit(WasmFill expression) {
|
||||||
var result = new CExpression();
|
var result = new CExpression();
|
||||||
|
|
||||||
|
requiredType = WasmType.INT32;
|
||||||
expression.getIndex().acceptVisitor(this);
|
expression.getIndex().acceptVisitor(this);
|
||||||
var dest = value;
|
var dest = value;
|
||||||
|
|
||||||
|
requiredType = WasmType.INT32;
|
||||||
expression.getValue().acceptVisitor(this);
|
expression.getValue().acceptVisitor(this);
|
||||||
var v = value;
|
var v = value;
|
||||||
|
|
||||||
expression.getValue().acceptVisitor(this);
|
requiredType = WasmType.INT32;
|
||||||
|
expression.getCount().acceptVisitor(this);
|
||||||
var num = value;
|
var num = value;
|
||||||
|
|
||||||
result.getLines().addAll(dest.getLines());
|
result.getLines().addAll(dest.getLines());
|
||||||
result.getLines().addAll(v.getLines());
|
result.getLines().addAll(v.getLines());
|
||||||
result.getLines().addAll(num.getLines());
|
result.getLines().addAll(num.getLines());
|
||||||
|
|
||||||
result.addLine("memset(" + dest.getText() + ", " + v.getText() + ", " + num.getText() + ");");
|
result.addLine("memset(wasm_heap + " + dest.getText() + ", " + v.getText()
|
||||||
|
+ ", " + num.getText() + ");");
|
||||||
value = result;
|
value = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1085,12 +1089,15 @@ class WasmCRenderingVisitor implements WasmExpressionVisitor {
|
||||||
public void visit(WasmCopy expression) {
|
public void visit(WasmCopy expression) {
|
||||||
var result = new CExpression();
|
var result = new CExpression();
|
||||||
|
|
||||||
|
requiredType = WasmType.INT32;
|
||||||
expression.getDestinationIndex().acceptVisitor(this);
|
expression.getDestinationIndex().acceptVisitor(this);
|
||||||
var dest = value;
|
var dest = value;
|
||||||
|
|
||||||
|
requiredType = WasmType.INT32;
|
||||||
expression.getSourceIndex().acceptVisitor(this);
|
expression.getSourceIndex().acceptVisitor(this);
|
||||||
var src = value;
|
var src = value;
|
||||||
|
|
||||||
|
requiredType = WasmType.INT32;
|
||||||
expression.getCount().acceptVisitor(this);
|
expression.getCount().acceptVisitor(this);
|
||||||
var num = value;
|
var num = value;
|
||||||
|
|
||||||
|
@ -1098,7 +1105,8 @@ class WasmCRenderingVisitor implements WasmExpressionVisitor {
|
||||||
result.getLines().addAll(src.getLines());
|
result.getLines().addAll(src.getLines());
|
||||||
result.getLines().addAll(num.getLines());
|
result.getLines().addAll(num.getLines());
|
||||||
|
|
||||||
result.addLine("memcpy(" + dest.getText() + ", " + src.getText() + ", " + num.getText() + ");");
|
result.addLine("memcpy(wasm_heap + " + dest.getText() + ", wasm_heap + " + src.getText() + ", "
|
||||||
|
+ num.getText() + ");");
|
||||||
value = result;
|
value = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,11 @@ static char** wasm_argv;
|
||||||
#define teavmMath_ceil ceil
|
#define teavmMath_ceil ceil
|
||||||
#define teavmMath_floor floor
|
#define teavmMath_floor floor
|
||||||
|
|
||||||
int64_t teavm_currentTimeMillis() {
|
double teavmMath_random() {
|
||||||
|
return rand() / (double) RAND_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
|
double teavm_currentTimeMillis() {
|
||||||
struct timespec time;
|
struct timespec time;
|
||||||
clock_gettime(CLOCK_REALTIME, &time);
|
clock_gettime(CLOCK_REALTIME, &time);
|
||||||
|
|
||||||
|
@ -148,4 +152,11 @@ int32_t wasi_snapshot_preview1_fd_write(int32_t fd, int32_t iovs, int32_t count,
|
||||||
int32_t* resultPtr = (int32_t*) (wasm_heap + result);
|
int32_t* resultPtr = (int32_t*) (wasm_heap + result);
|
||||||
*resultPtr = written;
|
*resultPtr = written;
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void teavm_putwcharsOut(int32_t chars, int32_t count) {
|
||||||
|
int16_t* chars_array = (int16_t*) (wasm_heap + chars);
|
||||||
|
for (int32_t i = 0; i < count; ++i) {
|
||||||
|
putwchar(chars_array[i]);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user