int SC_TerminalClient::run(int argc, char** argv) { Options& opt = mOptions; if (!parseOptions(argc, argv, opt)) { return mReturnCode; } // finish argv processing const char* codeFile = 0; if (argc > 0) { codeFile = argv[0]; opt.mDaemon = true; argv++; argc--; } opt.mArgc = argc; opt.mArgv = argv; // read library configuration file if (opt.mLibraryConfigFile) { int argLength = strlen(opt.mLibraryConfigFile); SC_LanguageConfig::readLibraryConfigYAML(opt.mLibraryConfigFile); } else SC_LanguageConfig::readDefaultLibraryConfig(); // initialize runtime initRuntime(opt); // startup library mShouldBeRunning = true; compileLibrary(); // enter main loop if (codeFile) executeFile(codeFile); if (opt.mCallRun) runMain(); if (opt.mDaemon) { daemonLoop(); } else { initInput(); if( shouldBeRunning() ) startInput(); if( shouldBeRunning() ) commandLoop(); endInput(); cleanupInput(); } if (opt.mCallStop) stopMain(); // shutdown library shutdownLibrary(); flush(); shutdownRuntime(); return mReturnCode; }
static void parseInput( const Block *block, const uint8_t *&p, const uint8_t *txHash, uint64_t inputIndex ) { if(!skip) { startInput(p); } auto upTXHash = p; const Chunk *upTX = 0; if(gNeedTXHash && !skip) { auto isGenTX = (0==memcmp(gNullHash.v, upTXHash, sizeof(gNullHash))); if(likely(false==isGenTX)) { auto i = gTXOMap.find(upTXHash); if(unlikely(gTXOMap.end()==i)) { errFatal("failed to locate upstream transaction"); } upTX = i->second; } } SKIP(uint256_t, dummyUpTXhash, p); LOAD(uint32_t, upOutputIndex, p); LOAD_VARINT(inputScriptSize, p); if(!skip && 0!=upTX) { auto inputScript = p; auto upTXOutputs = upTX->getData(); parseOutputs<false, true>( upTXOutputs, upTXHash, upOutputIndex, txHash, inputIndex, inputScript, inputScriptSize ); upTX->releaseData(); } p += inputScriptSize; SKIP(uint32_t, sequence, p); if(!skip) { endInput(p); } }
bool TreeBuilder::buildTree(const std::string &string, bool throw_error) { bool ret_val = true; for (auto chara : string) { if (buildTree(chara) == false) { ret_val = false; break; } } if (ret_val) ret_val = endInput(); else if (throw_error) throw formulateError(); else return false; }
static void parseInput( const uint8_t *&p, const uint8_t *txHash, uint64_t inputIndex ) { if(!skip) startInput(p); const uint8_t *upTXHash = p; const uint8_t *upTXOutputs = 0; if(gNeedTXHash && !skip) { bool isGenTX = (0==memcmp(gNullHash.v, upTXHash, sizeof(gNullHash))); if(likely(false==isGenTX)) { auto i = gTXMap.find(upTXHash); if(unlikely(gTXMap.end()==i)) errFatal("failed to locate upstream TX"); upTXOutputs = i->second; } } SKIP(uint256_t, dummyUpTXhash, p); LOAD(uint32_t, upOutputIndex, p); LOAD_VARINT(inputScriptSize, p); if(!skip && 0!=upTXOutputs) { const uint8_t *inputScript = p; parseOutputs<false, true>( upTXOutputs, upTXHash, upOutputIndex, txHash, inputIndex, inputScript, inputScriptSize ); } p += inputScriptSize; SKIP(uint32_t, sequence, p); if(!skip) endInput(p); }
template<> void CreatureAttributes::serialize(PrettyInputArchive& ar1, unsigned version) { serializeImpl(ar1, version); ar1(endInput()); initializeLastingEffects(); }