Commit 2c0fde51 authored by 袁兴强's avatar 袁兴强 Committed by vipwzw

add totalENV

parent 72e93aa3
...@@ -35,6 +35,7 @@ void printlog(const char* log, size_t len); ...@@ -35,6 +35,7 @@ void printlog(const char* log, size_t len);
void printint(int64_t n); void printint(int64_t n);
size_t getENVSize(int64_t n); size_t getENVSize(int64_t n);
size_t getENV(int64_t n, char* value, size_t v_len); size_t getENV(int64_t n, char* value, size_t v_len);
size_t totalENV();
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -178,3 +178,7 @@ func getENVSize(n int) int { ...@@ -178,3 +178,7 @@ func getENVSize(n int) int {
func getENV(n int) string { func getENV(n int) string {
return wasmCB.ENV[n] return wasmCB.ENV[n]
} }
func totalENV() int {
return len(wasmCB.ENV)
}
...@@ -302,6 +302,10 @@ func (r *Resolver) ResolveFunc(module, field string) exec.FunctionImport { ...@@ -302,6 +302,10 @@ func (r *Resolver) ResolveFunc(module, field string) exec.FunctionImport {
copy(vm.Memory[valuePtr:valuePtr+valueLen], value) copy(vm.Memory[valuePtr:valuePtr+valueLen], value)
return int64(len(value)) return int64(len(value))
} }
case "totalENV":
return func(vm *exec.VirtualMachine) int64 {
return int64(totalENV())
}
default: default:
log.Error("ResolveFunc", "unknown field", field) log.Error("ResolveFunc", "unknown field", field)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment