Skip to content

Commit 9fb0fba

Browse files
committed
fix code gen issue for multi lang
1 parent 39dabd3 commit 9fb0fba

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

codegen/codegen.wasm.go

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ var flag = 0
2222

2323
//go:noinline
2424
func GenerateTargetCode(targetLangLib string, parsedAPI *gabs.Container) string {
25-
fmt.Println("WASM: Generating target code")
2625
convertedSnippetFinal := generateConvertedSippet(targetLangLib, parsedAPI)
27-
fmt.Println("WASM: This is the converted snippet:", convertedSnippetFinal)
26+
fmt.Println("This is the converted snippet:", convertedSnippetFinal)
2827
return convertedSnippetFinal
2928
}
3029

@@ -36,34 +35,33 @@ func asyncTask(resultChan0 chan<- string) {
3635

3736
//go:noinline
3837
func generateConvertedSippet(targetLangLib string, parsedAPI *gabs.Container) string {
39-
fmt.Println("WASM: Generating converted snippet")
4038
parsedAPIblocks := parsedAPI.S("value").Data().(*gabs.Container).Children()
4139
convertedSnippetList := make([]string, 0)
4240
blockLength := len(parsedAPIblocks)
43-
fmt.Println("WASM: Parsed API", parsedAPIblocks)
41+
fmt.Println("Parsed API", parsedAPIblocks)
4442
for i, block := range parsedAPIblocks {
4543
blockType := block.S("type").Data().(string)
46-
fmt.Println("WASM: Block type:", blockType)
44+
fmt.Println("Block type:", blockType)
4745
if blockType == "processor" {
48-
fmt.Println("WASM: Block type is processor")
46+
fmt.Println("Block type is processor")
4947
snippet := block.S("value").Data().(*gabs.Container).Data().(string)
5048
log.Debug().Str("Processor block incoming block", block.String()).Msg("")
5149
convertedSnippetList = append(convertedSnippetList, snippet)
5250
} else if blockType == "Lama2File" {
53-
fmt.Println("WASM: Block type is L2File")
51+
fmt.Println("Block type is L2File")
5452
harRequest, flag := GetRequestHARString(block, targetLangLib)
55-
fmt.Println("WASM: HAR request:", harRequest)
53+
fmt.Println("HAR request:", harRequest)
5654
snippetArgs := SnippetArgs{}
5755
lang, lib := SplitLangLib(targetLangLib)
58-
fmt.Println("WASM: Target lang:", lang)
56+
fmt.Println("Target lang:", lang)
5957
snippetArgs.Language = lang
6058
snippetArgs.Library = lib
6159
snippetArgs.HARRequest = harRequest
6260
snippetArgs.SnippetCore = snippetcore
63-
fmt.Println("WASM: Snippet args:", snippetArgs)
61+
fmt.Println("Snippet args:", snippetArgs)
6462
httpsnippetCode := PrepareHTTPSnippetGenerator(snippetArgs)
6563
convertedSnippet := js.Global().Call("eval", httpsnippetCode)
66-
fmt.Println("WASM: convertedSnippet data:", convertedSnippet.String())
64+
fmt.Println("convertedSnippet data:", convertedSnippet.String())
6765
// convertedSnippet, err := evaluateJSCode(httpsnippetCode)
6866
// if err != nil {
6967
// log.Fatal().
@@ -81,7 +79,6 @@ func generateConvertedSippet(targetLangLib string, parsedAPI *gabs.Container) st
8179
}
8280

8381
convertedSnippetFinal := strings.Join(convertedSnippetList, "\n")
84-
fmt.Println("WASM: Converted snippet final:", convertedSnippetFinal)
8582
return convertedSnippetFinal
8683
}
8784

@@ -115,7 +112,6 @@ func generateConvertedSippet(targetLangLib string, parsedAPI *gabs.Container) st
115112

116113
//go:noinline
117114
func PrepareHTTPSnippetGenerator(snippetArgs SnippetArgs) string {
118-
fmt.Println("WASM: Snippet args:", snippetArgs)
119115
var templOutput bytes.Buffer
120116
templStr := `{{.SnippetCore}}
121117
@@ -125,6 +121,5 @@ func PrepareHTTPSnippetGenerator(snippetArgs SnippetArgs) string {
125121
`
126122
tmpl, _ := template.New("httpsnippet").Parse(templStr)
127123
tmpl.Execute(&templOutput, snippetArgs)
128-
fmt.Println("WASM: Templ output:")
129124
return templOutput.String()
130125
}

0 commit comments

Comments
 (0)