char* Call(ListExecutor* self, SlimList* instruction) { if (SlimList_GetLength(instruction) < 4) return MalformedInstruction(self, instruction); char* instanceName = SlimList_GetStringAt(instruction, 2); char* methodName = SlimList_GetStringAt(instruction, 3); SlimList* args = SlimList_GetTailAt(instruction, 4); char* result = buyString(StatementExecutor_Call(self->executor, instanceName, methodName, args)); SlimList_Destroy(args); return result; }
char* CallAndAssign(ListExecutor* self, SlimList* instruction) { if (SlimList_GetLength(instruction) < 5) return MalformedInstruction(self, instruction); char* symbolName = SlimList_GetStringAt(instruction, 2); char* instanceName = SlimList_GetStringAt(instruction, 3); char* methodName = SlimList_GetStringAt(instruction, 4); SlimList* args = SlimList_GetTailAt(instruction, 5); char* result = CSlim_BuyString(StatementExecutor_Call(self->executor, instanceName, methodName, args)); StatementExecutor_SetSymbol(self->executor, symbolName, result); SlimList_Destroy(args); return result; }
std::string ListExecutor::Call(SlimList* instruction) { if (instruction->GetLength() < 4) { return MalformedInstruction(instruction); } std::string instanceName = instruction->GetStringAt(2); std::string methodName = instruction->GetStringAt(3); SlimList* args = instruction->GetTailAt(4); std::string result = m_executor->Call(instanceName.c_str(), methodName.c_str(), args); delete args; return result; }