TEST(test_source_location, assignment) { auto a = here(); auto b = here(); b = a; ASSERT_EQ(a.line(), b.line()); ASSERT_STREQ(a.file(), b.file()); }
element* coerce (element* coerced, element* target){ if(target->kind == KPRIMITIVE || target->kind==KLITERAL || target->kind==KVARIABLE){ if(coerced->kind==KUNKNOWN) coerced->kind=KVARIABLE; coerced->pdtype = target->pdtype; }else if(target->kind==KOBJECT){ here(286); if(coerced->kind == KUNKNOWN){ here(288); coerced->kind = KOBJECT; } coerced->rdtype = target->rdtype; }else if(target->kind == KCLASS){ if(coerced->kind == KUNKNOWN){ coerced->kind = KOBJECT; } coerced->rdtype = target; }else{ here(55); //~ ehere(55); return NULL; } //~ if(coerced->kind == KUNKNOWN) coerced->kind=target->kind; coerced->dimensions = vector<int>(target->dimensions); return coerced; }
TEST(test_source_location, initialization){ auto a = here(); ASSERT_EQ(__LINE__-1, a.line()); ASSERT_STREQ(__FILE__, a.file()); auto b = here(); ASSERT_STREQ(a.file(), b.file()); xtd::source_location c(a); }
/* read etc... */ void ivread() { previous_obj = FALSE; if (here(BOOK)) object = BOOK; if (here(BOOK2)) addobj(BOOK2); if (here(BILLBD)) addobj(BILLBD); if (here(CARVNG)) addobj(CARVNG); if (here(MAGAZINE)) addobj(MAGAZINE); if (here(MESSAGE)) addobj(MESSAGE); if (here(OYSTER)) addobj(OYSTER); if (here(POSTER)) addobj(POSTER); if (here(TABLET)) addobj(TABLET); if (previous_obj || object == 0 || dark()) needobj(); else vread(); return; }
/* FEED */ vfeed() { int msg; switch(object) { case BIRD: msg = 100; break; case DWARF: if (!here(FOOD)) { actspk(verb); return; } ++dflag; msg = 103; break; case BEAR: if (!here(FOOD)) { if (prop[BEAR] == 0) msg = 102; else if (prop[BEAR] == 3) msg = 110; else { actspk(verb); return; } break; } dstroy(FOOD); prop[BEAR] = 1; fixed[AXE] = 0; prop[AXE] = 0; msg = 168; break; case DRAGON: msg = (prop[DRAGON] != 0 ? 110 : 102); break; case TROLL: msg = 182; break; case SNAKE: if (closed || !here(BIRD)) { msg = 102; break; } msg = 101; dstroy(BIRD); prop[BIRD] = 0; ++tally2; break; default: msg = 14; } rspeak(msg); }
void seltblgen(Node *n, int tbl, int *ends, int *ip) { Node *c, *s, *l, *t; if(n->t==NList){ /* chans are eval'ed from the top, so table is backwards */ seltblgen(n->r, tbl, ends, ip); seltblgen(n->l, tbl, ends, ip); return; } if(n->t!=NCase) panic("seltblgen"); if(n->l->t==NList) error("sorry, empty cases not implemented"); patch(tbl+*ip, (long)(here()-tbl)*WS); c=n->l->l; /* communication */ s=n->r; /* statement */ l=0; if(c->o.t=='='){ l=c->l; /* lvalue */ c=c->r; } if(c->o.t==SND){ gen(c->r, 1); if(isptrtype(etypeoft(c->l)->r)) emit(Isndptr); else emit(Isnd); } c=c->l; /* channel expression */ /* * The value is still on the stack; save it or toss it */ if(l) lgen(l); else if(c->t==NArraycom){ t=etypeoft(c->l)->r; if(t->o.t==TID) t=typeoftid(t); popgen(t->r); }else popgen(etypeoft(c)->r); if(c->t==NArraycom){ /* save array index */ if(c->r) lgen(c->r); else emit(Ipop); } gen(s, 0); emit(Ijmp); ends[*ip]=here(); (*ip)++; emitconst(0L); }
/* FILL bottle or cask must be empty, and some liquid avaible */ void ivfill() { if ((g.prop[CASK] == 1) && !here(CASK)) object = CASK; if ((g.prop[BOTTLE] == 1) && !here(BOTTLE)) object = BOTTLE; if ((here(BOTTLE) && here(CASK)) || (object == 0)) needobj(); else trverb(); }
/* * Initialize the extended trap mechanism. */ void init_extended_traps (void) { m68k_call_trapaddr = here (); calltrap (deftrap2 (m68k_call_handler, TRAPFLAG_NO_RETVAL, _T("m68k_call"))); m68k_return_trapaddr = here(); calltrap (deftrap2 (m68k_return_handler, TRAPFLAG_NO_RETVAL, _T("m68k_return"))); exit_trap_trapaddr = here(); calltrap (deftrap2 (exit_trap_handler, TRAPFLAG_NO_RETVAL, _T("exit_trap"))); uae_sem_init (&trap_mutex, 0, 1); }
static void uae_library_install (struct uae_library *library) { library->aptr_name = ds (library->name); library->aptr_id = ds (library->id); for (uae_library_trap_def *t = library->traps; t->function; t++) { t->aptr = here (); calltrap (deftrap2 (t->function, t->flags, _T(""))); dw (RTS); } library->aptr_func_table = here (); for (uae_library_trap_def *t = library->traps + 1; t->function; t++) { dl (t->aptr); } dl (0xFFFFFFFF); // end of table library->aptr_data_table = here (); dw (0xE000); // INITBYTE dw (0x0008); // LN_TYPE dw (0x0900); // NT_LIBRARY dw (0xE000); // INITBYTE dw (0x0009); // LN_PRI dw (0xCE00); // -50 dw (0xC000); // INITLONG dw (0x000A); // LN_NAME dl (library->aptr_name); dw (0xE000); // INITBYTE dw (0x000E); // LIB_FLAGS dw (0x0600); // LIBF_SUMUSED | LIBF_CHANGED dw (0xD000); // INITWORD dw (0x0014); // LIB_VERSION dw (library->version); dw (0xD000); dw (0x0016); // LIB_REVISION dw (library->revision); dw (0xC000); dw (0x0018); // LIB_IDSTRING dl (library->aptr_id); dl (0x00000000); // end of table library->aptr_init = here (); dl (SIZEOF_LIBRARY + library->data_size); dl (library->aptr_func_table); dl (library->aptr_data_table); dl (library->traps[0].aptr); write_log (_T("%s installed (%s)\n"), library->name, MODULE_SUFFIX); }
void uaeres_install (void) { uae_u32 functable, datatable; uae_u32 initcode, getfunc; TCHAR tmp[100]; _stprintf (tmp, L"UAE resource %d.%d.%d", UAEMAJOR, UAEMINOR, UAESUBREV); res_name = ds (L"uae.resource"); res_id = ds (tmp); /* initcode */ initcode = here (); calltrap (deftrap (res_initcode)); dw (RTS); /* getfunc */ getfunc = here (); calltrap (deftrap (res_getfunc)); dw (RTS); /* FuncTable */ functable = here (); dl (getfunc); /* getfunc */ dl (0xFFFFFFFF); /* end of table */ /* DataTable */ datatable = here (); dw (0xE000); /* INITBYTE */ dw (0x0008); /* LN_TYPE */ dw (0x0800); /* NT_RESOURCE */ dw (0xC000); /* INITLONG */ dw (0x000A); /* LN_NAME */ dl (res_name); dw (0xE000); /* INITBYTE */ dw (0x000E); /* LIB_FLAGS */ dw (0x0600); /* LIBF_SUMUSED | LIBF_CHANGED */ dw (0xD000); /* INITWORD */ dw (0x0014); /* LIB_VERSION */ dw (UAEMAJOR); dw (0xD000); /* INITWORD */ dw (0x0016); /* LIB_REVISION */ dw (UAEMINOR); dw (0xC000); /* INITLONG */ dw (0x0018); /* LIB_IDSTRING */ dl (res_id); dw (0x0000); /* end of table */ res_init = here (); dl (SIZEOF_LIBRARY + 16); /* size of device base */ dl (functable); dl (datatable); dl (initcode); }
bool iscoerciblelist(listofelements* list, element* target){ if(target->kind != KPRIMITIVE && target->kind!= KCLASS){ here(53); return false; } listofelements* node = list; while(node!=NULL){ if(!iscoercible(node->elem, target)){ here(54); return false; } node = node->next; } return true; }
bool iscoerciblelisttolist(listofelements* coerced, listofelements* target){ listofelements *cnode = coerced, *tnode = target; while(cnode!=NULL && tnode!=NULL){ if(!iscoercible(cnode->elem, tnode->elem)){ here(60); return false; } tnode = tnode->next; cnode= cnode->next; } if(cnode==NULL && tnode==NULL) return true; here(61); return false; }
TEST(test_source_location, comparison) { { auto a = here(); auto b = here(); ASSERT_FALSE(a == b); ASSERT_TRUE(a < b); b = a; ASSERT_TRUE(a == b); } { xtd::source_location a("a", 123); xtd::source_location b("b", 123); ASSERT_TRUE(a < b); } }
bool H4Queues::getNextTxPacket() { CriticalSection::Lock here(cs); #ifdef H4_MULTIQUEUE assert(txActiveQueue == -1); for (int queueNum = 0; queueNum < H4_NUMQUEUES; ++queueNum) { if (!queue[queueNum].list.empty()) { assert(packetCount != 0); txActiveQueue = queueNum; return true; } } #else if (!queue.list.empty()) { assert(packetCount != 0); return true; } #endif assert(packetCount == 0); return false; }
uaecptr libemu_InstallFunctionFlags (TrapFunction f, uaecptr libbase, int offset, int flags, const char *tracename) { int i; uaecptr retval; uaecptr execbase = get_long (four); int trnum; uaecptr addr = here(); calltrap (trnum = deftrap2 (f, flags, tracename)); dw (RTS); _68k_areg(1) = libbase; _68k_areg(0) = offset; _68k_dreg(0) = addr; retval = CallLib (execbase, -420); trapoldfunc[trnum] = retval; #if 0 for (i = 0; i < n_libpatches; i++) { if (libpatches[i].libbase == libbase) break; } if (i == n_libpatches) { int j; libpatches[i].libbase = libbase; for (j = 0; j < 300; j++) libpatches[i].functions[j] = NULL; n_libpatches++; } libpatches[i].functions[-offset/6] = f; #endif return retval; }
Statement* Expand::operator()(Mixin_Call* c) { string full_name(c->name() + "[m]"); if (!env->has(full_name)) { error("no mixin named " + c->name(), c->path(), c->position(), backtrace); } Definition* def = static_cast<Definition*>((*env)[full_name]); Block* body = def->block(); Parameters* params = def->parameters(); Arguments* args = static_cast<Arguments*>(c->arguments() ->perform(eval->with(env, backtrace))); Backtrace here(backtrace, c->path(), c->position(), ", in mixin `" + c->name() + "`"); backtrace = &here; Env new_env; new_env.link(def->environment()); if (c->block()) { // represent mixin content blocks as thunks/closures Definition* thunk = new (ctx.mem) Definition(c->path(), c->position(), "@content", new (ctx.mem) Parameters(c->path(), c->position()), c->block(), Definition::MIXIN); thunk->environment(env); new_env.current_frame()["@content[m]"] = thunk; } bind("mixin " + c->name(), params, args, ctx, &new_env, eval); Env* old_env = env; env = &new_env; append_block(body); env = old_env; backtrace = here.parent; return 0; }
element* findtypeinthisorsuper(element* pelement, namenode* node, bool respectprivacy){ if(node==NULL){ return pelement; } element* e = pelement; unordered_map<string, element*>::iterator it; while(e!=NULL){ if(e->desc != NULL){ it = e->desc->symtbl.find(node->name); if(LDEBUG) fprintf(stderr, "findtypeinthisorsuper(): finding %s in %s\n", node->name.c_str(), e->name.c_str()); //printsymtbl(e->desc->symtbl); if(it != e->desc->symtbl.end()){ if(LDEBUG) fprintf(stderr, "findtypeinthisorsuper(): %s found in %s\n", node->name.c_str(), e->name.c_str()); if(it->second->mod == APRIVATE && respectprivacy== true){ fprintf(stderr, "error at line #%d: class/member %s not accessible", line_number, node->name.c_str()); here(36); return NULL; }else{ return findtypeinthisorsuper(it->second, node->next, respectprivacy); } } if(LDEBUG) fprintf(stderr, "findtypeinthisorsuper(): %s not found in %s\n", node->name.c_str(), e->name.c_str()); } e = e->superclass; } fprintf(stderr, "findtypeinthisorsuper(): error at line #%d: class/member %s not found", line_number, node->name.c_str()); return NULL; }
static int initint (TrapContext *ctx) { uae_u32 tmp1; uaecptr p; if (irq_init) return 1; m68k_dreg (regs, 0) = 26; m68k_dreg (regs, 1) = 65536 + 1; p = CallLib (ctx, get_long (4), -0xC6); /* AllocMem */ if (!p) return 0; tmp1 = here (); calltrap (deftrap2 (uaenet_int_handler, TRAPFLAG_EXTRA_STACK, _T("uaenet_int_handler"))); put_word (p + 8, 0x020a); put_long (p + 10, ROM_netdev_resid); put_long (p + 18, tmp1); m68k_areg (regs, 1) = p; m68k_dreg (regs, 0) = 3; /* PORTS */ dw (0x4a80); /* TST.L D0 */ dw (0x4e75); /* RTS */ CallLib (ctx, get_long (4), -168); /* AddIntServer */ irq_init = 1; return 1; }
void simlog::write(const char* file, const char* func, int line, u8string const& group, Level level, const char* fmt, ...) { if (level <= config.verbosity) { lock_guard_t here(mutex); std::va_list arg_list; va_start(arg_list, fmt); msg_buff_.format(config.buff.msg_max_size, fmt, arg_list); va_end(arg_list); line_buff_.format(config.buff.line_buff_size, fmt_str_.c_str(), config.format.fieldset[Column::DATETIME] ? get_datetime_() : "", config.format.fieldset[Column::EPOCHTIME] ? (size_t) std::chrono::duration_cast<std::chrono::microseconds>(clock_t::now() - epoch_).count() : 0, config.format.fieldset[Column::THREAD] ? thread_hash_(std::this_thread::get_id()) : 0, config.format.fieldset[Column::FILE] ? file : "", config.format.fieldset[Column::FUNC] ? func : "", config.format.fieldset[Column::LINE] ? line : 0, config.format.fieldset[Column::GROUP] ? group.c_str() : "", config.format.fieldset[Column::LEVEL] ? level_string[level].c_str() : "", config.format.fieldset[Column::MESSAGE] ? msg_buff_.c_str() : ""); if (config.buff.enable) { buff_.append(line_buff_); if (!config.buff.enable || buff_.size() > config.buff.size) { flush(); } } else { (*ostream_) << line_buff_ << std::flush; } } }
/* * Initialize the extended trap mechanism. */ void init_extended_traps (void) { m68k_call_trapaddr = here (); calltrap (deftrap2 ((TrapHandler)m68k_call_handler, TRAPFLAG_NO_RETVAL, "m68k_call")); m68k_return_trapaddr = here(); calltrap (deftrap2 ((TrapHandler)m68k_return_handler, TRAPFLAG_NO_RETVAL, "m68k_return")); exit_trap_trapaddr = here(); calltrap (deftrap2 ((TrapHandler)exit_trap_handler, TRAPFLAG_NO_RETVAL, "exit_trap")); if(trap_mutex != 0) uae_sem_destroy(&trap_mutex); trap_mutex = 0; uae_sem_init (&trap_mutex, 0, 1); }
/* * Define an emulator trap * * handler_func = host function that will be invoked to handle this trap * flags = trap attributes * name = name for debugging purposes * * returns trap number of defined trap */ unsigned int define_trap (TrapHandler handler_func, int flags, const TCHAR *name) { if (trap_count == MAX_TRAPS) { write_log (_T("Ran out of emulator traps\n")); abort (); return -1; } else { unsigned int i; unsigned int trap_num; struct Trap *trap; uaecptr addr = here (); for (i = 0; i < trap_count; i++) { if (addr == traps[i].addr) return i; } trap_num = trap_count++; trap = &traps[trap_num]; trap->handler = handler_func; trap->flags = flags; trap->name = name; trap->addr = addr; return trap_num; } }
void trlrgen(void) { if(returnloc){ emit(Ijmp); emitconst((long)(returnloc-here()-1)*WS); return; } returnloc=here(); fdecrefgen(formals, -4*WS); emit(Iret); if(formals) emitconst(length(formals)*WS); else emitconst(0L); }
/// accepted new incoming connection void parcelport::handle_accept(boost::system::error_code const& e, server::shmem::parcelport_connection_ptr conn) { if (!e) { // handle this incoming parcel server::shmem::parcelport_connection_ptr c(conn); // hold on to conn // create new connection waiting for next incoming parcel conn.reset(new server::shmem::parcelport_connection( io_service_pool_.get_io_service(), here(), *this)); acceptor_->async_accept(conn->window(), boost::bind(&parcelport::handle_accept, this->shared_from_this(), boost::asio::placeholders::error, conn)); { // keep track of all the accepted connections lcos::local::spinlock::scoped_lock l(mtx_); accepted_connections_.insert(c); } // now accept the incoming connection by starting to read from the // data window c->async_read(boost::bind(&parcelport::handle_read_completion, this->shared_from_this(), boost::asio::placeholders::error, c)); } else { // remove this connection from the list of known connections lcos::local::spinlock::scoped_lock l(mtx_); accepted_connections_.erase(conn); } }
long MainPlayer::potentialMobilityHeuristic(const GameBoard &gameBoard, Tile tile) { long potentialMobility = 0; auto gameSize = gameBoard.getGameSize(); auto enemyTile = gameBoard.getEnemyTile(tile); for (size_t row = 0; row < gameSize; ++row) { for (size_t column = 0; column < gameSize; ++column) { Cell here(row, column); if (gameBoard.getAt(here) != tile) { continue; } for (int offsetRow = -1; offsetRow < 2; ++offsetRow) { for (int offsetCol = -1; offsetCol < 2; ++offsetCol) { if (offsetCol == 0 && offsetRow == 0) { continue; } Direction direction(offsetRow, offsetCol); auto neighbor = here; neighbor.move(direction); if (gameBoard.isCorrect(neighbor) && gameBoard.getAt(neighbor) == enemyTile) { ++potentialMobility; } } } } } return potentialMobility; }
element* findobject(scope* pscope, namenode* node, kindof kind){ if(LDEBUG) fprintf(stderr, "findobject(): finding %s in scope %s\n", node->name.c_str(), pscope->lexeme.c_str()); //printsymtbl(pscope->symtbl); //if(pscope == NULL) return NULL; element* e; namenode* n = new namenode(); n->name = node->name; n->next = NULL; element* first = findtype(pscope, n, KALL); if(first!=NULL){ if(LDEBUG) fprintf(stderr, "findobject(): %s found\n", node->name.c_str()); e = findobjectinthisorsuper(first, node->next, true); return e; } scope* s = pscope->parent; unordered_map<string, element*>::iterator it; while(s != NULL){ //printf("findtype(): finding %s in scope %s\n", node->name.c_str(), s->lexeme.c_str()); //printsymtbl(s->symtbl); n->name = node->name; n->next = NULL; first = findtype(pscope, n, KALL); if(first!=NULL){ e = findobjectinthisorsuper(first, node->next, true); if(e!=NULL && (kind == KALL || e->kind == kind)) return e; } s = s->parent; } fprintf(stderr, "error at line #%d: %s does not exist or is not accessible in this scope\n", line_number, node->name.c_str()); here(35); return makeIllegalNode(); }
bool alreadypresent(string& str){ symmap::iterator it = current->symtbl.find(string(str)); if(it==current->symtbl.end()) return false; here(399); return true; }
/* pirate stuff */ void dopirate() { int j; boolean k; if (g.newloc == g.chloc || g.prop[CHEST] >= 0) return; k = FALSE; /* Pirate won't take pyramid from plover room or dark room (too easy! ) */ for (j = 1; j < MAXOBJ; ++j) if (treasr(j) && !(j == CASK && liq(CASK) == WINE) && !(j == PYRAMID && (g.newloc == g.place[PYRAMID] || g.newloc == g.place[EMERALD]))) { if (toting(j) && athand(j)) goto stealit; if (here(j)) k = TRUE; } if (g.tally == g.tally2 + 1 && k == FALSE && g.place[CHEST] == 0 && athand(LAMP) && g.prop[LAMP] == 1) { rspeak(186); move(CHEST, g.chloc); move(MESSAGE, g.chloc2); g.dloc[DWARFMAX] = g.chloc; g.odloc[DWARFMAX] = g.chloc; g.dseen[DWARFMAX] = 0; return; } if (g.odloc[DWARFMAX] != g.dloc[DWARFMAX] && pct(30)) rspeak(127); return; stealit: rspeak(128); /* don't steal chest back from troll! */ if (g.place[MESSAGE] == 0) move(CHEST, g.chloc); move(MESSAGE, g.chloc2); for (j = 1; j < MAXOBJ; ++j) { if (!treasr(j) || !athand(j) || (j == PYRAMID && (g.newloc == plac[PYRAMID] || g.newloc == plac[EMERALD])) || (j == CASK && (liq(CASK) != WINE))) continue; if (enclosed(j)) extract(j); if (wearng(j)) { g.prop[j] = 0; bitoff(j, WEARBT); } insert(j, CHEST); } g.dloc[DWARFMAX] = g.chloc; g.odloc[DWARFMAX] = g.chloc; g.dseen[DWARFMAX] = FALSE; return; }
int main( ) { grrrrrrrr<whyyyyyyy<double>*> man; no_future<double> here(man); return 0; }
void AclDataTracker::removeConnection(uint16 handle) { // Lock critical section for duration of this scope CriticalSection::Lock here(protect_list); // don't remove a connection that is not there if ( connections.find(handle) != connections.end() ) connections.erase(connections.find(handle)); }
// not really necessary with a map, but we may want to // change the underlying impl. void AclDataTracker::addConnection(uint16 handle) { // Lock critical section for duration of this scope CriticalSection::Lock here(protect_list); // don't add a connection that is already there if ( connections.find(handle) == connections.end() ) connections[handle] = 0; }