}}}
(context *funcContext, stmt *ast.IfStmt)
| 911 | } // }}} |
| 912 | |
| 913 | func compileIfStmt(context *funcContext, stmt *ast.IfStmt) { // {{{ |
| 914 | thenlabel := context.NewLabel() |
| 915 | elselabel := context.NewLabel() |
| 916 | endlabel := context.NewLabel() |
| 917 | |
| 918 | compileBranchCondition(context, context.RegTop(), stmt.Condition, thenlabel, elselabel, false) |
| 919 | context.SetLabelPc(thenlabel, context.Code.LastPC()) |
| 920 | compileBlock(context, stmt.Then) |
| 921 | if len(stmt.Else) > 0 { |
| 922 | context.Code.AddASbx(OP_JMP, 0, endlabel, sline(stmt)) |
| 923 | } |
| 924 | context.SetLabelPc(elselabel, context.Code.LastPC()) |
| 925 | if len(stmt.Else) > 0 { |
| 926 | compileBlock(context, stmt.Else) |
| 927 | context.SetLabelPc(endlabel, context.Code.LastPC()) |
| 928 | } |
| 929 | |
| 930 | } // }}} |
| 931 | |
| 932 | func compileBranchCondition(context *funcContext, reg int, expr ast.Expr, thenlabel, elselabel int, hasnextcond bool) { // {{{ |
| 933 | // TODO folding constants? |
no test coverage detected
searching dependent graphs…