emitFunction adds builtin.Function.Func to the program.functions and emits call opcode.
(fn *builtin.Function, argsLen int)
| 174 | |
| 175 | // emitFunction adds builtin.Function.Func to the program.functions and emits call opcode. |
| 176 | func (c *compiler) emitFunction(fn *builtin.Function, argsLen int) { |
| 177 | switch argsLen { |
| 178 | case 0: |
| 179 | c.emit(OpCall0, c.addFunction(fn.Name, fn.Func)) |
| 180 | case 1: |
| 181 | c.emit(OpCall1, c.addFunction(fn.Name, fn.Func)) |
| 182 | case 2: |
| 183 | c.emit(OpCall2, c.addFunction(fn.Name, fn.Func)) |
| 184 | case 3: |
| 185 | c.emit(OpCall3, c.addFunction(fn.Name, fn.Func)) |
| 186 | default: |
| 187 | c.emit(OpLoadFunc, c.addFunction(fn.Name, fn.Func)) |
| 188 | c.emit(OpCallN, argsLen) |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | // addFunction adds builtin.Function.Func to the program.functions and returns its index. |
| 193 | func (c *compiler) addFunction(name string, fn Function) int { |
no test coverage detected