void ActionsTestScene::runThisTest() { s_nActionIdx = -1; addChild(NextAction()); CCDirector::sharedDirector()->replaceScene(this); }
void ActionsDemo::nextCallback(NSObject* pSender) { CCScene* s = new ActionsTestScene(); s->addChild( NextAction() ); CCDirector::sharedDirector()->replaceScene(s); s->release(); }
NextAction PrintStmtInFn::execute(Env &env, LocalDefs &ie) { Term v = expr.evaluate(env, ie); cout << "\n"; v.print_indented(cout); cout << endl; //cout << v.to_string() << endl; return NextAction(NextAction::continue_normal_execution); }
NextAction StmtSeq::execute(Env &env, LocalDefs &ie) { for (unsigned int i=0 ; i < stmts.size() ; i++) { NextAction res = stmts[i]->execute(env, ie); if (!res.is_normal()) return res; } return NextAction(NextAction::continue_normal_execution); }
NextAction AssertStmt::execute(Env &env, LocalDefs &ie) { Term v = expr.evaluate(env, ie); if (!v.is_true()) { cout << "Assertion failed somewhere\n"; Program::get_singleton().print_stack(); halt; } return NextAction(NextAction::continue_normal_execution); }
NextAction LoopStmt::execute(Env &env, LocalDefs &ie) { for (bool first=true ; ; first=false) { Term ec = first && is_tail_cond ? bool_obj(true) : cond.evaluate(env, ie); assert(ec.is_true() || ec.is_false()); if (ec.is_true()) { NextAction res = body->execute(env, ie); if (res.is_return()) return res; if (res.is_break()) return NextAction(NextAction::continue_normal_execution); } else { return NextAction(NextAction::continue_normal_execution); } } }
NextAction Assignment::execute(Env &env, LocalDefs &ie) { Term val = expr.evaluate(env, ie); if (!type.is_null() && !type->contains(val)) { cout << "Error in type assignment. The value is not of the declared type.\n"; cout << " Variable name: " << var_name.to_string() << "\n"; cout << " Value:\n\n"; val.print(cout); Program::get_singleton().print_stack(); cout << endl; halt; } env.set(var_name, val); return NextAction(NextAction::continue_normal_execution); }
NextAction IfStmt::execute(Env &env, LocalDefs &ie) { Term ec = cond.evaluate(env, ie); if (!ec.is_true() && !ec.is_false()) { string ecs = ec.to_string(true); cout << "Condition for if statement doesn't evaluate to either true or false:\n"; cout << ecs << endl; halt; } //assert(ec.is_true() || ec.is_false()); if (ec.is_true()) return if_true->execute(env, ie); else if (!if_false.is_null()) return if_false->execute(env, ie); else return NextAction(NextAction::continue_normal_execution); }
void CSuperMove::Update() { if (!gMap) { return /*Clear()*/; } if (m_bHungUp) { if (!gHero->IsMoving()) { m_bHungUp = false; StartMove(m_pPath, m_nErrorDistance); } return; } if (!gHero->IsTransfering() && !m_bOver && !m_bPause) { if ((*m_itCurAction)->CheckFailed()) { return Clear(); } if ((*m_itCurAction)->CheckDone()) { if (!HasNextAction()) { Over(); } else if (nFrameCounter++ == 5) { NextAction(); nFrameCounter = 0; } } } }
NextAction ReturnStmt::execute(Env &env, LocalDefs &ie) { Term val = expr.evaluate(env, ie); return NextAction(val); }
NextAction NullStatement::execute(Env &env, LocalDefs &ie) { return NextAction(NextAction::continue_normal_execution); }
NextAction BreakStmt::execute(Env &env, LocalDefs &ie) { return NextAction(NextAction::break_inner_loop); }
NextAction ForStatement::execute(Env &env, LocalDefs &ie) { if (src_expr.is_null()) { assert(idx_var.is_null()); assert(!start_expr.is_null()); assert(!end_expr.is_null()); Term start_obj = start_expr.evaluate(env, ie); Term end_obj = end_expr.evaluate(env, ie); if (start_obj.is_int() && end_obj.is_int()) // && start_obj.get_int() <= end_obj.get_int()) { int start = start_obj.get_int(); int end = end_obj.get_int(); //assert(start <= end); for (int i=start ; i <= end ; i++) { env.set(var, int_obj(i)); NextAction res = body->execute(env, ie); env.unset(var); if (res.is_return()) return res; if (res.is_break()) return NextAction(NextAction::continue_normal_execution); } return NextAction(NextAction::continue_normal_execution); } cout << "Invalid range in for loop or sequence comprehension\n"; cout << start_obj.to_string(true) << endl; cout << end_obj.to_string(true) << endl; Program::get_singleton().print_stack(); halt; } else { assert(start_expr.is_null()); assert(end_expr.is_null()); Term src = src_expr.evaluate(env, ie); int len = src.size(); for (int i=0 ; i < len ; i++) { env.set(var, src.item(i)); if (idx_var != PlainId()) env.set(idx_var, int_obj(i)); NextAction res = body->execute(env, ie); env.unset(var); if (idx_var != PlainId()) env.unset(idx_var); if (res.is_return()) return res; if (res.is_break()) return NextAction(NextAction::continue_normal_execution); } } return NextAction(NextAction::continue_normal_execution); }