}}}
(context *funcContext, stmt *ast.AssignStmt)
| 781 | } // }}} |
| 782 | |
| 783 | func compileAssignStmt(context *funcContext, stmt *ast.AssignStmt) { // {{{ |
| 784 | code := context.Code |
| 785 | lennames := len(stmt.Lhs) |
| 786 | reg, acs := compileAssignStmtLeft(context, stmt) |
| 787 | reg, acs = compileAssignStmtRight(context, stmt, reg, acs) |
| 788 | |
| 789 | for i := lennames - 1; i >= 0; i-- { |
| 790 | ex := stmt.Lhs[i] |
| 791 | switch acs[i].ec.ctype { |
| 792 | case ecLocal: |
| 793 | if acs[i].needmove { |
| 794 | code.AddABC(OP_MOVE, context.FindLocalVar(ex.(*ast.IdentExpr).Value), reg, 0, sline(ex)) |
| 795 | reg -= 1 |
| 796 | } |
| 797 | case ecGlobal: |
| 798 | code.AddABx(OP_SETGLOBAL, reg, context.ConstIndex(LString(ex.(*ast.IdentExpr).Value)), sline(ex)) |
| 799 | reg -= 1 |
| 800 | case ecUpvalue: |
| 801 | code.AddABC(OP_SETUPVAL, reg, context.Upvalues.RegisterUnique(ex.(*ast.IdentExpr).Value), 0, sline(ex)) |
| 802 | reg -= 1 |
| 803 | case ecTable: |
| 804 | opcode := OP_SETTABLE |
| 805 | if acs[i].keyks { |
| 806 | opcode = OP_SETTABLEKS |
| 807 | } |
| 808 | code.AddABC(opcode, acs[i].ec.reg, acs[i].keyrk, acs[i].valuerk, sline(ex)) |
| 809 | if !opIsK(acs[i].valuerk) { |
| 810 | reg -= 1 |
| 811 | } |
| 812 | } |
| 813 | } |
| 814 | } // }}} |
| 815 | |
| 816 | func compileRegAssignment(context *funcContext, names []string, exprs []ast.Expr, reg int, nvars int, line int) { // {{{ |
| 817 | lennames := len(names) |
no test coverage detected
searching dependent graphs…