int eCosBoard_flash(ecosflash_flash_bank_t *info, void *data, u32 address, u32 len) { target_t *target=info->target; const int chunk=8192; int retval=ERROR_OK; int timeout = (chunk / 20480 + 1) * 1000; /*asume 20 KB/s + 1 second*/ retval=loadDriver(info); if (retval!=ERROR_OK) return retval; u32 buffer; retval=runCode(info, info->start_address+OFFSET_GET_WORKAREA, info->start_address+OFFSET_GET_WORKAREA+OFFSET_GET_WORKAREA_SIZE, 0, 0, 0, &buffer, 1000); if (retval!=ERROR_OK) return retval; int i; for (i=0; i<len; i+=chunk) { int t=len-i; if (t>chunk) { t=chunk; } int retval; retval=target_write_buffer(target, buffer, t, ((u8 *)data)+i); if (retval != ERROR_OK) return retval; u32 flashErr; retval=runCode(info, info->start_address+OFFSET_FLASH, info->start_address+OFFSET_FLASH+OFFSET_FLASH_SIZE, buffer, address+i, t, &flashErr, timeout); if (retval != ERROR_OK) return retval; if (flashErr != 0x0) { LOG_ERROR("Flash prog failed with %d (%s)\n", flashErr, flash_errmsg(flashErr)); return ERROR_FAIL; } } return ERROR_OK; }
void CtrlrLuaConsole::snipsItemClicked(Button *b) { PopupMenu m; m.addItem (1, "Add input to snips"); m.addSubMenu ("Run snip", getSnipsMenu(1024)); m.addSubMenu ("Remove snip", getSnipsMenu(4096)); m.addItem (2, "Toggle input removal after run", true, (bool)owner.getProperty(Ids::uiLuaConsoleInputRemoveAfterRun)); const int ret = m.showAt(b); if (ret == 1) { snips.add (inputDocument.getAllContent()); } if (ret >= 1024 && ret < 4096) { runCode (snips[ret-1024]); } if (ret >= 4096) { snips.remove (ret-4096); } if (ret == 2) { owner.setProperty (Ids::uiLuaConsoleInputRemoveAfterRun, !owner.getProperty(Ids::uiLuaConsoleInputRemoveAfterRun)); } owner.setProperty (Ids::uiLuaConsoleSnips, snips.joinIntoString("$")); }
static int eCosBoard_erase(struct ecosflash_flash_bank *info, uint32_t address, uint32_t len) { int retval; int timeout = (len / 20480 + 1) * 1000; /*asume 20 KB/s*/ retval = loadDriver(info); if (retval != ERROR_OK) return retval; uint32_t flashErr; retval = runCode(info, info->start_address + OFFSET_ERASE, info->start_address + OFFSET_ERASE + OFFSET_ERASE_SIZE, address, len, 0, &flashErr, timeout ); if (retval != ERROR_OK) return retval; if (flashErr != 0x0) { LOG_ERROR("Flash erase failed with %d (%s)", (int)flashErr, flash_errmsg(flashErr)); return ERROR_FAIL; } return ERROR_OK; }
int main(int argc, const char** argv) { if (argc < 2) { printf("You have to give the brainfuck interpreter a name of a file that contains brainfuck code."); return 1; } char* fileName = argv[1]; char* code = 0; long length; FILE * file = fopen (fileName, "rb"); if (file) { fseek (file, 0, SEEK_END); length = ftell (file); fseek (file, 0, SEEK_SET); code = malloc (length); if (code) { fread (code, 1, length, file); } fclose (file); } if (code) { return runCode(code, length); } return 1; }
int main(void) { initializeStacks(); getCodeFromFile(); runCode(); printIntermediateOutputsForEachEquation(); printFinalValues(); freeMemory(); exit(EXIT_SUCCESS); }
//[MiscUserCode] You can add your own definitions of your custom methods or any other code here... bool CtrlrLuaConsole::keyPressed (const KeyPress& key, Component* originatingComponent) { if (key.getKeyCode() == 13 && originatingComponent == luaConsoleInput && !key.getModifiers().isCtrlDown()) { runCode(inputDocument.getAllContent()); if ((bool)owner.getProperty(Ids::uiLuaConsoleInputRemoveAfterRun)) { inputDocument.replaceAllContent(String::empty); } return (true); } else if (key.getKeyCode() == 13 && originatingComponent == luaConsoleInput && key.getModifiers().isCtrlDown()) { luaConsoleInput->insertTextAtCaret ("\n"); return (true); } else if (key.getKeyCode() == KeyPress::upKey && key.getModifiers().isCtrlDown() && originatingComponent == luaConsoleInput ) { if(inputHistory.size()) { // Prev command if (nextUpKeyPressWillbeFirst) { currentInputString = inputDocument.getAllContent(); nextUpKeyPressWillbeFirst = false; } luaConsoleInput->loadContent(inputHistory[lastCommandNumInHistory]); /* Put text at pointer into console */ lastCommandNumInHistory = ( ((lastCommandNumInHistory - 1) < 0) ? 0 : (lastCommandNumInHistory - 1) ); lastMoveDirection = UP; } return (true); } else if (key.getKeyCode() == KeyPress::downKey && key.getModifiers().isCtrlDown() && originatingComponent == luaConsoleInput) { if(inputHistory.size()) { // next command if (lastCommandNumInHistory == (inputHistory.size() - 1)) // at last command only { if (!currentInputString.isEmpty()) { luaConsoleInput->loadContent(currentInputString); nextUpKeyPressWillbeFirst = true; // if user changes this restored text we need to capture it at up key again } return true; } lastCommandNumInHistory += 1; luaConsoleInput->loadContent(inputHistory[lastCommandNumInHistory]); /* Put text at pointer into console */ lastMoveDirection = DOWN; } return (true); } return (false); }
int main() { /* Data and buffers */ double input = 2.3; double input2 = 31338.3; double output = runCode(input,input2); printf("Output is: %lf\n",output); return 0; }
int main() { int* commandList = NULL; int numberOfCommands = 0; FILE* input; input = fopen("bincode.txt","rb"); numberOfCommands = fGetCode( &commandList, input ); fclose( input ); //dumpCode( commandList, numberOfCommands ); runCode( commandList, numberOfCommands ); return 0; }
//[MiscUserCode] You can add your own definitions of your custom methods or any other code here... bool CtrlrLuaConsole::keyPressed (const KeyPress& key, Component* originatingComponent) { if (key.getKeyCode() == 13 && originatingComponent == luaConsoleInput && !key.getModifiers().isCtrlDown()) { runCode(inputDocument.getAllContent()); if ((bool)owner.getProperty(Ids::uiLuaConsoleInputRemoveAfterRun)) { inputDocument.replaceAllContent(String::empty); } return (true); } else if (key.getKeyCode() == 13 && originatingComponent == luaConsoleInput && key.getModifiers().isCtrlDown()) { luaConsoleInput->insertTextAtCaret ("\n"); } return (false); }
void CtrlrLuaConsole::menuItemSelected(int menuItemID, int topLevelMenuIndex) { if (menuItemID == 2) { snips.add (inputDocument.getAllContent()); } if (menuItemID >= 1024 && menuItemID < 4096) { runCode (snips[menuItemID-1024]); } if (menuItemID >= 4096) { snips.remove (menuItemID-4096); } if (menuItemID == 3) { owner.setProperty (Ids::uiLuaConsoleInputRemoveAfterRun, !owner.getProperty(Ids::uiLuaConsoleInputRemoveAfterRun)); } owner.setProperty (Ids::uiLuaConsoleSnips, snips.joinIntoString("$")); }