void UnaryExpression::execute(Stack2 &stack) { if(!customOpCall) { expr->execute(stack); void *ptr = stack.popPtr(); typeDecl->createInstance(stack, true); void *rPtr = stack.popPtr(); stack.pushPtr(rPtr); if(type == not_) *(bool*)rPtr = !(*(bool*)ptr); else if(type == minus) { if(dataType == float_) *(float*)rPtr = -(*(float*)ptr); else if(dataType == int_) *(int*)rPtr = -(*(int*)ptr); else ASSERT(false); } else ASSERT(false); } else customOpCall->execute(stack); }
void IfStatement::execute(Stack2 &stack) { if(stack.owner && stack.owner->state == TaskDeclarationBase::restart) internalState = 0; bool b; switch(internalState) { case 0: expression->execute(stack); b = *(bool*)stack.popPtr(); expression->executeCleanUp(stack); if(b) { internalState = 1; case 1: ifStatements->execute(stack); if(stack.interupt == Stack2::Yield) return; } else if(elseStatements) { internalState = 2; case 2: elseStatements->execute(stack); if(stack.interupt == Stack2::Yield) return; } } internalState = 0; }
void FunctionDeclaration::call(Stack2 &stack) { PUSH_CALL_TREE(stack.executionContext->callTree, ident->name); ASSERT(statements); stack.pushFrame(); statements->execute(stack); ASSERT(stack.interupt == Stack2::None || stack.interupt == Stack2::Return); stack.interupt = Stack2::None; for(size_t i = 0; i < paramDecls->size(); i++) stack.popPtr(); stack.popFrame(); POP_CALL_TREE(stack.executionContext->callTree); }