diff options
Diffstat (limited to 'vendor/modernc.org/ccgo')
-rw-r--r-- | vendor/modernc.org/ccgo/v3/lib/Makefile | 3 | ||||
-rw-r--r-- | vendor/modernc.org/ccgo/v3/lib/go.go | 47 |
2 files changed, 47 insertions, 3 deletions
diff --git a/vendor/modernc.org/ccgo/v3/lib/Makefile b/vendor/modernc.org/ccgo/v3/lib/Makefile index a170239c..eade00eb 100644 --- a/vendor/modernc.org/ccgo/v3/lib/Makefile +++ b/vendor/modernc.org/ccgo/v3/lib/Makefile @@ -76,6 +76,7 @@ build_all_targets: GOOS=darwin GOARCH=arm64 go test -c -o /dev/null GOOS=freebsd GOARCH=386 go test -c -o /dev/null GOOS=freebsd GOARCH=amd64 go test -c -o /dev/null + GOOS=freebsd GOARCH=arm go test -c -o /dev/null GOOS=linux GOARCH=386 go test -c -o /dev/null GOOS=linux GOARCH=amd64 go test -c -o /dev/null GOOS=linux GOARCH=arm go test -c -o /dev/null @@ -83,7 +84,9 @@ build_all_targets: GOOS=linux GOARCH=riscv64 go test -c -o /dev/null GOOS=linux GOARCH=s390x go test -c -o /dev/null GOOS=netbsd GOARCH=amd64 go test -c -o /dev/null + #TODO GOOS=netbsd GOARCH=arm go test -c -o /dev/null GOOS=openbsd GOARCH=amd64 go test -c -o /dev/null + GOOS=openbsd GOARCH=arm64 go test -c -o /dev/null GOOS=windows GOARCH=386 go test -c -o /dev/null GOOS=windows GOARCH=amd64 go test -c -o /dev/null GOOS=windows GOARCH=arm64 go test -c -o /dev/null diff --git a/vendor/modernc.org/ccgo/v3/lib/go.go b/vendor/modernc.org/ccgo/v3/lib/go.go index 665f5ebe..6238d0c9 100644 --- a/vendor/modernc.org/ccgo/v3/lib/go.go +++ b/vendor/modernc.org/ccgo/v3/lib/go.go @@ -1245,8 +1245,9 @@ type project struct { wanted map[*cc.Declarator]struct{} wcharSize uintptr - isMain bool - pass1 bool + isMain bool + pass1 bool + pauseCodegen bool } func newProject(t *Task) (*project, error) { @@ -1366,7 +1367,7 @@ func (p *project) o(s string, args ...interface{}) { } func (p *project) w(s string, args ...interface{}) { - if p.pass1 { + if p.pass1 || p.pauseCodegen { return } @@ -4633,6 +4634,11 @@ var dummyJumpStatement = &cc.JumpStatement{} func (p *project) statement(f *function, n *cc.Statement, forceCompoundStmtBrace, forceNoBraces, switchBlock bool, mode exprMode) (r *cc.JumpStatement) { if forceCompoundStmtBrace { + if f.switchCtx == inSwitchFirst && p.pauseCodegen { + p.pauseCodegen = false + p.w(" {") + p.pauseCodegen = true + } p.w(" {") if !switchBlock { p.instrument(n) @@ -4679,6 +4685,12 @@ func (p *project) statement(f *function, n *cc.Statement, forceCompoundStmtBrace panic(todo("%v: internal error: %v", n.Position(), n.Case)) } if forceCompoundStmtBrace { + // We need to do this, to guarantee that we always close the brace is we opened it + if f.switchCtx == inSwitchFirst && p.pauseCodegen { + p.pauseCodegen = false + p.w("}") + p.pauseCodegen = true + } p.w("}") } return r @@ -12786,12 +12798,22 @@ func (p *project) selectionStatement(f *function, n *cc.SelectionStatement) { p.statement(f, n.Statement2, true, false, false, 0) } case cc.SelectionStatementSwitch: // "switch" '(' Expression ')' Statement + // just dont generate in this case + if f.switchCtx == inSwitchFirst { + break + } sv := f.switchCtx + sb := f.block + sc := p.pauseCodegen svBreakCtx := f.breakCtx f.breakCtx = 0 + f.block = f.blocks[n.Statement.CompoundStatement] + defer func() { + f.block = sb f.switchCtx = sv f.breakCtx = svBreakCtx + p.pauseCodegen = sc }() if f.hasJumps { f.switchCtx = inSwitchFlat @@ -12800,9 +12822,27 @@ func (p *project) selectionStatement(f *function, n *cc.SelectionStatement) { } f.switchCtx = inSwitchFirst + // fmt.Println(f.block.decls) + if len(f.block.decls) != 0 { + f.block.topDecl = true + // fmt.Printf("%p:%tf\n", f.block, f.block.topDecl) + p.w("{") + for _, v := range f.block.decls { + // fmt.Printf("%p:%tf\n", f.block, f.block.topDecl) + p.declaration(f, v, true) + // fmt.Println("done!") + } + } + p.w("switch ") p.expression(f, n.Expression, n.Promote(), exprValue, 0) + p.pauseCodegen = true p.statement(f, n.Statement, true, false, true, 0) + p.pauseCodegen = false + if len(f.block.decls) != 0 { + p.w("}") + } + default: panic(todo("%v: internal error: %v", n.Position(), n.Case)) } @@ -12925,6 +12965,7 @@ func (p *project) labeledStatementCase(f *function, n *cc.LabeledStatement) { switch f.switchCtx { case inSwitchFirst: f.switchCtx = inSwitchCase + p.pauseCodegen = false case inSwitchCase: p.w("\nfallthrough;") case inSwitchSeenBreak: |