// Creates a new empty but suitably initialized bound module fragment. static value_t new_empty_module_fragment(runtime_t *runtime, value_t stage, value_t module) { TRY_DEF(empty_fragment, new_heap_module_fragment(runtime, module, stage, nothing(), nothing(), nothing())); TRY(init_empty_module_fragment(runtime, empty_fragment)); return empty_fragment; }
TER Transactor::checkSig() { // Consistency: Check signature // Verify the transaction's signing public key is the key authorized for signing. if (mHasAuthKey && mSigningPubKey.getAccountID() == mTxnAccount->getFieldAccount(sfRegularKey).getAccountID()) { // Authorized to continue. nothing(); } else if (mSigningPubKey.getAccountID() == mTxnAccountID) { // Authorized to continue. nothing(); } else if (mHasAuthKey) { cLog(lsINFO) << "applyTransaction: Delay: Not authorized to use account."; return tefBAD_AUTH; } else { cLog(lsINFO) << "applyTransaction: Invalid: Not authorized to use account."; return temBAD_AUTH_MASTER; } return tesSUCCESS; }
monad_t* increment_evens(int* val) { if(!val) { return nothing(); } if(0 != ((*val) % 2)) { return nothing(); } int* v2 = malloc(sizeof(int)); *v2 = (*val) + 1; return just(v2); }
TER Transactor::checkSig () { // Consistency: Check signature // Verify the transaction's signing public key is the key authorized for signing. if (mSigningPubKey.getAccountID () == mTxnAccountID) { // Authorized to continue. mSigMaster = true; if (mTxnAccount->isFlag(lsfDisableMaster)) return tefMASTER_DISABLED; } else if (mHasAuthKey && mSigningPubKey.getAccountID () == mTxnAccount->getFieldAccount160 (sfRegularKey)) { // Authorized to continue. nothing (); } else if (mHasAuthKey) { WriteLog (lsINFO, Transactor) << "applyTransaction: Delay: Not authorized to use account."; return tefBAD_AUTH; } else { WriteLog (lsINFO, Transactor) << "applyTransaction: Invalid: Not authorized to use account."; return temBAD_AUTH_MASTER; } return tesSUCCESS; }
/** Is this the all-exclusive logic? (Here, that means propositional logic) */ bool LogicInfo::hasNothing() const { PrettyCheckArgument(d_locked, *this, "This LogicInfo isn't locked yet, and cannot be queried"); LogicInfo nothing(""); nothing.lock(); return *this == nothing; }
void Cell::loadSprite() { this->viewed = false; switch (code) { case DUNGEON_FLOOR_A: dungeonFloorA(); break; case DUNGEON_WALL_A: dungeonWallA(); break; case DUNGEON_EXIT: dungeonExit(); break; case CAVERN_FLOOR_A: cavernFloorA(); break; case CAVERN_WALL_A: cavernWallA(); break; case GRASS_A: grassA(); break; case TREE_A: treeA(); break; case DUNGEON_WALL_ITEM_A: dungeonWallItemA(); break; default: nothing(); } }
bool RippleAddress::setSeedGeneric (const std::string& strText) { RippleAddress naTemp; bool bResult = true; uint256 uSeed; if (strText.empty () || naTemp.setAccountID (strText) || naTemp.setAccountPublic (strText) || naTemp.setAccountPrivate (strText) || naTemp.setNodePublic (strText) || naTemp.setNodePrivate (strText)) { bResult = false; } else if (strText.length () == 32 && uSeed.SetHex (strText, true)) { setSeed (uSeed); } else if (setSeed (strText)) { // Log::out() << "Recognized seed."; nothing (); } else { // Log::out() << "Creating seed from pass phrase."; setSeed (EdKeyPair::passPhraseToKey (strText)); } return bResult; }
Blob RippleAddress::accountPrivateDecrypt (const RippleAddress& naPublicFrom, Blob const& vucCipherText) const { CKey ckPrivate; CKey ckPublic; Blob vucPlainText; if (!ckPublic.SetPubKey (naPublicFrom.getAccountPublic ())) { // Bad public key. WriteLog (lsWARNING, RippleAddress) << "accountPrivateDecrypt: Bad public key."; } else if (!ckPrivate.SetPrivateKeyU (getAccountPrivate ())) { // Bad private key. WriteLog (lsWARNING, RippleAddress) << "accountPrivateDecrypt: Bad private key."; } else { try { vucPlainText = ckPrivate.decryptECIES (ckPublic, vucCipherText); } catch (...) { nothing (); } } return vucPlainText; }
static AbstractQoreNode* eval_notnull(const AbstractQoreNode* n, ExceptionSink* xsink) { ReferenceHolder<AbstractQoreNode> exp(n->eval(xsink), xsink); if (*xsink) return 0; return exp ? exp.release() : nothing(); }
monad_t* maybe_return(void* v) { if(v) return just(v); else return nothing(); }
void ServerOptionsPanel::ApplySchemeSettings(vgui::IScheme *pScheme) { BaseClass::ApplySchemeSettings(pScheme); vgui::HFont defaultfont = pScheme->GetFont( "MissionChooserFont", IsProportional() ); if (defaultfont == vgui::INVALID_FONT) { defaultfont = pScheme->GetFont( "Default", IsProportional() ); } m_HostNameLabel->SetFont(defaultfont); m_pHostNameEntry->SetFont(defaultfont); m_pPasswordLabel->SetFont(defaultfont); m_pServerPasswordEntry->SetFont(defaultfont); m_pMaxPlayersLabel->SetFont(defaultfont); m_pMaxPlayersCombo->SetFont(defaultfont); m_pLANCheck->SetFont(defaultfont); m_pCancelButton->SetFont(defaultfont); Color white(255,255,255,255); Color nothing(0, 0, 0, 0); m_HostNameLabel->SetFgColor(white); m_pHostNameEntry->SetFgColor(white); m_pPasswordLabel->SetFgColor(white); m_pServerPasswordEntry->SetFgColor(white); m_pMaxPlayersLabel->SetFgColor(white); m_pMaxPlayersCombo->SetFgColor(white); m_pLANCheck->SetFgColor(white); m_pLANCheck->SetDefaultColor(white, nothing); m_pLANCheck->SetArmedColor(white, nothing); m_pLANCheck->SetDepressedColor(white, nothing); }
// Returns true if the given signature could possibly match an invocation where // the given tag maps to the given value. static bool can_match_eq(value_t signature, value_t tag, value_t value) { int64_t paramc = get_signature_parameter_count(signature); // First look for a matching parameter in the signature. value_t match = nothing(); for (int64_t i = 0; i < paramc; i++) { value_t param = get_signature_parameter_at(signature, i); value_t tags = get_parameter_tags(param); if (in_array(tags, tag)) { match = param; break; } } if (is_nothing(match)) { // There was no matching parameter so this can only match if the signature // permits it as an extra argument. return get_signature_allow_extra(signature); } else { value_t guard = get_parameter_guard(match); if (get_guard_type(guard) == gtEq) { value_t eq_value = get_guard_value(guard); return value_identity_compare(value, eq_value); } else { return true; } } }
std::vector<unsigned char> RippleAddress::accountPrivateDecrypt(const RippleAddress& naPublicFrom, const std::vector<unsigned char>& vucCipherText) const { CKey ckPrivate; CKey ckPublic; std::vector<unsigned char> vucPlainText; if (!ckPublic.SetPubKey(naPublicFrom.getAccountPublic())) { // Bad public key. cLog(lsWARNING) << "accountPrivateDecrypt: Bad public key."; } else if (!ckPrivate.SetPrivateKeyU(getAccountPrivate())) { // Bad private key. cLog(lsWARNING) << "accountPrivateDecrypt: Bad private key."; } else { try { vucPlainText = ckPrivate.decryptECIES(ckPublic, vucCipherText); } catch (...) { nothing(); } } return vucPlainText; }
extern "C" __declspec(dllexport) BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { DWORD id = 0; extern const char __ihook_version__[]; switch (fdwReason) { case DLL_PROCESS_ATTACH: writeToLog(__ihook_version__); id = hookitByAddress((DWORD) ¬hing, (DWORD) &hook_nothing); if (id <= 0) { writeToLog("Something goes wrong, check returned value"); return -1; } id = hookitByName((char*)"HttpOpenRequestA", (char*)"wininet.dll", (DWORD) hook_OpenRequest); if (id <= 0) { writeToLog("Something goes wrong, check returned value"); return -2; } nothing("hook function code"); break; case DLL_PROCESS_DETACH: unhookByName((char *) "HttpOpenRequestA", (char*) "wininet.dll"); unhookByAddress((DWORD) ¬hing); break; } return TRUE; }
void Maybe_f_fmap(OPObject* _self, OPObject* _next, f_fmap_callback cb) { Maybe* self = (Maybe*) _self; Maybe* next = (Maybe*) _next; if (is_nothing(self) && self != next) { nothing(next); } cb(self->data, &next->data); }
void Maybe_m_bind(OPObject* _self, m_bind_callback cb, OPObject* _next) { Maybe* self = (Maybe*) _self; Maybe* next = (Maybe*) _next; if (is_nothing(self) && self != next) { nothing(next); } cb(self->data, _next); }
int main() { f (f (23)); m1 (46); nothing (); /* end-here */ return 0; }
static value_t init_empty_module_fragment(runtime_t *runtime, value_t fragment) { TRY_DEF(nspace, new_heap_namespace(runtime, nothing())); TRY_DEF(methodspace, new_heap_methodspace(runtime)); TRY_DEF(imports, new_heap_id_hash_map(runtime, 16)); set_module_fragment_namespace(fragment, nspace); set_module_fragment_methodspace(fragment, methodspace); set_module_fragment_imports(fragment, imports); return success(); }
monad_t* increment_odds(int* val) { if(!val || 0 == ((*val) % 2)) { return nothing(); } int* v = malloc(sizeof(int)); *v = (*val) + 1; return just(v); }
int parse_config_file(const char *fn) { FILE *f; char *line = NULL; size_t linelen = 0; char *name; char *val; struct opt *opt; struct header *hdr; int lineno = 1; unsigned h; f = fopen(fn, "r"); if (!f) return -1; hdr = NULL; while (getline(&line, &linelen, f) > 0) { char *s = strchr(line, '#'); if (s) *s = 0; s = strstrip(line); if (*s == '[') { char *p = strchr(s, ']'); if (p == NULL) parse_error(lineno, "Header without ending ]"); nothing(p + 1, lineno); *p = 0; hdr = new_header(hdr, s + 1); } else if ((val = strchr(line, '=')) != NULL) { *val++ = 0; name = strstrip(s); val = strstrip(val); opt = xalloc(sizeof(struct opt)); opt->name = xstrdup(name); opt->val = xstrdup(val); h = hash(name); if (!hdr) hdr = new_header(hdr, "global"); //printf("[%s] \"%s\" = \"%s\"\n", hdr->name, name, val); if (hdr->optslast[h] == NULL) hdr->opts[h] = opt; else hdr->optslast[h]->next = opt; hdr->optslast[h] = opt; } else if (!empty(s)) { parse_error(lineno, "config file line not field nor header"); } lineno++; } fclose(f); free(line); return 0; }
void close_frame(frame_t *frame) { value_t piece = frame->stack_piece; CHECK_FALSE("stack piece already closed", is_stack_piece_closed(piece)); bool pushed = try_push_new_frame(frame, 0, ffLid | ffSynthetic, true); CHECK_TRUE("Failed to close frame", pushed); value_t *stack_start = frame_get_stack_piece_bottom(frame); set_stack_piece_lid_frame_pointer(piece, new_integer(frame->frame_pointer - stack_start)); frame->stack_piece = nothing(); frame->frame_pointer = frame->limit_pointer = frame->stack_pointer = 0; frame->pc = 0; }
static value_t new_instance_of_string(runtime_t *runtime, value_t type) { value_t factories = ROOT(runtime, plankton_factories); value_t factory = get_id_hash_map_at(factories, type); if (in_family(ofFactory, factory)) { value_t new_instance_wrapper = get_factory_new_instance(factory); void *new_instance_ptr = get_void_p_value(new_instance_wrapper); factory_new_instance_t *new_instance = (factory_new_instance_t*) (intptr_t) new_instance_ptr; return new_instance(runtime); } else { return new_heap_seed(runtime, type, nothing()); } }
monad_t* maybe_bind(monad_t* m, monad_t* (*f)(void*)) { monad_t* rv = nothing(); if(!m) { goto cleanup; } maybe_t* maybe = (maybe_t*)(m->mvalue); if(NOTHING == maybe->type) { goto cleanup; } rv = f(maybe->value); cleanup: return rv; }
value_t compile_method_ast_to_method(runtime_t *runtime, value_t method_ast, value_t fragment) { reusable_scratch_memory_t scratch; reusable_scratch_memory_init(&scratch); TRY_FINALLY { E_TRY_DEF(signature, build_method_signature(runtime, fragment, &scratch, get_method_ast_signature(method_ast))); E_TRY_DEF(method, new_heap_method(runtime, afMutable, signature, method_ast, nothing(), fragment, new_flag_set(kFlagSetAllOff))); E_RETURN(method); } FINALLY { reusable_scratch_memory_dispose(&scratch); } YRT }
bool RippleAddress::setSeedGeneric(const std::string& strText) { RippleAddress naTemp; bool bResult = true; uint128 uSeed; if (strText.empty() || naTemp.setAccountID(strText) || naTemp.setAccountPublic(strText) || naTemp.setAccountPrivate(strText) || naTemp.setNodePublic(strText) || naTemp.setNodePrivate(strText)) { bResult = false; } else if (strText.length() == 32 && uSeed.SetHex(strText, true)) { setSeed(uSeed); } else if (setSeed(strText)) { // std::cerr << "Recognized seed." << std::endl; nothing(); } else if (1 == setSeed1751(strText)) { // std::cerr << "Recognized 1751 seed." << std::endl; nothing(); } else { // std::cerr << "Creating seed from pass phrase." << std::endl; setSeed(CKey::PassPhraseToKey(strText)); } return bResult; }
bool try_push_new_frame(frame_t *frame, size_t frame_capacity, uint32_t flags, bool is_lid) { value_t stack_piece = frame->stack_piece; CHECK_FALSE("pushing closed stack piece", is_stack_piece_closed(stack_piece)); // First record the current state of the old top frame so we can store it in // the header of the new frame. frame_t old_frame = *frame; // Determine how much room is left in the stack piece. value_t *stack_piece_start = get_stack_piece_storage(stack_piece); size_t capacity = get_integer_value(get_stack_piece_capacity(stack_piece)); value_t *stack_piece_limit = stack_piece_start + capacity; // There must always be room on a stack piece for the lid frame because it // must always be possible to close a stack if a condition occurs, which we // assume it can at any time. So we hold back a frame header's worth of stack // except when allocating the lid. if (!is_lid) stack_piece_limit -= kFrameHeaderSize; value_t *new_frame_pointer = old_frame.stack_pointer + kFrameHeaderSize; value_t *new_frame_limit = new_frame_pointer + frame_capacity; if (new_frame_limit > stack_piece_limit) return false; // Store the new frame's info in the frame struct. frame->stack_pointer = frame->frame_pointer = new_frame_pointer; frame->limit_pointer = new_frame_limit; frame->flags = new_flag_set(flags); frame->pc = 0; // Record the relevant information about the previous frame in the new frame's // header. frame_set_previous_frame_pointer(frame, old_frame.frame_pointer - stack_piece_start); frame_set_previous_limit_pointer(frame, old_frame.limit_pointer - stack_piece_start); frame_set_previous_flags(frame, old_frame.flags); frame_set_previous_pc(frame, old_frame.pc); frame_set_code_block(frame, nothing()); frame_set_argument_map(frame, nothing()); return true; }
TEST(syntax, emitting) { CREATE_RUNTIME(); value_t ast = new_heap_literal_ast(runtime, yes()); assembler_t assm; ASSERT_SUCCESS(assembler_init(&assm, runtime, nothing(), scope_get_bottom())); ASSERT_SUCCESS(emit_value(ast, &assm)); assembler_emit_return(&assm); value_t code = assembler_flush(&assm); ASSERT_SUCCESS(code); value_t result = run_code_block_until_condition(ambience, code); ASSERT_VALEQ(yes(), result); assembler_dispose(&assm); DISPOSE_RUNTIME(); }
std::string HCS_Troop::reportarmorname(unsigned int armorslot) { std::string nothing("Nothing there"); switch (armorslot) { case INV_HELMET: if (Helmet) return Helmet->getAC()->getarmorname(); break; case INV_CHEST: if (Armor) return Armor->getAC()->getarmorname(); break; case INV_SHIRT: if (Shirt) return Shirt->getAC()->getarmorname(); break; default: return nothing; } return nothing; }
static value_t new_instance_of_type(runtime_t *runtime, value_t type) { TRY_DEF(species, new_heap_instance_species(runtime, type, nothing(), vmFluid)); TRY_DEF(result, new_heap_instance(runtime, species)); return result; }
static value_t new_instance_of_seed(runtime_t *runtime, value_t type) { return new_heap_seed(runtime, type, nothing()); }