Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wasm2c generating undeclared identifier errors #2554

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/prebuilt/wasm2c_source_declarations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1126,9 +1126,12 @@ R"w2c_template( LOAD_DATA((*dest), dest_addr, src + src_addr, n);
R"w2c_template(}
)w2c_template"
R"w2c_template(
typedef enum { RefFunc, RefNull, GlobalGet } expr_type_t;
)w2c_template"
R"w2c_template(
typedef struct {
)w2c_template"
R"w2c_template( enum { RefFunc, RefNull, GlobalGet } expr_type;
R"w2c_template( expr_type_t expr_type;
)w2c_template"
R"w2c_template( wasm_rt_func_type_t type;
)w2c_template"
Expand Down
4 changes: 3 additions & 1 deletion src/template/wasm2c.declarations.c
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,10 @@ static inline void memory_init(wasm_rt_memory_t* dest,
LOAD_DATA((*dest), dest_addr, src + src_addr, n);
}

typedef enum { RefFunc, RefNull, GlobalGet } expr_type_t;

typedef struct {
enum { RefFunc, RefNull, GlobalGet } expr_type;
expr_type_t expr_type;
wasm_rt_func_type_t type;
wasm_rt_function_ptr_t func;
wasm_rt_tailcallee_t func_tailcallee;
Expand Down
4 changes: 3 additions & 1 deletion test/wasm2c/add.txt
Original file line number Diff line number Diff line change
Expand Up @@ -669,8 +669,10 @@ static inline void memory_init(wasm_rt_memory_t* dest,
LOAD_DATA((*dest), dest_addr, src + src_addr, n);
}

typedef enum { RefFunc, RefNull, GlobalGet } expr_type_t;

typedef struct {
enum { RefFunc, RefNull, GlobalGet } expr_type;
expr_type_t expr_type;
wasm_rt_func_type_t type;
wasm_rt_function_ptr_t func;
wasm_rt_tailcallee_t func_tailcallee;
Expand Down
4 changes: 3 additions & 1 deletion test/wasm2c/check-imports.txt
Original file line number Diff line number Diff line change
Expand Up @@ -694,8 +694,10 @@ static inline void memory_init(wasm_rt_memory_t* dest,
LOAD_DATA((*dest), dest_addr, src + src_addr, n);
}

typedef enum { RefFunc, RefNull, GlobalGet } expr_type_t;

typedef struct {
enum { RefFunc, RefNull, GlobalGet } expr_type;
expr_type_t expr_type;
wasm_rt_func_type_t type;
wasm_rt_function_ptr_t func;
wasm_rt_tailcallee_t func_tailcallee;
Expand Down
4 changes: 3 additions & 1 deletion test/wasm2c/export-names.txt
Original file line number Diff line number Diff line change
Expand Up @@ -694,8 +694,10 @@ static inline void memory_init(wasm_rt_memory_t* dest,
LOAD_DATA((*dest), dest_addr, src + src_addr, n);
}

typedef enum { RefFunc, RefNull, GlobalGet } expr_type_t;

typedef struct {
enum { RefFunc, RefNull, GlobalGet } expr_type;
expr_type_t expr_type;
wasm_rt_func_type_t type;
wasm_rt_function_ptr_t func;
wasm_rt_tailcallee_t func_tailcallee;
Expand Down
4 changes: 3 additions & 1 deletion test/wasm2c/hello.txt
Original file line number Diff line number Diff line change
Expand Up @@ -701,8 +701,10 @@ static inline void memory_init(wasm_rt_memory_t* dest,
LOAD_DATA((*dest), dest_addr, src + src_addr, n);
}

typedef enum { RefFunc, RefNull, GlobalGet } expr_type_t;

typedef struct {
enum { RefFunc, RefNull, GlobalGet } expr_type;
expr_type_t expr_type;
wasm_rt_func_type_t type;
wasm_rt_function_ptr_t func;
wasm_rt_tailcallee_t func_tailcallee;
Expand Down
4 changes: 3 additions & 1 deletion test/wasm2c/minimal.txt
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,10 @@ static inline void memory_init(wasm_rt_memory_t* dest,
LOAD_DATA((*dest), dest_addr, src + src_addr, n);
}

typedef enum { RefFunc, RefNull, GlobalGet } expr_type_t;

typedef struct {
enum { RefFunc, RefNull, GlobalGet } expr_type;
expr_type_t expr_type;
wasm_rt_func_type_t type;
wasm_rt_function_ptr_t func;
wasm_rt_tailcallee_t func_tailcallee;
Expand Down
4 changes: 3 additions & 1 deletion test/wasm2c/tail-calls.txt
Original file line number Diff line number Diff line change
Expand Up @@ -693,8 +693,10 @@ static inline void memory_init(wasm_rt_memory_t* dest,
LOAD_DATA((*dest), dest_addr, src + src_addr, n);
}

typedef enum { RefFunc, RefNull, GlobalGet } expr_type_t;

typedef struct {
enum { RefFunc, RefNull, GlobalGet } expr_type;
expr_type_t expr_type;
wasm_rt_func_type_t type;
wasm_rt_function_ptr_t func;
wasm_rt_tailcallee_t func_tailcallee;
Expand Down