//******************** void main_LineEdit(){ SeqStack S; char ch; DataType e; DataType a[50]; int i,j=0; InitStack(&S); printf("输入字符序列(#表示前一个字符无效,@表示当前行字符无效).\n"); ch=getchar(); while(ch!='\n'){ switch(ch){ case '#': if(!StackEmpty(S)) PopStack(&S,&ch); break; case '@': ClearStack(&S); break; default: PushStack(&S,ch); } ch=getchar(); } while(!StackEmpty(S)){ PopStack(&S,&e); a[j++]=e; } for(i=j-1;i>=0;i--) printf("%c",a[i]); printf("\n"); ClearStack(&S); system("pause"); }
void main() { // 初始化节点栈 for(int i = 0; i < LEN; i++) NodeStack[i] = NULL; for(int i = 0; i < LEN; i++) { // 如果遇到的是数字 // 不能使用Expr[i] != '-' || Expr[i] != '+'来识别除了-+以外的字符 // 因为当字符为 '-' 时,前一条规则不满足但后一条满足,所以整个表达式还是返回true // '+'同上 if(Expr[i] == '-' || Expr[i] == '+') { // 以下则是处理 + - 的情况 // 创建一个符号节点 PtrToNode newnode = CreateNewNode(Expr[i]); newnode->Right = PopStack(); newnode->Left = PopStack(); PushStack(newnode); } else // 将非运算符的的字符入栈 PushStack(CreateNewNode(Expr[i])); } // 输出结果 // 使用后序遍历,遍历二叉树 PrintBinaryTree(NodeStack[0]); }
//******************** void main_SeqStack(){ SeqStack S; int i; DataType a[]={'a','b','c','d','e'}; DataType e; InitStack(&S); for(i=0;i<sizeof(a)/sizeof(a[0]);i++) { if(PushStack(&S,a[i])==0) { printf("栈已满,不能进栈!"); return; } } printf("出栈的元素是:"); if(PopStack(&S,&e)==1) printf("%4c",e); if(PopStack(&S,&e)==1) printf("%4c",e); printf("\n"); printf("当前栈顶的元素是:"); if(GetTop(S,&e)==0) { printf("栈已空!"); return; } else printf("%4c\n",e); if(PushStack(&S,'f')==0) { printf("栈已满,不能进栈!"); return; } if(PushStack(&S,'g')==0) { printf("栈已满,不能进栈!"); return; } printf("当前栈中的元素个数是:%d\n",StackLength(S)); printf("元素出栈的序列是:"); while(!StackEmpty(S)) { PopStack(&S,&e); printf("%4c",e); } printf("\n"); system("pause"); }
BOOL CDirFileEnum::NextFile(CString &sResult, bool* pbIsDirectory) { if (m_bIsNew) { // Special-case first time - haven't found anything yet, // so don't do recurse-into-directory check. m_bIsNew = FALSE; } else if (m_seStack && m_seStack->IsDirectory()) { PushStack(m_seStack->GetFilePath()); } while (m_seStack && !m_seStack->FindNextFileNoDots()) { // No more files in this directory, try parent. PopStack(); } if (m_seStack) { sResult = m_seStack->GetFilePath(); if(pbIsDirectory != NULL) { *pbIsDirectory = m_seStack->IsDirectory(); } return TRUE; } else { return FALSE; } }
CDirFileEnum::~CDirFileEnum() { while (m_seStack) { PopStack(); } }
EFI_STATUS PopExpression ( OUT EFI_HII_VALUE *Value ) /*++ Routine Description: Pop an Expression value from the stack. Arguments: Value - Expression value to pop. Returns: EFI_SUCCESS - The value was popped onto the stack. EFI_ACCESS_DENIED - The pop operation underflowed the stack --*/ { return PopStack ( &mExpressionEvaluationStack, &mExpressionEvaluationStackPointer, &mExpressionEvaluationStackEnd, Value ); }
EFI_STATUS PopScope ( OUT UINT8 *Operand ) /*++ Routine Description: Pop an Operand from the Stack Arguments: Operand - Operand to pop. Returns: EFI_SUCCESS - The value was pushed onto the stack. EFI_OUT_OF_RESOURCES - There is not enough system memory to grow the stack. --*/ { EFI_STATUS Status; EFI_HII_VALUE Data; Status = PopStack ( &mOpCodeScopeStack, &mOpCodeScopeStackPointer, &mOpCodeScopeStackEnd, &Data ); *Operand = Data.Value.u8; return Status; }
void OpPOP::Execute() { auto cu = Environment::get().GetCU(); uint16_t ddata = cu->PopStack(); cu->SetOperandData(0, ddata); }
D_MOBILE *load_player(char *player) { D_MOBILE *dMob = NULL; char sql[MAX_BUFFER]; char pName[MAX_BUFFER]; sqlite3_stmt *rSet = NULL; int i, size; memset(sql, '\0', MAX_BUFFER); pName[0] = toupper(player[0]); size = strlen(player); for (i = 1; i < size && i < MAX_BUFFER - 1; i++) pName[i] = tolower(player[i]); pName[i] = '\0'; /* prepare sql to query player table */ snprintf(sql, MAX_BUFFER, "select * from players where name = ?"); sqlite3_prepare_v2(db, sql, sizeof(sql), &rSet, NULL); sqlite3_bind_text(rSet, 1, pName, strlen(pName), 0); /* execute query and return NULL if player isn't found*/ if (sqlite3_step(rSet) != SQLITE_ROW) { sqlite3_reset(rSet); sqlite3_finalize(rSet); return NULL; } /* create new mobile data */ if (StackSize(dmobile_free) <= 0) { if ((dMob = malloc(sizeof(*dMob))) == NULL) { bug("Load_player: Cannot allocate memory."); abort(); } } else { dMob = (D_MOBILE *) PopStack(dmobile_free); } clear_mobile(dMob); /* load data */ dMob->name = strdup((const char *)sqlite3_column_text(rSet,3)); dMob->password = strdup((const char *)sqlite3_column_text(rSet,4)); dMob->level = sqlite3_column_int(rSet,2); dMob->room = find_room(sqlite3_column_int(rSet,0)); /* clear result set */ sqlite3_reset(rSet); sqlite3_finalize(rSet); if (dMob->room == NULL) dMob->room = find_room(START_ROOM); return dMob; }
void PopScope(CompileInstance &inst) { if (inst.scopes.GetSize() <= 0) { return; } Scope &scope = inst.scopes.GetLast()->GetItem(); PopStack(inst, scope.size); inst.scopes.RemoveLast(); }
bool EvalLuaExpression(lua_State *pLuaState, string expression) { if (luaL_dostring(pLuaState, STR("return " + expression)) != 0) { Variant v; PopStack(pLuaState, v); FATAL("Unable to evaluate expression %s\n%s", STR(expression), STR(v.ToString())); return false; } return true; }
int main() { stack s; int temp=0; InitStack(s); printf("s.stackSize = %d\n",s.stackSize); int num1=10; PushStack(s,num1); int num2=11; PushStack(s,num2); PopStack(s,temp); printf("temp = %d\n",temp); PopStack(s,temp); printf("temp = %d\n",temp); return 0; }
int BaseVMLua::GetFunctionReference(string path) { if (luaL_dostring(_pGlobalState, STR("return " + path)) != 0) { Variant v; PopStack(_pGlobalState, v); FATAL("Unable to get path %s\n%s", STR(path), STR(v.ToString())); return 0; } if (lua_type(_pGlobalState, -1) != LUA_TFUNCTION) { FATAL("Path %s is not a lua function", STR(path)); lua_pop(_pGlobalState, 1); return 0; } int result = luaL_ref(_pGlobalState, LUA_REGISTRYINDEX); if (result < 0) { Variant v; PopStack(_pGlobalState, v); FATAL("Unable to get reference\n%s", STR(v.ToString())); return 0; } return result; }
void CInputManager::UnRegisterKeyBoardCallback( SKeyTriggerType type, const Function<void(void)>& function) { WORD id = type.GetUniqueId(); TCallbackMap::iterator iter = m_callBacks.find(id); BEATS_ASSERT(iter != m_callBacks.end(), _T("Can't Unregister a call back before register it!")); iter->second->Disconnect(function); TCallbackStack::iterator stackIter = m_stack.find(id); if (stackIter != m_stack.end() && iter->second->GetConnectedCount() == 0) { BEATS_SAFE_DELETE(iter->second); PopStack(id); } }
//*************************************************************** int StackDump ( MyStack* Stack ) { freopen ( "dump.log", "a", stdout ); time_t RawTime = time ( NULL ); printf ( "\n\n$$$$$ Date: %s \n", ctime ( &RawTime ) ); int IsOutStack = 0; switch ( errno ) { case EINVAL: printf ( "-----> Stack head no valid! \n\r" ); break; case ESTCKOVRFLW: printf ( "-----> Stack overflow \n\r" ); break; case EAGAIN: printf ( "-----> Stack data address no valid \n\r" ); break; case EFAULT: printf ( "-----> Stack address no valid \n\r" ); break; case EDOM: printf ( "-----> Division by zero \n\r" ); IsOutStack = 1; break; case ENOMEM: printf ( "-----> No memory for expansion stack or no memory for create \n\r" ); IsOutStack = 1; break; default: printf ( "-----> Unknown error \n\r" ); IsOutStack = 1; } if ( IsOutStack ) { printf ( "The contents of the stack at address 0x%p:\n", Stack->Data ); if ( Stack->Head == -1 ) { printf ( " NO DATA " ); } while ( Stack->Head != -1 ) { printf ( "%lg ", PopStack ( Stack ) ); } } printf ( "\n************************************************************************ " ); fclose ( stdout ); errno = 0; return 0; }
int main(void) { STACK s; char element[NUM] = { 0 }; char buffer; int i; InitStack(&s); printf("input brackets:\n"); fscanf(stdin, "%s", element); for (i = 0; element[i] != 0; i++) { switch (element[i]) { case '(': case '[': case '{': case '<': PushStack(&s, element[i]); break; case ')': case ']': case '}': case '>': default: if (IsEmpty(&s)) { printf("\nnot match\n"); return 0; } else { if (MatchBracket(s.array[s.top], element[i])) PopStack(&s, &buffer); else { printf("\nnot match\n"); return 0; } } } } if (IsEmpty(&s)) { printf("\nleft and right brackets are matched"); } else { printf("\nnot match"); } printf("\n"); return 0; }
/* function :: alloc_event() * arguments :: none * ====================================================== * This function allocates memory for an event, and * makes sure it's values are set to default. */ EVENT_DATA *alloc_event() { EVENT_DATA *event; if (StackSize(event_free) <= 0) event = malloc(sizeof(*event)); else event = (EVENT_DATA *) PopStack(event_free); /* clear the event */ event->fun = NULL; event->argument = NULL; event->owner.dMob = NULL; /* only need to NULL one of the union members */ event->passes = 0; event->bucket = 0; event->ownertype = EVENT_UNOWNED; event->type = EVENT_NONE; /* return the allocated and cleared event */ return event; }
void rbBytecode::Parse() { wxLogMessage(wxT("")); // Initialize stack // parse until end-script marker Root = new rbToken(NULL,-1,wxT("ROOT"),wxT("ROOT")); PushIndent(); PrintOutput(wxT("{\n")); PushStack(Root); while( true ) { dword token = LoadToken(); if( token == 0x53 ) break; } PopStack(); PopIndent(); //ScriptText.RemoveLast(); // remove tab PrintOutput( wxT("}\n") ); }
void TranslateExpress(char str[],char exp[]){ SeqStack S; char ch; DataType e; int i = 0; int j = 0; InitStack(&S); ch = str[i]; i++; while(ch != '\0'){ switch(ch){ case '(' : PushStack(&S,ch); break; case ')': while(GetTop(S,&e) && e!= '('){ PopStack(&S,&e); exp[j] = e; j++; exp[j] = ' '; j++; } PopStack(&S,&e); break; case '+': case '-': while(!StackEmpty(S) && GetTop(S,&e) && e!='('){ PopStack(&S,&e); exp[j] = e; j++; exp[j] = ' '; j++; } PushStack(&S,ch); break; case '*': case '/': while((!StackEmpty(S) && GetTop(S,&e)) && (e == '/' || e == '*')){ PopStack(&S,&e); exp[j] = e; j++; exp[j] = ' '; j++; } PushStack(&S,ch); break; case ' ': break; default: while(ch >= '0' && ch <= '9'){ exp[j] = ch; j++; ch = str[i]; i++; } i--; exp[j] = ' '; j++; } ch = str[i]; i++; } while(!StackEmpty(S)){ PopStack(&S,&e); exp[j] = e; j++; exp[j] = ' '; j++; } exp[j] = '\0'; }
void rbBytecode::ParseFunc( dword token ) { rbToken* t = new rbToken(NULL,token); wxString& name = t->Name; wxString& output = t->Output; wxString code; dword flags = 0; try{ //wxLogMessage( wxT("%sFUNC %x"), GetPrefix(), dword(token) ); PrintPreOutput(t); switch( token ) { case 0x0070: // $ { RB_TOKEN_CODE("29A001000029A10100000B53"); RB_TOKEN_NAME("$"); flags=0x00023401; break; } case 0x0071: // GotoState { RB_TOKEN_CODE("299D000000299E000000299F00000029A00000000B53"); RB_TOKEN_NAME("GotoState"); flags=0x00020401; break; } case 0x0072: // == { RB_TOKEN_CODE("293B010000293C0100000B53"); RB_TOKEN_NAME("=="); flags=0x00023401; break; } case 0x0073: // < { RB_TOKEN_CODE("299801000029990100000B53"); RB_TOKEN_NAME("<"); flags=0x00023401; break; } case 0x0074: // > { RB_TOKEN_CODE("299401000029950100000B53"); RB_TOKEN_NAME(">"); flags=0x00023401; break; } case 0x0075: // Enable { RB_TOKEN_CODE("29830000000B53"); RB_TOKEN_NAME("Enable"); flags=0x00020401; break; } case 0x0076: // Disable { RB_TOKEN_CODE("29810000000B53"); RB_TOKEN_NAME("Disable"); flags=0x00020401; break; } case 0x0077: // != { RB_TOKEN_CODE("293701000029380100000B53"); RB_TOKEN_NAME("!="); flags=0x00023401; break; } case 0x0078: // <= { RB_TOKEN_CODE("299001000029910100000B53"); RB_TOKEN_NAME("<="); flags=0x00023401; break; } case 0x0079: // >= { RB_TOKEN_CODE("298C010000298D0100000B53"); RB_TOKEN_NAME(">="); flags=0x00023401; break; } case 0x007A: // == { RB_TOKEN_CODE("298801000029890100000B53"); RB_TOKEN_NAME("=="); flags=0x00023401; break; } case 0x007B: // != { RB_TOKEN_CODE("298401000029850100000B53"); RB_TOKEN_NAME("!="); flags=0x00023401; break; } case 0x007C: // ~= { RB_TOKEN_CODE("298001000029810100000B53"); RB_TOKEN_NAME("~="); flags=0x00023401; break; } case 0x007D: // Len { RB_TOKEN_CODE("29730100000B53"); RB_TOKEN_NAME("Len"); flags=0x00022401; break; } case 0x007E: // InStr { RB_TOKEN_CODE("296F01000029700100000B53"); RB_TOKEN_NAME("InStr"); flags=0x00022401; break; } case 0x007F: // Mid { RB_TOKEN_CODE("296A010000296B010000296C0100000B53"); RB_TOKEN_NAME("Mid"); flags=0x00022401; break; } case 0x0080: // Left { RB_TOKEN_CODE("296601000029670100000B53"); RB_TOKEN_NAME("Left"); flags=0x00022401; break; } case 0x0081: // ! { RB_TOKEN_CODE("29B70300000B53"); RB_TOKEN_NAME("!"); flags=0x00023411; break; } case 0x0082: // && { RB_TOKEN_CODE("29AB03000029AC0300000B53"); RB_TOKEN_NAME("&&"); flags=0x00023401; break; } case 0x0083: // ^^ { RB_TOKEN_CODE("29A703000029A80300000B53"); RB_TOKEN_NAME("^^"); flags=0x00023401; break; } case 0x0084: // || { RB_TOKEN_CODE("29A303000029A40300000B53"); RB_TOKEN_NAME("||"); flags=0x00023401; break; } case 0x0085: // *= { RB_TOKEN_CODE("299F03000029A00300000B53"); RB_TOKEN_NAME("*="); flags=0x00423401; break; } case 0x0086: // /= { RB_TOKEN_CODE("299B030000299C0300000B53"); RB_TOKEN_NAME("/="); flags=0x00423401; break; } case 0x0087: // += { RB_TOKEN_CODE("299703000029980300000B53"); RB_TOKEN_NAME("+="); flags=0x00423401; break; } case 0x0088: // -= { RB_TOKEN_CODE("299303000029940300000B53"); RB_TOKEN_NAME("-="); flags=0x00423401; break; } case 0x0089: // ++ { RB_TOKEN_CODE("29900300000B53"); RB_TOKEN_NAME("++"); flags=0x00423411; break; } case 0x008A: // -- { RB_TOKEN_CODE("298D0300000B53"); RB_TOKEN_NAME("--"); flags=0x00423411; break; } case 0x008B: // ++ { RB_TOKEN_CODE("298A0300000B53"); RB_TOKEN_NAME("++"); flags=0x00423401; break; } case 0x008C: // -- { RB_TOKEN_CODE("29870300000B53"); RB_TOKEN_NAME("--"); flags=0x00423401; break; } case 0x008D: // ~ { RB_TOKEN_CODE("29840300000B53"); RB_TOKEN_NAME("~"); flags=0x00023411; break; } case 0x008E: // == { RB_TOKEN_CODE("290D020000290E0200000B53"); RB_TOKEN_NAME("=="); flags=0x00023401; break; } case 0x008F: // - { RB_TOKEN_CODE("29810300000B53"); RB_TOKEN_NAME("-"); flags=0x00023411; break; } case 0x0090: // * { RB_TOKEN_CODE("297D030000297E0300000B53"); RB_TOKEN_NAME("*"); flags=0x00023401; break; } case 0x0091: // / { RB_TOKEN_CODE("2979030000297A0300000B53"); RB_TOKEN_NAME("/"); flags=0x00023401; break; } case 0x0092: // + { RB_TOKEN_CODE("297503000029760300000B53"); RB_TOKEN_NAME("+"); flags=0x00023401; break; } case 0x0093: // - { RB_TOKEN_CODE("297103000029720300000B53"); RB_TOKEN_NAME("-"); flags=0x00023401; break; } case 0x0094: // << { RB_TOKEN_CODE("296D030000296E0300000B53"); RB_TOKEN_NAME("<<"); flags=0x00023401; break; } case 0x0095: // >> { RB_TOKEN_CODE("2969030000296A0300000B53"); RB_TOKEN_NAME(">>"); flags=0x00023401; break; } case 0x0096: // < { RB_TOKEN_CODE("296103000029620300000B53"); RB_TOKEN_NAME("<"); flags=0x00023401; break; } case 0x0097: // > { RB_TOKEN_CODE("295D030000295E0300000B53"); RB_TOKEN_NAME(">"); flags=0x00023401; break; } case 0x0098: // <= { RB_TOKEN_CODE("2959030000295A0300000B53"); RB_TOKEN_NAME("<="); flags=0x00023401; break; } case 0x0099: // >= { RB_TOKEN_CODE("295503000029560300000B53"); RB_TOKEN_NAME(">="); flags=0x00023401; break; } case 0x009A: // == { RB_TOKEN_CODE("295103000029520300000B53"); RB_TOKEN_NAME("=="); flags=0x00023401; break; } case 0x009B: // != { RB_TOKEN_CODE("294D030000294E0300000B53"); RB_TOKEN_NAME("!="); flags=0x00023401; break; } case 0x009C: // & { RB_TOKEN_CODE("2949030000294A0300000B53"); RB_TOKEN_NAME("&"); flags=0x00023401; break; } case 0x009D: // ^ { RB_TOKEN_CODE("294503000029460300000B53"); RB_TOKEN_NAME("^"); flags=0x00023401; break; } case 0x009E: // | { RB_TOKEN_CODE("294103000029420300000B53"); RB_TOKEN_NAME("|"); flags=0x00023401; break; } case 0x009F: // *= { RB_TOKEN_CODE("293D030000293E0300000B53"); RB_TOKEN_NAME("*="); flags=0x00423401; break; } case 0x00A0: // /= { RB_TOKEN_CODE("2939030000293A0300000B53"); RB_TOKEN_NAME("/="); flags=0x00423401; break; } case 0x00A1: // += { RB_TOKEN_CODE("293503000029360300000B53"); RB_TOKEN_NAME("+="); flags=0x00423401; break; } case 0x00A2: // -= { RB_TOKEN_CODE("293103000029320300000B53"); RB_TOKEN_NAME("-="); flags=0x00423401; break; } case 0x00A3: // ++ { RB_TOKEN_CODE("292E0300000B53"); RB_TOKEN_NAME("++"); flags=0x00423411; break; } case 0x00A4: // -- { RB_TOKEN_CODE("292B0300000B53"); RB_TOKEN_NAME("--"); flags=0x00423411; break; } case 0x00A5: // ++ { RB_TOKEN_CODE("29280300000B53"); RB_TOKEN_NAME("++"); flags=0x00423401; break; } case 0x00A6: // -- { RB_TOKEN_CODE("29250300000B53"); RB_TOKEN_NAME("--"); flags=0x00423401; break; } case 0x00A7: // Rand { RB_TOKEN_CODE("29220300000B53"); RB_TOKEN_NAME("Rand"); flags=0x00022401; break; } case 0x00A8: // @ { RB_TOKEN_CODE("299C010000299D0100000B53"); RB_TOKEN_NAME("@"); flags=0x00023401; break; } case 0x00A9: // - { RB_TOKEN_CODE("29120300000B53"); RB_TOKEN_NAME("-"); flags=0x00023411; break; } case 0x00AA: // ** { RB_TOKEN_CODE("290E030000290F0300000B53"); RB_TOKEN_NAME("**"); flags=0x00023401; break; } case 0x00AB: // * { RB_TOKEN_CODE("290A030000290B0300000B53"); RB_TOKEN_NAME("*"); flags=0x00023401; break; } case 0x00AC: // / { RB_TOKEN_CODE("290603000029070300000B53"); RB_TOKEN_NAME("/"); flags=0x00023401; break; } case 0x00AD: // % { RB_TOKEN_CODE("290203000029030300000B53"); RB_TOKEN_NAME("%"); flags=0x00023401; break; } case 0x00AE: // + { RB_TOKEN_CODE("29FE02000029FF0200000B53"); RB_TOKEN_NAME("+"); flags=0x00023401; break; } case 0x00AF: // - { RB_TOKEN_CODE("29FA02000029FB0200000B53"); RB_TOKEN_NAME("-"); flags=0x00023401; break; } case 0x00B0: // < { RB_TOKEN_CODE("29F602000029F70200000B53"); RB_TOKEN_NAME("<"); flags=0x00023401; break; } case 0x00B1: // > { RB_TOKEN_CODE("29F202000029F30200000B53"); RB_TOKEN_NAME(">"); flags=0x00023401; break; } case 0x00B2: // <= { RB_TOKEN_CODE("29EE02000029EF0200000B53"); RB_TOKEN_NAME("<="); flags=0x00023401; break; } case 0x00B3: // >= { RB_TOKEN_CODE("29EA02000029EB0200000B53"); RB_TOKEN_NAME(">="); flags=0x00023401; break; } case 0x00B4: // == { RB_TOKEN_CODE("29E602000029E70200000B53"); RB_TOKEN_NAME("=="); flags=0x00023401; break; } case 0x00B5: // != { RB_TOKEN_CODE("29DE02000029DF0200000B53"); RB_TOKEN_NAME("!="); flags=0x00023401; break; } case 0x00B6: // *= { RB_TOKEN_CODE("29DA02000029DB0200000B53"); RB_TOKEN_NAME("*="); flags=0x00423401; break; } case 0x00B7: // /= { RB_TOKEN_CODE("29D602000029D70200000B53"); RB_TOKEN_NAME("/="); flags=0x00423401; break; } case 0x00B8: // += { RB_TOKEN_CODE("29D202000029D30200000B53"); RB_TOKEN_NAME("+="); flags=0x00423401; break; } case 0x00B9: // -= { RB_TOKEN_CODE("29CE02000029CF0200000B53"); RB_TOKEN_NAME("-="); flags=0x00423401; break; } case 0x00BA: // Abs { RB_TOKEN_CODE("29CB0200000B53"); RB_TOKEN_NAME("Abs"); flags=0x00022401; break; } case 0x00BB: // Sin { RB_TOKEN_CODE("29C80200000B53"); RB_TOKEN_NAME("Sin"); flags=0x00022401; break; } case 0x00BC: // Cos { RB_TOKEN_CODE("29C20200000B53"); RB_TOKEN_NAME("Cos"); flags=0x00022401; break; } case 0x00BD: // Tan { RB_TOKEN_CODE("29BC0200000B53"); RB_TOKEN_NAME("Tan"); flags=0x00022401; break; } case 0x00BE: // Atan { RB_TOKEN_CODE("29B902000029BA0200000B53"); RB_TOKEN_NAME("Atan"); flags=0x00022401; break; } case 0x00BF: // Exp { RB_TOKEN_CODE("29B60200000B53"); RB_TOKEN_NAME("Exp"); flags=0x00022401; break; } case 0x00C0: // Loge { RB_TOKEN_CODE("29B30200000B53"); RB_TOKEN_NAME("Loge"); flags=0x00022401; break; } case 0x00C1: // Sqrt { RB_TOKEN_CODE("29B00200000B53"); RB_TOKEN_NAME("Sqrt"); flags=0x00022401; break; } case 0x00C2: // Square { RB_TOKEN_CODE("29AD0200000B53"); RB_TOKEN_NAME("Square"); flags=0x00022401; break; } case 0x00C3: // FRand { RB_TOKEN_CODE("0B53"); RB_TOKEN_NAME("FRand"); flags=0x00022401; break; } case 0x00C4: // >>> { RB_TOKEN_CODE("296503000029660300000B53"); RB_TOKEN_NAME(">>>"); flags=0x00023401; break; } case 0x00C5: // IsA { RB_TOKEN_CODE("29280100000B53"); RB_TOKEN_NAME("IsA"); flags=0x00020401; break; } case 0x00C9: // Repl { RB_TOKEN_CODE("29500100002951010000295201000029530100000B53"); RB_TOKEN_NAME("Repl"); flags=0x00022401; break; } case 0x00CB: // != { RB_TOKEN_CODE("2909020000290A0200000B53"); RB_TOKEN_NAME("!="); flags=0x00023401; break; } case 0x00D2: // ~= { RB_TOKEN_CODE("29E202000029E30200000B53"); RB_TOKEN_NAME("~="); flags=0x00023401; break; } case 0x00D3: // - { RB_TOKEN_CODE("29800200000B53"); RB_TOKEN_NAME("-"); flags=0x00023411; break; } case 0x00D4: // * { RB_TOKEN_CODE("297D020000297E0200000B53"); RB_TOKEN_NAME("*"); flags=0x00023401; break; } case 0x00D5: // * { RB_TOKEN_CODE("2979020000297A0200000B53"); RB_TOKEN_NAME("*"); flags=0x00023401; break; } case 0x00D6: // / { RB_TOKEN_CODE("297102000029720200000B53"); RB_TOKEN_NAME("/"); flags=0x00023401; break; } case 0x00D7: // + { RB_TOKEN_CODE("296D020000296E0200000B53"); RB_TOKEN_NAME("+"); flags=0x00023401; break; } case 0x00D8: // - { RB_TOKEN_CODE("2969020000296A0200000B53"); RB_TOKEN_NAME("-"); flags=0x00023401; break; } case 0x00D9: // == { RB_TOKEN_CODE("295D020000295E0200000B53"); RB_TOKEN_NAME("=="); flags=0x00023401; break; } case 0x00DA: // != { RB_TOKEN_CODE("2959020000295A0200000B53"); RB_TOKEN_NAME("!="); flags=0x00023401; break; } case 0x00DB: // Dot { RB_TOKEN_CODE("295502000029560200000B53"); RB_TOKEN_NAME("Dot"); flags=0x00023401; break; } case 0x00DC: // Cross { RB_TOKEN_CODE("295102000029520200000B53"); RB_TOKEN_NAME("Cross"); flags=0x00023401; break; } case 0x00DD: // *= { RB_TOKEN_CODE("294D020000294E0200000B53"); RB_TOKEN_NAME("*="); flags=0x00423401; break; } case 0x00DE: // /= { RB_TOKEN_CODE("294502000029460200000B53"); RB_TOKEN_NAME("/="); flags=0x00423401; break; } case 0x00DF: // += { RB_TOKEN_CODE("294102000029420200000B53"); RB_TOKEN_NAME("+="); flags=0x00423401; break; } case 0x00E0: // -= { RB_TOKEN_CODE("293D020000293E0200000B53"); RB_TOKEN_NAME("-="); flags=0x00423401; break; } case 0x00E1: // VSize { RB_TOKEN_CODE("293A0200000B53"); RB_TOKEN_NAME("VSize"); flags=0x00022401; break; } case 0x00E2: // Normal { RB_TOKEN_CODE("292E0200000B53"); RB_TOKEN_NAME("Normal"); flags=0x00022401; break; } case 0x00E5: // GetAxes { RB_TOKEN_CODE("29DC01000029DD01000029DE01000029DF0100000B53"); RB_TOKEN_NAME("GetAxes"); flags=0x00422401; break; } case 0x00E6: // GetUnAxes { RB_TOKEN_CODE("29D701000029D801000029D901000029DA0100000B53"); RB_TOKEN_NAME("GetUnAxes"); flags=0x00422401; break; } case 0x00E7: // LogInternal { RB_TOKEN_CODE("29AC00000029AD0000000B53"); RB_TOKEN_NAME("LogInternal"); flags=0x00022401; break; } case 0x00E8: // WarnInternal { RB_TOKEN_CODE("29AA0000000B53"); RB_TOKEN_NAME("WarnInternal"); flags=0x00022401; break; } case 0x00EA: // Right { RB_TOKEN_CODE("296201000029630100000B53"); RB_TOKEN_NAME("Right"); flags=0x00022401; break; } case 0x00EB: // Caps { RB_TOKEN_CODE("295F0100000B53"); RB_TOKEN_NAME("Caps"); flags=0x00022401; break; } case 0x00EC: // Chr { RB_TOKEN_CODE("29590100000B53"); RB_TOKEN_NAME("Chr"); flags=0x00022401; break; } case 0x00ED: // Asc { RB_TOKEN_CODE("29560100000B53"); RB_TOKEN_NAME("Asc"); flags=0x00022401; break; } case 0x00EE: // Locs { RB_TOKEN_CODE("295C0100000B53"); RB_TOKEN_NAME("Locs"); flags=0x00022401; break; } case 0x00F2: // == { RB_TOKEN_CODE("29B303000029B40300000B53"); RB_TOKEN_NAME("=="); flags=0x00023401; break; } case 0x00F3: // != { RB_TOKEN_CODE("29AF03000029B00300000B53"); RB_TOKEN_NAME("!="); flags=0x00023401; break; } case 0x00F4: // FMin { RB_TOKEN_CODE("29A702000029A80200000B53"); RB_TOKEN_NAME("FMin"); flags=0x00022401; break; } case 0x00F5: // FMax { RB_TOKEN_CODE("29A302000029A40200000B53"); RB_TOKEN_NAME("FMax"); flags=0x00022401; break; } case 0x00F6: // FClamp { RB_TOKEN_CODE("299E020000299F02000029A00200000B53"); RB_TOKEN_NAME("FClamp"); flags=0x00022401; break; } case 0x00F7: // Lerp { RB_TOKEN_CODE("2999020000299A020000299B0200000B53"); RB_TOKEN_NAME("Lerp"); flags=0x00022401; break; } case 0x00F9: // Min { RB_TOKEN_CODE("291E030000291F0300000B53"); RB_TOKEN_NAME("Min"); flags=0x00022401; break; } case 0x00FA: // Max { RB_TOKEN_CODE("291A030000291B0300000B53"); RB_TOKEN_NAME("Max"); flags=0x00022401; break; } case 0x00FB: // Clamp { RB_TOKEN_CODE("2915030000291603000029170300000B53"); RB_TOKEN_NAME("Clamp"); flags=0x00022401; break; } case 0x00FC: // VRand { RB_TOKEN_CODE("0B53"); RB_TOKEN_NAME("VRand"); flags=0x00022401; break; } case 0x00FE: // == { RB_TOKEN_CODE("292401000029250100000B53"); RB_TOKEN_NAME("=="); flags=0x00023401; break; } case 0x00FF: // != { RB_TOKEN_CODE("292001000029210100000B53"); RB_TOKEN_NAME("!="); flags=0x00023401; break; } case 0x0100: // Sleep { RB_TOKEN_CODE("294C0D00000B53"); RB_TOKEN_NAME("Sleep"); flags=0x00020409; break; } case 0x0102: // ClassIsChildOf { RB_TOKEN_CODE("292B010000292C0100000B53"); RB_TOKEN_NAME("ClassIsChildOf"); flags=0x00022401; break; } case 0x0105: // FinishAnim { RB_TOKEN_CODE("294B0D00000B53"); RB_TOKEN_NAME("FinishAnim"); flags=0x00020409; break; } case 0x0106: // SetCollision { RB_TOKEN_CODE("29470D000029480D000029490D00000B53"); RB_TOKEN_NAME("SetCollision"); flags=0x00020401; break; } case 0x010A: // Move { RB_TOKEN_CODE("293D0D00000B53"); RB_TOKEN_NAME("Move"); flags=0x00020401; break; } case 0x010B: // SetLocation { RB_TOKEN_CODE("293A0D00000B53"); RB_TOKEN_NAME("SetLocation"); flags=0x00020401; break; } case 0x010E: // + { RB_TOKEN_CODE("29F900000029FA0000000B53"); RB_TOKEN_NAME("+"); flags=0x00023401; break; } case 0x010F: // - { RB_TOKEN_CODE("29F000000029F10000000B53"); RB_TOKEN_NAME("-"); flags=0x00023401; break; } case 0x0110: // SetOwner { RB_TOKEN_CODE("29230D00000B53"); RB_TOKEN_NAME("SetOwner"); flags=0x00020401; break; } case 0x0113: // << { RB_TOKEN_CODE("296502000029660200000B53"); RB_TOKEN_NAME("<<"); flags=0x00023401; break; } case 0x0114: // >> { RB_TOKEN_CODE("296102000029620200000B53"); RB_TOKEN_NAME(">>"); flags=0x00023401; break; } case 0x0115: // Trace { RB_TOKEN_CODE("29940C000029950C000029960C000029970C000029980C000029990C0000299A0C0000299B0C00000B53"); RB_TOKEN_NAME("Trace"); flags=0x00420401; break; } case 0x0116: // Spawn { RB_TOKEN_CODE("29730C000029740C000029750C000029760C000029770C000029780C000029790C00000B53"); RB_TOKEN_NAME("Spawn"); flags=0x00020401; break; } case 0x0117: // Destroy { RB_TOKEN_CODE("0B53"); RB_TOKEN_NAME("Destroy"); flags=0x00020401; break; } case 0x0118: // SetTimer { RB_TOKEN_CODE("296B0C0000296C0C0000296D0C0000296E0C00000B53"); RB_TOKEN_NAME("SetTimer"); flags=0x00020401; break; } case 0x0119: // IsInState { RB_TOKEN_CODE("2999000000299A0000000B53"); RB_TOKEN_NAME("IsInState"); flags=0x00020401; break; } case 0x011B: // SetCollisionSize { RB_TOKEN_CODE("29440D000029450D00000B53"); RB_TOKEN_NAME("SetCollisionSize"); flags=0x00020401; break; } case 0x011C: // GetStateName { RB_TOKEN_CODE("0B53"); RB_TOKEN_NAME("GetStateName"); flags=0x00020401; break; } case 0x011F: // * { RB_TOKEN_CODE("290502000029060200000B53"); RB_TOKEN_NAME("*"); flags=0x00023401; break; } case 0x0120: // * { RB_TOKEN_CODE("290102000029020200000B53"); RB_TOKEN_NAME("*"); flags=0x00023401; break; } case 0x0121: // / { RB_TOKEN_CODE("29FD01000029FE0100000B53"); RB_TOKEN_NAME("/"); flags=0x00023401; break; } case 0x0122: // *= { RB_TOKEN_CODE("29F901000029FA0100000B53"); RB_TOKEN_NAME("*="); flags=0x00423401; break; } case 0x0123: // /= { RB_TOKEN_CODE("29F501000029F60100000B53"); RB_TOKEN_NAME("/="); flags=0x00423401; break; } case 0x0128: // * { RB_TOKEN_CODE("297502000029760200000B53"); RB_TOKEN_NAME("*"); flags=0x00023401; break; } case 0x0129: // *= { RB_TOKEN_CODE("2949020000294A0200000B53"); RB_TOKEN_NAME("*="); flags=0x00423401; break; } case 0x012A: // SetBase { RB_TOKEN_CODE("29250D000029260D000029270D000029280D00000B53"); RB_TOKEN_NAME("SetBase"); flags=0x00020401; break; } case 0x012B: // SetRotation { RB_TOKEN_CODE("29370D00000B53"); RB_TOKEN_NAME("SetRotation"); flags=0x00020401; break; } case 0x012C: // MirrorVectorByNormal { RB_TOKEN_CODE("291E020000291F0200000B53"); RB_TOKEN_NAME("MirrorVectorByNormal"); flags=0x00022401; break; } case 0x0130: // AllActors { RB_TOKEN_CODE("29360C000029370C00000B53"); RB_TOKEN_NAME("AllActors"); flags=0x00420405; break; } case 0x0131: // ChildActors { RB_TOKEN_CODE("29300C000029310C00000B53"); RB_TOKEN_NAME("ChildActors"); flags=0x00420405; break; } case 0x0132: // BasedActors { RB_TOKEN_CODE("292D0C0000292E0C00000B53"); RB_TOKEN_NAME("BasedActors"); flags=0x00420405; break; } case 0x0133: // TouchingActors { RB_TOKEN_CODE("292A0C0000292B0C00000B53"); RB_TOKEN_NAME("TouchingActors"); flags=0x00420405; break; } case 0x0135: // TraceActors { RB_TOKEN_CODE("29210C000029220C000029230C000029240C000029250C000029260C000029270C000029280C00000B53"); RB_TOKEN_NAME("TraceActors"); flags=0x00420405; break; } case 0x0137: // VisibleActors { RB_TOKEN_CODE("291C0C0000291D0C0000291E0C0000291F0C00000B53"); RB_TOKEN_NAME("VisibleActors"); flags=0x00420405; break; } case 0x0138: // VisibleCollidingActors { RB_TOKEN_CODE("29160C000029170C000029180C000029190C0000291A0C00000B53"); RB_TOKEN_NAME("VisibleCollidingActors"); flags=0x00420405; break; } case 0x0139: // DynamicActors { RB_TOKEN_CODE("29330C000029340C00000B53"); RB_TOKEN_NAME("DynamicActors"); flags=0x00420405; break; } case 0x013C: // + { RB_TOKEN_CODE("29F101000029F20100000B53"); RB_TOKEN_NAME("+"); flags=0x00023401; break; } case 0x013D: // - { RB_TOKEN_CODE("29ED01000029EE0100000B53"); RB_TOKEN_NAME("-"); flags=0x00023401; break; } case 0x013E: // += { RB_TOKEN_CODE("29E901000029EA0100000B53"); RB_TOKEN_NAME("+="); flags=0x00423401; break; } case 0x013F: // -= { RB_TOKEN_CODE("29E501000029E60100000B53"); RB_TOKEN_NAME("-="); flags=0x00423401; break; } case 0x0140: // RotRand { RB_TOKEN_CODE("29D40100000B53"); RB_TOKEN_NAME("RotRand"); flags=0x00022401; break; } case 0x0141: // CollidingActors { RB_TOKEN_CODE("29100C000029110C000029120C000029130C000029140C00000B53"); RB_TOKEN_NAME("CollidingActors"); flags=0x00420405; break; } case 0x0142: // $= { RB_TOKEN_CODE("297D010000297E0100000B53"); RB_TOKEN_NAME("$="); flags=0x00423401; break; } case 0x0143: // @= { RB_TOKEN_CODE("2979010000297A0100000B53"); RB_TOKEN_NAME("@="); flags=0x00423401; break; } case 0x0144: // -= { RB_TOKEN_CODE("297601000029770100000B53"); RB_TOKEN_NAME("-="); flags=0x00423401; break; } case 0x01D0: // StrLen { RB_TOKEN_CODE("29262C000029272C000029282C00000B53"); RB_TOKEN_NAME("StrLen"); flags=0x00420401; break; } case 0x01D1: // DrawText { RB_TOKEN_CODE("291F2C000029202C00000B53"); RB_TOKEN_NAME("DrawText"); flags=0x00020401; break; } case 0x01D2: // DrawTile { RB_TOKEN_CODE("29312C000029322C000029332C000029342C000029352C000029362C000029372C00000B53"); RB_TOKEN_NAME("DrawTile"); flags=0x00020401; break; } case 0x01D5: // DrawTextClipped { RB_TOKEN_CODE("291C2C0000291D2C00000B53"); RB_TOKEN_NAME("DrawTextClipped"); flags=0x00020401; break; } case 0x01D6: // TextSize { RB_TOKEN_CODE("29222C000029232C000029242C00000B53"); RB_TOKEN_NAME("TextSize"); flags=0x00420401; break; } case 0x01F4: // MoveTo { RB_TOKEN_CODE("2916260000291726000029182600000B53"); RB_TOKEN_NAME("MoveTo"); flags=0x00020409; break; } case 0x01F6: // MoveToward { RB_TOKEN_CODE("291026000029112600002912260000291326000029142600000B53"); RB_TOKEN_NAME("MoveToward"); flags=0x00020409; break; } case 0x01FC: // FinishRotation { RB_TOKEN_CODE("0B53"); RB_TOKEN_NAME("FinishRotation"); flags=0x00020409; break; } case 0x0200: // MakeNoise { RB_TOKEN_CODE("294F0C000029500C00000B53"); RB_TOKEN_NAME("MakeNoise"); flags=0x00020401; break; } case 0x0202: // LineOfSightTo { RB_TOKEN_CODE("293326000029342600000B53"); RB_TOKEN_NAME("LineOfSightTo"); flags=0x00020401; break; } case 0x0205: // FindPathToward { RB_TOKEN_CODE("29032600002904260000290526000029062600000B53"); RB_TOKEN_NAME("FindPathToward"); flags=0x00020401; break; } case 0x0206: // FindPathTo { RB_TOKEN_CODE("2909260000290A260000290B2600000B53"); RB_TOKEN_NAME("FindPathTo"); flags=0x00020401; break; } case 0x0208: // ActorReachable { RB_TOKEN_CODE("29EE2500000B53"); RB_TOKEN_NAME("ActorReachable"); flags=0x00020401; break; } case 0x0209: // PointReachable { RB_TOKEN_CODE("29F12500000B53"); RB_TOKEN_NAME("PointReachable"); flags=0x00020401; break; } case 0x020C: // FindStairRotation { RB_TOKEN_CODE("294F2B00000B53"); RB_TOKEN_NAME("FindStairRotation"); flags=0x00020401; break; } case 0x020D: // FindRandomDest { RB_TOKEN_CODE("0B53"); RB_TOKEN_NAME("FindRandomDest"); flags=0x00020401; break; } case 0x020E: // PickWallAdjust { RB_TOKEN_CODE("29E82500000B53"); RB_TOKEN_NAME("PickWallAdjust"); flags=0x00020401; break; } case 0x020F: // WaitForLanding { RB_TOKEN_CODE("29E62500000B53"); RB_TOKEN_NAME("WaitForLanding"); flags=0x00020409; break; } case 0x0213: // PickTarget { RB_TOKEN_CODE("2923260000292426000029252600002926260000292726000029282600000B53"); RB_TOKEN_NAME("PickTarget"); flags=0x00420401; break; } case 0x0214: // PlayerCanSeeMe { RB_TOKEN_CODE("0B53"); RB_TOKEN_NAME("PlayerCanSeeMe"); flags=0x00020401; break; } case 0x0215: // CanSee { RB_TOKEN_CODE("29302600000B53"); RB_TOKEN_NAME("CanSee"); flags=0x00020401; break; } case 0x0218: // SaveConfig { RB_TOKEN_CODE("0B53"); RB_TOKEN_NAME("SaveConfig"); flags=0x00020401; break; } case 0x0219: // CanSeeByPoints { RB_TOKEN_CODE("292B260000292C260000292D2600000B53"); RB_TOKEN_NAME("CanSeeByPoints"); flags=0x00020401; break; } case 0x0222: // UpdateURL { RB_TOKEN_CODE("29642B000029652B000029662B00000B53"); RB_TOKEN_NAME("UpdateURL"); flags=0x00020401; break; } case 0x0223: // GetURLMap { RB_TOKEN_CODE("0B53"); RB_TOKEN_NAME("GetURLMap"); flags=0x00020401; break; } case 0x0224: // FastTrace { RB_TOKEN_CODE("29860C000029870C000029880C00000B53"); RB_TOKEN_NAME("FastTrace"); flags=0x00020401; break; } case 0x05DC: // ProjectOnTo { RB_TOKEN_CODE("291A020000291B0200000B53"); RB_TOKEN_NAME("ProjectOnTo"); flags=0x00022401; break; } case 0x05DD: // IsZero { RB_TOKEN_CODE("29170200000B53"); RB_TOKEN_NAME("IsZero"); flags=0x00022401; break; } case 0x0F81: // MoveSmooth { RB_TOKEN_CODE("292D0D00000B53"); RB_TOKEN_NAME("MoveSmooth"); flags=0x00020401; break; } case 0x0F82: // SetPhysics { RB_TOKEN_CODE("29E20C00000B53"); RB_TOKEN_NAME("SetPhysics"); flags=0x00020401; break; } case 0x0F83: // AutonomousPhysics { RB_TOKEN_CODE("292C0D00000B53"); RB_TOKEN_NAME("AutonomousPhysics"); flags=0x00020401; break; } default: { throw upexception(wxString::Format(wxT("Unknown Function Token %x at %s"),dword(token),Arc.DebugInfo().c_str())); } } output = name; AddToken(t); PushStack(t); if( rbHasFlag(flags,0x1000) ) { if( rbHasFlag(flags,0x10) ) { // preoperator //wxLogMessage( wxT("%x %x preoperator"),token,flags); output = name; PrintOutput(output); for( dword x=0; x!=0xFF; ++x ) if( LoadToken() == 0x16 ) break; } else { // post/operator //wxLogMessage( wxT("%x %x post/operator"),token,flags); output = wxString::Format( wxT(" %s "), PF_SAFESTR(name) ); for( dword x=0; x!=0xFF; ++x ) { if( LoadToken() == 0x16 ) break; if( x == 0 ) { PrintOutput(output); } } } } else { output = wxString::Format( wxT("%s"), PF_SAFESTR(name) ); ParseAndOutputFunction( output ); } PopStack(); PrintPostOutput(t); /* static final preoperator byte #(byte a){return a;} // 00000000000000100011000000010010 static final postoperator byte #(byte a){return a;} // 00000000000000100011000000000011 static final operator(1) byte #(byte a, byte b){return a;} // 00000000000000100011000000000011 // 0072 == // 00000000000000100011010000000001 // 00000000000000000001000000000000 FUNC_Operator = 0x00001000, // Operator function. FUNC_PreOperator = 0x00000010, // Unary operator is a prefix operator. FUNC_Final = 0x00000001, // Function is final (prebindable, non-overridable function). FUNC_Defined = 0x00000002, // Function has been defined (not just declared). FUNC_Iterator = 0x00000004, // Function is an iterator. FUNC_Latent = 0x00000008, // Function is a latent state function. FUNC_Singular = 0x00000020, // Function cannot be reentered. FUNC_Net = 0x00000040, // Function is network-replicated. FUNC_NetReliable = 0x00000080, // Function should be sent reliably on the network. FUNC_Simulated = 0x00000100, // Function executed on the client side. FUNC_Exec = 0x00000200, // Executable from command line. FUNC_Native = 0x00000400, // Native function. FUNC_Event = 0x00000800, // Event function. FUNC_Static = 0x00002000, // Static function. FUNC_NoExport = 0x00004000, // Don't export intrinsic function to C++. FUNC_Const = 0x00008000, // Function doesn't modify this object. FUNC_Invariant = 0x00010000, // Return value is purely dependent on parameters; no state dependencies or internal state changes. FUNC_Public = 0x00020000, // Function is accessible in all classes (if overridden, parameters much remain unchanged). FUNC_Private = 0x00040000, // Function is accessible only in the class it is defined in (cannot be overriden, but function name may be reused in subclasses. IOW: if overridden, parameters don't need to match, and Super.Func() cannot be accessed since it's private.) FUNC_Protected = 0x00080000, // Function is accessible only in the class it is defined in and subclasses (if overridden, parameters much remain unchanged). FUNC_Delegate = 0x00100000, // Function is actually a delegate. */ /*if( !t ) { t = new rbToken(token,name,output); AddToken(t); } dword idx = 0; dword param = 0; while( idx < code.Length() ) { unsigned long val; if( !code.Mid(idx,2).ToULong(&val,16) ) throw upexception(wxString::Format(wxT("Unknown Function Token code %x at %s"),dword(token),Arc.DebugInfo().c_str())); idx += 2; if( val == 0x29 ) { ++param; if( !code.Mid(idx,4).ToULong(&val,16) ) throw upexception(wxString::Format(wxT("Unknown Function Token code 2 %x at %s"),dword(token),Arc.DebugInfo().c_str())); //val = wxUINT32_SWAP_ALWAYS(val); idx += 4; wxLogMessage( wxString::Format(wxT("LOAD param %d for %s"),param,PF_SAFESTR(name))); AddToken(LoadToken(true)); } else if( val == 0x0b ) { // should be 0x16 = endparams AddToken(LoadToken(true)); wxLogMessage( wxString::Format(wxT("END param for %s"),PF_SAFESTR(name))); } } */ } catch( upexception& e ) { throw upexception( wxString::Format(wxT(" [%.4x]%s -- %s"), token, PF_SAFESTR(name), e.wwhat().c_str() )); } catch( exception& e ) { throw exception( wxString::Format(wxT(" [%.4x]%s -- %hs"), token, PF_SAFESTR(name), e.what()).ToAscii()); } }
//中缀表达式转换为后缀表达式 void InfixExpressionToSuffixExpression(char InfixExpression[],char SuffixExpression[]) { pStack s; char ch; char e; int i=0,j=0; InitStack(&s); ch=InfixExpression[i]; i++; while(ch!='\0') { switch(ch) { case '(': PushStack(&s,ch); break; case ')': while(GetTop(s,&e)&&e!='(') { PopStack(&s,&e); SuffixExpression[j]=e; j++; SuffixExpression[j]=' '; j++; } PopStack(&s,&e); break; case '+': case '-': while(!StackEmpty(s)&&GetTop(s,&e)&&e!='(') { PopStack(&s,&e); SuffixExpression[j]=e; j++; SuffixExpression[j]=' '; j++; } PushStack(&s,ch); break; case '*': case '/': while(!StackEmpty(s)&&GetTop(s,&e)&&e=='/'||e=='*') { PopStack(&s,&e); SuffixExpression[j]=e; j++; SuffixExpression[j]=' '; j++; } PushStack(&s,ch); break; case ' ': break; default: while(ch>='0' && ch<='9') { SuffixExpression[j]=ch; j++; ch=InfixExpression[i]; i++; } i--; SuffixExpression[j]=' '; j++; } ch=InfixExpression[i]; i++; } while(!StackEmpty(s)) { PopStack(&s,&e); SuffixExpression[j]=e; j++; SuffixExpression[j]=' '; j++; } SuffixExpression[j]='\0'; }
D_MOBILE *load_player(char *player) { FILE *fp; D_MOBILE *dMob = NULL; char pfile[MAX_BUFFER]; char pName[MAX_BUFFER]; char *word; bool done = FALSE, found; int i, size; pName[0] = toupper(player[0]); size = strlen(player); for (i = 1; i < size && i < MAX_BUFFER - 1; i++) pName[i] = tolower(player[i]); pName[i] = '\0'; /* open the pfile so we can write to it */ snprintf(pfile, MAX_BUFFER, "players/%s.pfile", pName); if ((fp = fopen(pfile, "r")) == NULL) return NULL; /* create new mobile data */ if (StackSize(dmobile_free) <= 0) { if ((dMob = malloc(sizeof(*dMob))) == NULL) { bug("Load_player: Cannot allocate memory."); abort(); } } else { dMob = (D_MOBILE *) PopStack(dmobile_free); } clear_mobile(dMob); /* load data */ word = fread_word(fp); while (!done) { found = FALSE; switch (word[0]) { case 'E': if (!strcasecmp(word, "EOF")) {done = TRUE; found = TRUE; break;} break; case 'L': IREAD( "Level", dMob->level ); break; case 'N': SREAD( "Name", dMob->name ); break; case 'P': SREAD( "Password", dMob->password ); break; } if (!found) { bug("Load_player: unexpected '%s' in %s's pfile.", word, player); free_mobile(dMob); return NULL; } /* read one more */ if (!done) word = fread_word(fp); } fclose(fp); return dMob; }
//输入表达式并计算结果 double CalculateExp(void) { double result, tempNum1, tempNum2; double data = 0, expn; char ch, topSign, point = 'n', num = 'n'; OPTR *sign; OPRD *number; InitStack(OPTR, &sign); InitStack(OPRD, &number); PushStack(sign, '#'); printf("请输入表达式:"); ch = getchar(); GetStackTop(sign, &topSign); while(ch != '#' || topSign != '#'){ if ('0' <= ch && ch <= '9' || ch == '.'){ if (ch == '.' && point == 'y'){ printf("表达式输入有误!\n"); exit(-1); } else if (ch == '.' && point == 'n'){ point = 'y'; expn = 0.1; } else{ if (point == 'y'){ data = data + expn * (ch - '0'); expn *= 0.1; } else{ data = data * 10 + (ch - '0'); } num = 'y'; } ch = getchar(); } else if (ch == '+' || ch == '-' || ch == '*' || ch == '/' || ch == '(' || ch == ')' || ch == '#'){ if (num == 'y'){ PushStack(number, data); num = 'n'; point = 'n'; data = 0; } GetStackTop(sign, &topSign); switch(compare(ch, topSign)){ case '<': //扫描运算符优先级小于栈顶元素 PopStack(sign, &topSign); PopStack(number, &tempNum1); PopStack(number, &tempNum2); switch(topSign){ case '+': result = tempNum1 + tempNum2; break; case '-': result = tempNum1 - tempNum2; break; case '*': result = tempNum1 * tempNum2; break; case '/': result = tempNum2 / tempNum1; break; } PushStack(number, result); break; case '>': //扫描运算符优先级大于栈顶元素 PushStack(sign, ch); ch = getchar(); break; case '=': //扫描运算符为右括号,匹配到了左括号 PopStack(sign, &topSign); ch = getchar(); break; } } else if (ch == '\n'){ ch = '#'; } else{ printf("输入的表达式有误!\n"); exit(-1); } GetStackTop(sign, &topSign); } PopStack(number, &result); //将结果从栈中取出来 if (!EmptyStack(number)){ //如果取出后栈不为空则表示输入的表达式不正确 printf("表达式有误!\n"); exit(-1); } return result; }
bool AssignVar(CompileInstance &inst, const mtlChars &name, const mtlChars &expr) { mtlChars base_name = GetBaseName(name); Definition *type = GetType(inst, base_name); if (type == NULL) { AddError(inst, "Undeclared variable", name); return false; } if (type->mut != Mutable) { AddError(inst, "Modifying a constant", name); return false; } ExpressionNode *tree = GenerateTree(expr); if (tree == NULL) { AddError(inst, "Malformed expression", expr); return false; } mtlChars base_mem = GetBaseMembers(name); bool result = true; Parser parser; mtlList<mtlChars> ops; mtlList<mtlChars> m; mtlString order_str; const int num_lanes = (base_mem.GetSize() > 0) ? base_mem.GetSize() : type->type.size; for (int lane = 0; lane < num_lanes; ++lane) { order_str.Free(); const int stack_size = tree->Evaluate(name, order_str, lane, 0); PushStack(inst, stack_size); order_str.SplitByChar(ops, ';'); mtlItem<mtlChars> *op = ops.GetFirst(); while (op != NULL && op->GetItem().GetSize() > 0) { parser.SetBuffer(op->GetItem()); switch (parser.MatchPart("%s+=%s%|%s-=%s%|%s*=%s%|%s/=%s%|%s=%s", m, NULL)) { case 0: EmitInstruction(inst, swsl::FLT_ADD_MM); break; case 1: EmitInstruction(inst, swsl::FLT_SUB_MM); break; case 2: EmitInstruction(inst, swsl::FLT_MUL_MM); break; case 3: EmitInstruction(inst, swsl::FLT_DIV_MM); break; case 4: EmitInstruction(inst, swsl::FLT_SET_MM); break; default: AddError(inst, "Invalid syntax", op->GetItem()); return false; break; } mtlItem<swsl::Instruction> *instr_item = inst.program.GetLast(); const mtlChars dst = m.GetFirst()->GetItem(); const mtlChars src = m.GetFirst()->GetNext()->GetItem(); EmitOperand(inst, dst); if (src.IsFloat()) { *((int*)(&instr_item->GetItem().instr)) += 1; } EmitOperand(inst, src); op = op->GetNext(); } PopStack(inst, stack_size); } delete tree; return result; }
static instruction *OpToReg( instruction *ins, temp_entry *temp, fp_attr attr ) { /*****************************************************************************/ if( ins == temp->last && !temp->whole_block ) { switch( ins->u.gen_table->generate ) { case G_MFLD: PushVirtualStack( ins ); InsLoc( ins, VIRTUAL_0 ) = temp->actual_locn; DoNothing( ins ); break; case G_MCOMP: // if( temp->actual_locn != ACTUAL_1 ) _Zoiks( ZOIKS_076 ); ins->operands[ 0 ] = ST( ACTUAL_1 ); ins->operands[ 1 ] = ST( 0 ); if( temp->actual_locn != ACTUAL_1 ) { byte *actual_owner; actual_owner = ActualStackOwner( ACTUAL_1 ); *actual_owner = temp->actual_locn; PrefFXCH( ins, ACTUAL_1 ); PrefFXCH( ins, temp->actual_locn ); RevCond( ins ); } ins->u.gen_table = &FCOMPP; PopStack( ins ); PopStack( ins ); break; case G_MNFBIN: case G_MRFBIN: if( ins->u.gen_table->generate == G_MRFBIN ) { ins->u.gen_table = &RNFBINP; } else { ins->u.gen_table = &RRFBINP; } ins->operands[ 0 ] = ST( temp->actual_locn ); ins->result = ins->operands[ 0 ]; ins->operands[ 1 ] = ST( 0 ); InsLoc( ins, VIRTUAL_0 ) = temp->actual_locn; DecrementAll(); break; } temp->actual_locn = ACTUAL_NONE; } else { if( ( ins == temp->first ) && !temp->defined && !temp->whole_block ) { PrefFLDOp( ins, OP_MEM, temp->actual_op ); IncrementAll(); temp->actual_locn = ACTUAL_0; if( ins->u.gen_table->generate == G_MFLD ) { // PushStack( ins ); ins->operands[ 0 ] = ST( ACTUAL_0 ); } else { GetToTopOfStack( ins, VIRTUAL_0 ); ins->operands[ 0 ] = ST( temp->actual_locn ); } } else { ins->operands[ 0 ] = ST( temp->actual_locn ); // if( attr & PUSHES ) { // PushStack( ins ); // } } if( attr & PUSHES ) { PushStack( ins ); } else if( attr & POPS2 ) { PopStack( ins ); PopStack( ins ); } else if( attr & POPS ) { PopStack( ins ); } ins->u.gen_table = RegAction( ins ); } return( ins ); }
int CPU_DoCommand ( CPU_t* Processor, int Command ) { switch ( (int)Processor->RAM[Processor->ProgramCounter] ) { case ADD: { Processor->ProgramCounter++; int NumberR1 = (int) Processor->RAM[Processor->ProgramCounter]; Processor->ProgramCounter++; int NumberR2 = (int) Processor->RAM[Processor->ProgramCounter]; Processor->CPURegister[NumberR1] = Processor->CPURegister[NumberR1] + Processor->CPURegister[NumberR2]; break; } case ADD2: { Processor->ProgramCounter++; int NumberR1 = (int) Processor->RAM[Processor->ProgramCounter]; Processor->ProgramCounter++; double Number = Processor->RAM[Processor->ProgramCounter]; Processor->CPURegister[NumberR1] += Number; break; } case SUB: { Processor->ProgramCounter++; int NumberR1 = (int) Processor->RAM[Processor->ProgramCounter]; Processor->ProgramCounter++; int NumberR2 = (int) Processor->RAM[Processor->ProgramCounter]; Processor->CPURegister[NumberR1] = Processor->CPURegister[NumberR1] - Processor->CPURegister[NumberR2]; break; } case SUB2: { Processor->ProgramCounter++; int NumberR1 = (int) Processor->RAM[Processor->ProgramCounter]; Processor->ProgramCounter++; double Number = Processor->RAM[Processor->ProgramCounter]; Processor->CPURegister[NumberR1] -= Number; break; } case DIV: { Processor->ProgramCounter++; int NumberR1 = (int) Processor->RAM[Processor->ProgramCounter]; Processor->ProgramCounter++; int NumberR2 = (int) Processor->RAM[Processor->ProgramCounter]; if ( Processor->CPURegister[NumberR2] == 0 ) { CPU_Errno = EINVAL; return -1; } Processor->CPURegister[NumberR1] = Processor->CPURegister[NumberR1] / Processor->CPURegister[NumberR2]; break; } case DIV2: { Processor->ProgramCounter++; int NumberR1 = (int) Processor->RAM[Processor->ProgramCounter]; Processor->ProgramCounter++; double Number = Processor->RAM[Processor->ProgramCounter]; if ( Number == 0 ) { CPU_Errno = EINVAL; return -1; } Processor->CPURegister[NumberR1] /= Number; break; } case MUL: { Processor->ProgramCounter++; int NumberR1 = (int) Processor->RAM[Processor->ProgramCounter]; Processor->ProgramCounter++; int NumberR2 = (int) Processor->RAM[Processor->ProgramCounter]; Processor->CPURegister[NumberR1] = Processor->CPURegister[NumberR1] * Processor->CPURegister[NumberR2]; break; } case MUL2: { Processor->ProgramCounter++; int NumberR1 = (int) Processor->RAM[Processor->ProgramCounter]; Processor->ProgramCounter++; double Number = Processor->RAM[Processor->ProgramCounter]; Processor->CPURegister[NumberR1] *= Number; break; } case MOV: { Processor->ProgramCounter++; int NumberR1 = (int) Processor->RAM[Processor->ProgramCounter]; Processor->ProgramCounter++; int NumberR2 = (int) Processor->RAM[Processor->ProgramCounter]; Processor->CPURegister[NumberR1] = Processor->CPURegister[NumberR2]; break; } case MOV2: { Processor->ProgramCounter++; int NumberR1 = (int) Processor->RAM[Processor->ProgramCounter]; Processor->ProgramCounter++; int Number = Processor->RAM[Processor->ProgramCounter]; Processor->CPURegister[NumberR1] = Number; break; } case CMP: { (Processor->ProgramCounter)++; int NumberR1 = (int) Processor->RAM[Processor->ProgramCounter]; (Processor->ProgramCounter)++; int NumberR2 = (int) Processor->RAM[Processor->ProgramCounter]; double Different = Processor->CPURegister[NumberR1] - Processor->CPURegister[NumberR2]; Processor->StatusReg = 0; if ( Different > 0 ) (Processor->StatusReg) |= MoreBit; if ( Different < 0 ) (Processor->StatusReg) |= LessBit; if ( Different == 0 ) (Processor->StatusReg) |= EqualBit; break; } case CMP2: { Processor->ProgramCounter++; int NumberR1 = (int) Processor->RAM[Processor->ProgramCounter]; Processor->ProgramCounter++; double Number = Processor->RAM[Processor->ProgramCounter]; double Different = Processor->CPURegister[NumberR1] - Number; Processor->StatusReg = 0; if ( Different > 0 ) Processor->StatusReg |= MoreBit; if ( Different < 0 ) Processor->StatusReg |= LessBit; if ( Different == 0 ) Processor->StatusReg |= EqualBit; break; } case POP: { Processor->ProgramCounter++; int NumberR1 = (int) Processor->RAM[Processor->ProgramCounter]; double Number = PopStack( Processor->CPUStack ); if ( Number == -1 && errno != 0 ) { return -1; } Processor->CPURegister[NumberR1] = Number; break; } case PUSH: { Processor->ProgramCounter++; int NumberR1 = (int) Processor->RAM[Processor->ProgramCounter]; if ( PushStack( Processor->CPUStack, Processor->CPURegister[NumberR1] ) == -1 ) { return -1; }; break; } case CALL: { Processor->ProgramCounter++; unsigned int CallAdress = (int) Processor->RAM[Processor->ProgramCounter]; if ( PushStack( Processor->CPUStack, (Processor->ProgramCounter+1) ) == -1 ) { return -1; }; Processor->ProgramCounter = CallAdress - 1; break; } case JP: { Processor->ProgramCounter++; Processor->ProgramCounter = (Processor->RAM[Processor->ProgramCounter] - 1); break; } case JA: { Processor->ProgramCounter++; if ( ( Processor->StatusReg & ( MoreBit ) ) == MoreBit ) Processor->ProgramCounter = (Processor->RAM[Processor->ProgramCounter] - 1); break; } case JB: { Processor->ProgramCounter++; if ( ( Processor->StatusReg & ( LessBit ) ) == LessBit ) Processor->ProgramCounter = (Processor->RAM[Processor->ProgramCounter] - 1); break; } case JAE: { Processor->ProgramCounter++; if ( ( Processor->StatusReg & ( MoreBit ) ) == MoreBit || ( Processor->StatusReg & ( EqualBit ) ) == EqualBit ) Processor->ProgramCounter = (Processor->RAM[Processor->ProgramCounter] - 1); break; } case JBE: { Processor->ProgramCounter++; if ( ( Processor->StatusReg & ( LessBit ) ) == LessBit || ( Processor->StatusReg & ( EqualBit ) ) == EqualBit ) Processor->ProgramCounter = (Processor->RAM[Processor->ProgramCounter] - 1); break; } case JE: { Processor->ProgramCounter++; if ( ( Processor->StatusReg & ( EqualBit ) ) == EqualBit ) Processor->ProgramCounter = (Processor->RAM[Processor->ProgramCounter] - 1); break; } case JZ: { /********** Not use ***********/ break; } case JNZ: { /********** Not use ***********/ break; } case RET: { int CallAdress = PopStack ( Processor->CPUStack ); if ( CallAdress == -1 && errno != 0 ) { return -1; }; Processor->ProgramCounter = ( CallAdress - 1 ); break; } case OUT: { Processor->ProgramCounter++; int NumberR1 = (int) Processor->RAM[Processor->ProgramCounter]; printf ( "%lg\n", Processor->CPURegister[NumberR1] ); break; } case IN: { Processor->ProgramCounter++; int NumberR1 = (int) Processor->RAM[Processor->ProgramCounter]; scanf ( "%lg", &Processor->CPURegister[NumberR1] ); break; } case CLR: { Processor->ProgramCounter++; int NumberR1 = (int) Processor->RAM[Processor->ProgramCounter]; Processor->CPURegister[NumberR1] = 0; break; } case DEC: { Processor->ProgramCounter++; int NumberR1 = (int) Processor->RAM[Processor->ProgramCounter]; Processor->CPURegister[NumberR1]--; break; } case INC: { Processor->ProgramCounter++; int NumberR1 = (int) Processor->RAM[Processor->ProgramCounter]; Processor->CPURegister[NumberR1]++; break; } case NOP: { // break; } case END: { return END; } } return 0; }
int main() { int i = 0; int flag = 0; int *x = (int *)malloc(sizeof(int)); //CreateEmptySqstack printf("creat empty stack\n"); sqstack_t *stack; stack = CreateEmptySqstack(MAX_DEPTH); //EmptySqstack printf("test if stack is empty?\n"); flag = EmptySqstack(stack); if (flag)//start of if { printf ("stack empty\n"); } else if (0 == flag) { printf ("stack not empty\n"); } else { printf("stack error\n"); }//end of if //PushStack printf("push stack\n"); for (i=0; i<MAX_DEPTH; i++) { if (0 != PushStack(stack, i)) {break;} //GetTop printf("push %d in %d position\n", i, i); GetTop(stack, x); // printf("%d\n", *x); } //after push printf("after push, test if stack is full?\n"); flag = FullSqstack(stack); if (1 == flag)//start of if { printf ("stack full\n"); } else if (0 == flag) { printf ("stack not full\n"); } else { printf("stack error\n"); }//end of if //PopStack printf("pop stack 1 time\n"); PopStack(stack, x); printf("%d\n", *x); printf("after one pop, test if stack is full?\n"); flag = FullSqstack(stack); if (flag)//start of if { printf ("stack full\n"); } else if (0 == flag) { printf ("stack not full\n"); } else { printf("stack error\n"); }//end of if //ClearSqstack printf("clear stack\n"); ClearSqstack(stack); printf("after clear,test if stack is empty?\n"); flag = EmptySqstack(stack); if (flag)//start of if { printf ("stack empty\n"); } else if (0 == flag) { printf ("stack not empty\n"); } else { printf("stack error\n"); }//end of if printf("destroy stack\n"); DestroySqstack(stack); return 0; }
D_MOBILE *load_player(char *player) { FILE *fp; D_MOBILE *dMob = NULL; char pfile[256]; char pName[20]; char *word; bool done = FALSE, found; int i, size; pName[0] = toupper(player[0]); size = strlen(player); for (i = 1; i < size; i++) pName[i] = tolower(player[i]); pName[i] = '\0'; /* open the pfile so we can write to it */ sprintf(pfile, "../players/%s.pfile", pName); if ((fp = fopen(pfile, "r")) == NULL) return NULL; /* create new mobile data */ if (StackSize(dmobile_free) <= 0) { if ((dMob = malloc(sizeof(*dMob))) == NULL) { bug("Load_player: Cannot allocate memory."); abort(); } } else { dMob = (D_MOBILE *) PopStack(dmobile_free); } clear_mobile(dMob); #ifdef IMC imc_initchar( dMob ); #endif /* load data */ word = fread_word(fp); while (!done) { found = FALSE; switch (word[0]) { case 'C': if (compares(word, "Coordx")) { IREAD( "Coordx", dMob->coordx ); } if (compares(word, "Coordy")) { IREAD( "Coordy", dMob->coordy ); } if (compares(word, "Coordz")) { IREAD( "Coordz", dMob->coordz ); } break; case 'E': if (!strcasecmp(word, "EOF")) {done = TRUE; found = TRUE; break;} break; case 'I': #ifdef IMC if( ( found = imc_loadchar( dMob, fp, word ) ) ) break; #endif break; case 'L': IREAD( "Level", dMob->level ); break; case 'N': SREAD( "Name", dMob->name ); break; case 'P': SREAD( "Password", dMob->password ); break; case 'T': SREAD( "Title", dMob->title ); break; } if (!found) { bug("Load_player: unexpected '%s' in %s's pfile.", word, player); free_mobile(dMob); return NULL; } /* read one more */ if (!done) word = fread_word(fp); } fclose(fp); return dMob; }