int main(int argc, const char* argv[]){ variables_init(); /*tests!*/ boost::shared_ptr<ProcessHandle> hproc = NewArcProcess(); Process& proc=*(static_cast<Process*>(hproc->pproc.get())); ProcessStack& stack = proc.stack; /*allocate stuff*/ //(cons 'bar ...) proc.stack.push(new(proc) Sym(globals->lookup("bar"))); //(cons 'foo ...) proc.stack.push(new(proc) Sym(globals->lookup("foo"))); //(cons t ...) proc.stack.push(new(proc) Sym(TATOM));//t //(cons t nil) proc.stack.push(new(proc) Sym(TATOM)); //t proc.stack.push(new(proc) Sym(NILATOM)); //nil //cons bytecode_cons(proc,stack); //repush stack top to make shared structure proc.stack.push(proc.stack.top()); bytecode_cons(proc,stack); bytecode_cons(proc,stack); bytecode_cons(proc,stack); //int proc.stack.push(new(proc) Integer(1)); proc.stack.push(new(proc) Integer(-1)); bytecode_cons(proc,stack); bytecode_cons(proc,stack); proc.stack.top()->probe(0); }
void SMC::init_variables () { variables_init(); ncons = get_num_cons(); nprim = get_num_prim(); nplot = 5 + nspec; }
int main(int argc, char *argv[]) { int ret; FILE *fp; Instruction start = { .instruction = I_NOP, .next_instruction = NULL, .alt_instruction = NULL }; Variables global_vars; if (argc != 2 || (fp = fopen(argv[1], "rb")) == NULL) { debug("Cannot open file.\n"); return print_error(INTERNAL_ERROR); } variables_init(&global_vars); debug("calling PARSE\n"); if ((ret = parse(fp, &start, &global_vars)) == SUCCESS) { debug("PARSE ok\n\n"); #ifdef DEBUG debug("\n========================PRINTING GLOBAL VARIABLES==========================\n"); variables_print(&global_vars); fprintf(stderr, "\n===========================================================================\n\n"); debug("\n===========================PRINTING INSTRUCTION============================\n"); debug_print_instruction(&start); fprintf(stderr, "\n===========================================================================\n\n"); #endif debug("calling INTERPRETER\n"); if ((ret = interpret(&start, &global_vars)) == SUCCESS) { debug("INTERPRETER OK\n"); } else { debug("INTERPRETER: NOT success return code\n"); } } else { debug("PARSER: NOT success return code\n"); } fclose(fp); variables_free(&global_vars); free_instr(); cstr_gc_free_all(); debug("MAIN RETURN CODE is: [ %d ]\n", ret); return print_error(ret); }
int main(int argc, const char* argv[]){ variables_init(); /*tests!*/ /*make sure NILATOM is a global atom*/ GlobalAtom* p = dynamic_cast<GlobalAtom*>(&*NILATOM); if(p != NULL){ std::cout << "NIL ATOM: "; p->emit(); std::cout << std::endl; } else { std::cout << "NIL ATOM not global!" << std::endl; } /*make sure NILATOM is looked up again*/ boost::shared_ptr<Atom> tmp(globals->lookup("nil")); if(tmp != NILATOM){ std::cout << "Eh??" << std::endl; p = dynamic_cast<GlobalAtom*>(&*tmp); if(p != NULL){ std::cout << "Other 'nil atom: "; p->emit(); std::cout << std::endl; } else { std::cout << "Other 'nil atom isn't even global!" << std::endl; } } else { std::cout << "Got NILATOM on lookup again!" << std::endl; } /*make sure NILATOM != TATOM*/ if(NILATOM != TATOM){ std::cout << "As expected, 'nil is not 't" << std::endl; } else { std::cout << "Not good: 'nil is somehow 't!" << std::endl; } }
void main_open_window() { main_freemem_hook = freemem_alloc_hook(); char *initdir = getenv("DB101_LASTDIR"); if(initdir) strcpy(lastdir, initdir); variables_init(); console_init(); stacktrace_init(); source_init(); disassembler_init(); sourcelist_init(); pipe_init(); AppPort = IExec->AllocSysObjectTags(ASOT_PORT, TAG_DONE); /* Create the window object. */ if(( MainWinObj = WindowObject, WA_ScreenTitle, "Debug 101", WA_Title, "Debug 101 v1.1.0 BETA - secret edition ;)", WA_Width, 1024, WA_Height, 768, WA_DepthGadget, TRUE, WA_SizeGadget, TRUE, WA_DragBar, TRUE, WA_CloseGadget, TRUE, WA_Activate, TRUE, WINDOW_NewMenu, mynewmenu, WINDOW_MenuUserData, WGUD_IGNORE, WINDOW_IconifyGadget, TRUE, WINDOW_IconTitle, "Debug 101", WINDOW_AppPort, AppPort, WINDOW_Position, WPOS_CENTERSCREEN, /* there is no HintInfo array set up here, instead we define the ** strings directly when each gadget is created (OM_NEW) */ WINDOW_GadgetHelp, TRUE, WINDOW_ParentGroup, MainObj[GAD_TOPLAYOUT] = VLayoutObject, LAYOUT_AddChild, HLayoutObject, LAYOUT_AddChild, MainObj[GAD_SELECT_BUTTON] = ButtonObject, GA_ID, GAD_SELECT_BUTTON, GA_Text, "Select file", GA_RelVerify, TRUE, GA_HintInfo, "Push to select file", ButtonEnd, CHILD_WeightedWidth, 0, LAYOUT_AddChild, MainObj[GAD_RELOAD_BUTTON] = ButtonObject, GA_ID, GAD_RELOAD_BUTTON, GA_Text, "Reload", GA_RelVerify, TRUE, GA_Disabled, TRUE, GA_HintInfo, "Push to reload previously executed file", ButtonEnd, CHILD_WeightedWidth, 0, LAYOUT_AddChild, MainObj[GAD_FILENAME_STRING] = StringObject, GA_ID, GAD_FILENAME_STRING, GA_RelVerify, TRUE, GA_HintInfo, "Filename", GA_Disabled, TRUE, GA_ReadOnly, TRUE, STRINGA_MinVisible, 10, STRINGA_TextVal, "Select File", StringEnd, LAYOUT_AddChild, MainObj[GAD_ATTACH_BUTTON] = ButtonObject, GA_ID, GAD_ATTACH_BUTTON, GA_Text, "Attach", GA_RelVerify, TRUE, GA_HintInfo, "Push to attach to process", ButtonEnd, CHILD_WeightedWidth, 0, LAYOUT_AddChild, SpaceObject, SPACE_MinWidth, 24, SpaceEnd, LAYOUT_AddChild, MainObj[GAD_START_BUTTON] = ButtonObject, GA_ID, GAD_START_BUTTON, GA_RelVerify, TRUE, GA_Text, "Continue", GA_Disabled, TRUE, ButtonEnd, CHILD_WeightedHeight, 0, LAYOUT_AddChild, MainObj[GAD_PAUSE_BUTTON] = ButtonObject, GA_ID, GAD_PAUSE_BUTTON, GA_RelVerify, TRUE, GA_Text, "Pause", GA_Disabled, TRUE, ButtonEnd, CHILD_WeightedHeight, 0, LAYOUT_AddChild, MainObj[GAD_KILL_BUTTON] = ButtonObject, GA_ID, GAD_KILL_BUTTON, GA_RelVerify, TRUE, GA_Text, "Kill", GA_Disabled, TRUE, ButtonEnd, CHILD_WeightedHeight, 0, #if 0 LAYOUT_AddChild, CrashButtonObj = ButtonObject, GA_ID, GAD_CRASH_BUTTON, GA_RelVerify, TRUE, GA_Text, "Crash", GA_Disabled, TRUE, ButtonEnd, CHILD_WeightedHeight, 0, #endif LAYOUT_AddChild, MainObj[GAD_STEPOVER_BUTTON] = ButtonObject, GA_ID, GAD_STEPOVER_BUTTON, GA_RelVerify, TRUE, GA_Text, "Step Over", GA_Disabled, TRUE, ButtonEnd, CHILD_WeightedHeight, 0, LAYOUT_AddChild, MainObj[GAD_STEPINTO_BUTTON] = ButtonObject, GA_ID, GAD_STEPINTO_BUTTON, GA_RelVerify, TRUE, GA_Text, "Step Into", GA_Disabled, TRUE, ButtonEnd, CHILD_WeightedHeight, 0, LAYOUT_AddChild, MainObj[GAD_STEPOUT_BUTTON] = ButtonObject, GA_ID, GAD_STEPOUT_BUTTON, GA_RelVerify, TRUE, GA_Text, "Step Out", GA_Disabled, TRUE, ButtonEnd, CHILD_WeightedHeight, 0, LAYOUT_AddChild, SpaceObject, SPACE_MinWidth, 24, SpaceEnd, LAYOUT_AddChild, MainObj[GAD_SETBREAK_BUTTON] = ButtonObject, GA_ID, GAD_SETBREAK_BUTTON, GA_RelVerify, TRUE, GA_Text, "Breaks", GA_Disabled, TRUE, ButtonEnd, CHILD_WeightedHeight, 0, LAYOUT_AddChild, MainObj[GAD_HEX_BUTTON] = ButtonObject, GA_ID, GAD_HEX_BUTTON, GA_RelVerify, TRUE, GA_Text, "Hex", GA_Disabled, TRUE, ButtonEnd, CHILD_WeightedHeight, 0, EndMember, CHILD_WeightedHeight, 0, LAYOUT_AddChild, HLayoutObject, LAYOUT_AddChild, MainObj[GAD_STACKTRACE_LISTBROWSER] = ListBrowserObject, GA_ID, GAD_STACKTRACE_LISTBROWSER, GA_RelVerify, TRUE, GA_TabCycle, TRUE, LISTBROWSER_AutoFit, TRUE, LISTBROWSER_Labels, &stacktrace_list, // LISTBROWSER_ColumnInfo, columninfo, LISTBROWSER_ColumnTitles, FALSE, LISTBROWSER_ShowSelected, FALSE, LISTBROWSER_Striping, LBS_ROWS, ListBrowserEnd, LAYOUT_AddChild, MainObj[GAD_VARIABLES_LISTBROWSER] = ListBrowserObject, GA_ID, GAD_VARIABLES_LISTBROWSER, GA_RelVerify, TRUE, GA_TabCycle, TRUE, LISTBROWSER_Hierarchical, TRUE, //LISTBROWSER_AutoFit, TRUE, LISTBROWSER_Labels, &variable_list, LISTBROWSER_ColumnInfo, variablescolumninfo, LISTBROWSER_ColumnTitles, TRUE, //LISTBROWSER_ShowSelected, TRUE, /* not really needed yet */ LISTBROWSER_Striping, LBS_ROWS, LISTBROWSER_SortColumn, 0, LISTBROWSER_TitleClickable, TRUE, ListBrowserEnd, EndMember, LAYOUT_AddChild, HLayoutObject, LAYOUT_AddChild, MainObj[GAD_CLICKTAB] = ClickTabObject, GA_Text, PageLabels_1, CLICKTAB_Current, 0, CLICKTAB_PageGroup, PageObject, PAGE_Add, VLayoutObject, //LAYOUT_SpaceOuter, TRUE, //LAYOUT_DeferLayout, TRUE, LAYOUT_AddChild, MainObj[GAD_SOURCE_LISTBROWSER] = ListBrowserObject, GA_ID, GAD_SOURCE_LISTBROWSER, GA_RelVerify, TRUE, GA_TabCycle, TRUE, LISTBROWSER_AutoFit, TRUE, LISTBROWSER_Labels, &source_list, LISTBROWSER_ColumnInfo, sourcecolumninfo, LISTBROWSER_ColumnTitles, TRUE, LISTBROWSER_ShowSelected, TRUE, //LISTBROWSER_Striping, LBS_ROWS, ListBrowserEnd, EndMember, PAGE_Add, VLayoutObject, LAYOUT_AddChild, MainObj[GAD_DISASSEMBLER_LISTBROWSER] = ListBrowserObject, GA_ID, GAD_DISASSEMBLER_LISTBROWSER, GA_RelVerify, TRUE, GA_TabCycle, TRUE, //GA_TextAttr, &courier_font, LISTBROWSER_AutoFit, TRUE, LISTBROWSER_Labels, &disassembly_list, LISTBROWSER_ShowSelected, TRUE, LISTBROWSER_Striping, LBS_ROWS, ListBrowserEnd, LAYOUT_AddChild, HLayoutObject, LAYOUT_AddChild, MainObj[GAD_DISASSEMBLER_STEP_BUTTON] = ButtonObject, GA_ID, GAD_DISASSEMBLER_STEP_BUTTON, GA_RelVerify, TRUE, GA_Text, "Step", ButtonEnd, CHILD_WeightedHeight, 0, LAYOUT_AddChild, MainObj[GAD_DISASSEMBLER_SKIP_BUTTON] = ButtonObject, GA_ID, GAD_DISASSEMBLER_SKIP_BUTTON, GA_RelVerify, TRUE, GA_Text, "Skip", ButtonEnd, CHILD_WeightedHeight, 0, EndMember, CHILD_WeightedHeight, 0, EndMember, PageEnd, EndMember, LAYOUT_WeightBar, TRUE, LAYOUT_AddChild, VLayoutObject, LAYOUT_AddChild, MainObj[GAD_SOURCELIST_LISTBROWSER] = ListBrowserObject, GA_ID, GAD_SOURCELIST_LISTBROWSER, GA_RelVerify, TRUE, GA_TabCycle, TRUE, LISTBROWSER_AutoFit, TRUE, LISTBROWSER_Labels, &sourcelist_list, LISTBROWSER_ShowSelected, TRUE, LISTBROWSER_Striping, LBS_ROWS, ListBrowserEnd, LAYOUT_AddChild, MainObj[GAD_IMPORT_BUTTON] = ButtonObject, GA_ID, GAD_IMPORT_BUTTON, GA_RelVerify, TRUE, GA_Text, "Import externals", ButtonEnd, CHILD_WeightedHeight, 0, EndMember, CHILD_WeightedWidth, 20, EndMember, LAYOUT_AddChild, HLayoutObject, LAYOUT_AddChild, MainObj[GAD_CONSOLE_LISTBROWSER] = ListBrowserObject, GA_ID, GAD_CONSOLE_LISTBROWSER, GA_RelVerify, TRUE, GA_TabCycle, TRUE, LISTBROWSER_AutoFit, TRUE, LISTBROWSER_Labels, &console_list, ListBrowserEnd, EndMember, LAYOUT_AddChild, HLayoutObject, LAYOUT_AddChild, MainObj[GAD_AREXX_STRING] = StringObject, GA_ID, GAD_AREXX_STRING, GA_RelVerify, TRUE, GA_Disabled, FALSE, GA_ReadOnly, FALSE, STRINGA_TextVal, "", StringEnd, LAYOUT_AddChild, MainObj[GAD_AREXX_BUTTON] = ButtonObject, GA_ID, GAD_AREXX_BUTTON, GA_RelVerify, TRUE, GA_Text, "Send", GA_Disabled, FALSE, ButtonEnd, CHILD_WeightedHeight, 0, CHILD_WeightedWidth, 0, LAYOUT_AddChild, MainObj[GAD_SIGNAL_BUTTON] = ButtonObject, GA_ID, GAD_SIGNAL_BUTTON, GA_RelVerify, TRUE, GA_Text, "Signal", GA_Disabled, FALSE, ButtonEnd, CHILD_WeightedHeight, 0, CHILD_WeightedWidth, 0, LAYOUT_AddChild, MainObj[GAD_X_BUTTON] = ButtonObject, GA_ID, GAD_X_BUTTON, GA_RelVerify, TRUE, GA_Text, "X", GA_Disabled, FALSE, ButtonEnd, CHILD_WeightedHeight, 0, CHILD_WeightedWidth, 0, EndMember, CHILD_WeightedHeight, 0, EndMember, EndWindow)) { /* Open the window. */ if( mainwin = (struct Window *) RA_OpenWindow(MainWinObj) ) { main_window_is_open = TRUE; button_set_start(); } } return; }
void main(void) { //u16 ad_val; //u8 ad_cnt = 0, cnt = 0; //u32 ad_sum = 0; //u8 second = 0; peripheral_init(); //³õʼ»¯ variables_init(); while(1) { if(timer_100ms_flag) { Button_Scan(); timer_100ms_flag = FALSE; WDR(); //kick watchdog } Con_Monitor(); switch(module_state) { case MODULE_STATE_INIT: Con_Module_Init_Proc(); break; case MODULE_STATE_WORK_NORM: Con_Module_Work_Norm_Proc(); break; case MODULE_STATE_WORK_WARN: Con_Module_Work_Warn_Proc(); break; case MODULE_STATE_COMMUNICATE: Con_Module_Communicate_Proc(); break; case MODULE_STATE_SERVICE: Con_Module_Service_Proc(); break; case MODULE_STATE_ERROR: Con_Module_Error_Proc(); break; case MODULE_STATE_QUIT: Con_Module_Quit_Proc(); break; default: break; } //Button_Scan(); //if(timer_100ms_flag) //{ //cnt++; //} //ad_val = EEPROM_Read(0x10); //Seg_Number_Show(ad_val, 100); //LedBlink(LED_D1, BLINK_1HZ); //LedBlink(LED_D2, BLINK_2HZ); //Seg_Number_Show(969, 100); //Seg_Alpha_Show(g, o, d, 100); //Delay(100); //ÑÓʱ } }