MCPcopy Create free account
hub / github.com/chibash/stone / callFunction

Method callFunction

src/chap13/StoneVM.java:133–152  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

131 pc += 4;
132 }
133 protected void callFunction() {
134 Object value = registers[decodeRegister(code[pc + 1])];
135 int numOfArgs = code[pc + 2];
136 if (value instanceof VmFunction
137 && ((VmFunction)value).parameters().size() == numOfArgs) {
138 ret = pc + 3;
139 pc = ((VmFunction)value).entry();
140 }
141 else if (value instanceof NativeFunction
142 && ((NativeFunction)value).numOfParameters() == numOfArgs) {
143 Object[] args = new Object[numOfArgs];
144 for (int i = 0; i < numOfArgs; i++)
145 args[i] = stack[sp + i];
146 stack[sp] = ((NativeFunction)value).invoke(args,
147 new ASTList(new ArrayList<ASTree>()));
148 pc += 3;
149 }
150 else
151 throw new StoneException("bad function call");
152 }
153 protected void saveRegisters() {
154 int size = decodeOffset(code[pc + 1]);
155 int dest = size + sp;

Callers 1

mainLoopMethod · 0.95

Calls 6

decodeRegisterMethod · 0.80
entryMethod · 0.80
numOfParametersMethod · 0.80
sizeMethod · 0.45
parametersMethod · 0.45
invokeMethod · 0.45

Tested by

no test coverage detected