stage1 完成14测试

This commit is contained in:
zzy
2026-07-06 15:18:17 +08:00
parent ad473f245c
commit 0892c084ee
3 changed files with 32 additions and 8 deletions

View File

@@ -8,6 +8,7 @@
*/
#include "spl_syscall.h"
#include "include/core_map.h"
#include "include/core_vec.h"
#include "spl_ir.h"
#include "spl_vm.h"
@@ -121,9 +122,15 @@ static spl_val_t vm_fsize(int nargs, spl_val_t *args) {
static spl_val_t vm_read_file(int nargs, spl_val_t *args) {
CHECK_NARGS("vm_read_file", 1);
const char *path = (const char *)(uintptr_t)args[0];
if (path == nullptr) {
fprintf(stderr, "filepath can't be null");
return 1;
}
FILE *f = fopen(path, "rb");
if (!f)
return 0;
if (!f) {
fprintf(stderr, "filepath %s can't be open", path);
return 1;
}
fseek(f, 0, SEEK_END);
long sz = ftell(f);
fseek(f, 0, SEEK_SET);