Reduces FunctionDefinition usages (#1419)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
This commit is contained in:
@@ -40,7 +40,7 @@ func TestModule_BuildFunctionDefinitions(t *testing.T) {
|
||||
{
|
||||
name: "only imported functions",
|
||||
expected: []FunctionDefinition{
|
||||
{name: "fn", debugName: ".fn", importDesc: &Import{Module: "foo", Name: "bar", Type: ExternTypeFunc}, funcType: &FunctionType{}},
|
||||
{name: "fn", Debugname: ".fn", importDesc: &Import{Module: "foo", Name: "bar", Type: ExternTypeFunc}, Functype: &FunctionType{}},
|
||||
},
|
||||
m: &Module{
|
||||
ExportSection: []Export{{Type: ExternTypeGlobal, Index: 0}},
|
||||
@@ -52,8 +52,8 @@ func TestModule_BuildFunctionDefinitions(t *testing.T) {
|
||||
},
|
||||
expectedImports: []api.FunctionDefinition{
|
||||
&FunctionDefinition{
|
||||
name: "fn", debugName: ".fn", importDesc: &Import{Module: "foo", Name: "bar", Type: ExternTypeFunc},
|
||||
funcType: &FunctionType{},
|
||||
name: "fn", Debugname: ".fn", importDesc: &Import{Module: "foo", Name: "bar", Type: ExternTypeFunc},
|
||||
Functype: &FunctionType{},
|
||||
},
|
||||
},
|
||||
expectedExports: map[string]api.FunctionDefinition{},
|
||||
@@ -76,9 +76,9 @@ func TestModule_BuildFunctionDefinitions(t *testing.T) {
|
||||
index: 0,
|
||||
name: "fn",
|
||||
moduleName: "m",
|
||||
debugName: "m.fn",
|
||||
Debugname: "m.fn",
|
||||
goFunc: MustParseGoReflectFuncCode(fn).GoFunc,
|
||||
funcType: &i32_i32,
|
||||
Functype: &i32_i32,
|
||||
paramNames: []string{"x"},
|
||||
resultNames: []string{"y"},
|
||||
},
|
||||
@@ -110,41 +110,41 @@ func TestModule_BuildFunctionDefinitions(t *testing.T) {
|
||||
expected: []FunctionDefinition{
|
||||
{
|
||||
index: 0,
|
||||
debugName: ".$0",
|
||||
Debugname: ".$0",
|
||||
exportNames: []string{"function_index=0"},
|
||||
funcType: &f64i32_v128i64,
|
||||
Functype: &f64i32_v128i64,
|
||||
},
|
||||
{
|
||||
index: 1,
|
||||
debugName: ".$1",
|
||||
Debugname: ".$1",
|
||||
exportNames: []string{"function_index=1"},
|
||||
funcType: &f64f32_i64,
|
||||
Functype: &f64f32_i64,
|
||||
},
|
||||
{
|
||||
index: 2,
|
||||
debugName: ".$2",
|
||||
Debugname: ".$2",
|
||||
exportNames: []string{"function_index=2"},
|
||||
funcType: &v_v,
|
||||
Functype: &v_v,
|
||||
},
|
||||
},
|
||||
expectedExports: map[string]api.FunctionDefinition{
|
||||
"function_index=0": &FunctionDefinition{
|
||||
index: 0,
|
||||
debugName: ".$0",
|
||||
Debugname: ".$0",
|
||||
exportNames: []string{"function_index=0"},
|
||||
funcType: &f64i32_v128i64,
|
||||
Functype: &f64i32_v128i64,
|
||||
},
|
||||
"function_index=1": &FunctionDefinition{
|
||||
index: 1,
|
||||
exportNames: []string{"function_index=1"},
|
||||
debugName: ".$1",
|
||||
funcType: &f64f32_i64,
|
||||
Debugname: ".$1",
|
||||
Functype: &f64f32_i64,
|
||||
},
|
||||
"function_index=2": &FunctionDefinition{
|
||||
index: 2,
|
||||
debugName: ".$2",
|
||||
Debugname: ".$2",
|
||||
exportNames: []string{"function_index=2"},
|
||||
funcType: &v_v,
|
||||
Functype: &v_v,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -169,52 +169,52 @@ func TestModule_BuildFunctionDefinitions(t *testing.T) {
|
||||
expected: []FunctionDefinition{
|
||||
{
|
||||
index: 0,
|
||||
debugName: ".$0",
|
||||
Debugname: ".$0",
|
||||
importDesc: imp,
|
||||
exportNames: []string{"imported_function"},
|
||||
funcType: &f64f32_i64,
|
||||
Functype: &f64f32_i64,
|
||||
},
|
||||
{
|
||||
index: 1,
|
||||
debugName: ".$1",
|
||||
Debugname: ".$1",
|
||||
exportNames: []string{"function_index=1"},
|
||||
funcType: &f64i32_v128i64,
|
||||
Functype: &f64i32_v128i64,
|
||||
},
|
||||
{
|
||||
index: 2,
|
||||
debugName: ".$2",
|
||||
Debugname: ".$2",
|
||||
exportNames: []string{"function_index=2"},
|
||||
funcType: &v_v,
|
||||
Functype: &v_v,
|
||||
},
|
||||
},
|
||||
expectedImports: []api.FunctionDefinition{
|
||||
&FunctionDefinition{
|
||||
index: 0,
|
||||
debugName: ".$0",
|
||||
Debugname: ".$0",
|
||||
importDesc: imp,
|
||||
exportNames: []string{"imported_function"},
|
||||
funcType: &f64f32_i64,
|
||||
Functype: &f64f32_i64,
|
||||
},
|
||||
},
|
||||
expectedExports: map[string]api.FunctionDefinition{
|
||||
"imported_function": &FunctionDefinition{
|
||||
index: 0,
|
||||
debugName: ".$0",
|
||||
Debugname: ".$0",
|
||||
importDesc: imp,
|
||||
exportNames: []string{"imported_function"},
|
||||
funcType: &f64f32_i64,
|
||||
Functype: &f64f32_i64,
|
||||
},
|
||||
"function_index=1": &FunctionDefinition{
|
||||
index: 1,
|
||||
debugName: ".$1",
|
||||
Debugname: ".$1",
|
||||
exportNames: []string{"function_index=1"},
|
||||
funcType: &f64i32_v128i64,
|
||||
Functype: &f64i32_v128i64,
|
||||
},
|
||||
"function_index=2": &FunctionDefinition{
|
||||
index: 2,
|
||||
debugName: ".$2",
|
||||
Debugname: ".$2",
|
||||
exportNames: []string{"function_index=2"},
|
||||
funcType: &v_v,
|
||||
Functype: &v_v,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -236,15 +236,15 @@ func TestModule_BuildFunctionDefinitions(t *testing.T) {
|
||||
CodeSection: []Code{nopCode, nopCode, nopCode, nopCode, nopCode},
|
||||
},
|
||||
expected: []FunctionDefinition{
|
||||
{moduleName: "module", index: 0, debugName: "module.$0", importDesc: &Import{Module: "i", Name: "f"}, funcType: &v_v},
|
||||
{moduleName: "module", index: 1, debugName: "module.$1", funcType: &v_v},
|
||||
{moduleName: "module", index: 2, debugName: "module.two", funcType: &v_v, name: "two"},
|
||||
{moduleName: "module", index: 3, debugName: "module.$3", funcType: &v_v},
|
||||
{moduleName: "module", index: 4, debugName: "module.four", funcType: &v_v, name: "four"},
|
||||
{moduleName: "module", index: 5, debugName: "module.five", funcType: &v_v, name: "five"},
|
||||
{moduleName: "module", index: 0, Debugname: "module.$0", importDesc: &Import{Module: "i", Name: "f"}, Functype: &v_v},
|
||||
{moduleName: "module", index: 1, Debugname: "module.$1", Functype: &v_v},
|
||||
{moduleName: "module", index: 2, Debugname: "module.two", Functype: &v_v, name: "two"},
|
||||
{moduleName: "module", index: 3, Debugname: "module.$3", Functype: &v_v},
|
||||
{moduleName: "module", index: 4, Debugname: "module.four", Functype: &v_v, name: "four"},
|
||||
{moduleName: "module", index: 5, Debugname: "module.five", Functype: &v_v, name: "five"},
|
||||
},
|
||||
expectedImports: []api.FunctionDefinition{
|
||||
&FunctionDefinition{moduleName: "module", index: 0, debugName: "module.$0", importDesc: &Import{Module: "i", Name: "f"}, funcType: &v_v},
|
||||
&FunctionDefinition{moduleName: "module", index: 0, Debugname: "module.$0", importDesc: &Import{Module: "i", Name: "f"}, Functype: &v_v},
|
||||
},
|
||||
expectedExports: map[string]api.FunctionDefinition{},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user