codec_e file_header_t::get_codec() const { auto f = fourcc_c{fourcc}; if (f.equiv("VP80")) return VP8; if (f.equiv("VP90")) return VP9; return UNKNOWN_CODEC; }
void tex::set_math_char(int c) { ptr p; if (c >= 0100000) { cur_cs = active_base[cur_chr]; cur_cmd = eq_type(cur_cs); cur_chr = equiv(cur_cs); x_token(); back_input(); } else { p = new_noad(); math_type(nucleus(p)) = MATH_CHAR; character(nucleus(p)) = c % 256; fam(nucleus(p)) = c / 256 % 16; if (c >= VAR_CODE) { if (fam_in_range()) fam(nucleus(p)) = cur_fam; type(p) = ORD_NOAD; } else { type(p) = ORD_NOAD + c / 010000; } tail_append(p); } }
void tex::scan_math(ptr p) { int c; restart: get_nbrx_token(); reswitch: switch (cur_cmd) { case LETTER: case OTHER_CHAR: case CHAR_GIVEN: c = math_code(cur_chr); if (c == 0100000) { cur_cs = active_base[cur_chr]; cur_cmd = eq_type(cur_cs); cur_chr = equiv(cur_cs); x_token(); back_input(); goto restart; } break; case CHAR_NUM: scan_char_num(); cur_chr = cur_val; cur_cmd = CHAR_GIVEN; goto reswitch; case MATH_CHAR_NUM: scan_fifteen_bit_int(); c = cur_val; break; case MATH_GIVEN: c = cur_chr; break; case DELIM_NUM: scan_twenty_seven_bit_int(); c = cur_val / 010000; break; default: back_input(); scan_left_brace(); saved(0) = p; incr(save_ptr); push_math(MATH_GROUP); return; } math_type(p) = MATH_CHAR; character(p) = c % 256; if (c >= VAR_CODE && fam_in_range()) { fam(p) = cur_fam; } else { fam(p) = c / 256 % 16; } }
/** * Dispose of the data structure. */ void list_free(list_t **list_ptr) { g_assert(list_ptr); if (*list_ptr) { list_t *list; list = *list_ptr; g_assert(LIST_MAGIC == list->magic); g_assert(equiv(list->length == 0, list->tail == NULL)); list_regression(list); if (--list->refcount != 0) { g_critical("%s(): list is still referenced! " "(list=%p, list->refcount=%d)", G_STRFUNC, cast_to_constpointer(list), list->refcount); } gm_list_free_null(&list->head); list->tail = NULL; list->magic = 0; WFREE(list); *list_ptr = NULL; } }
// Add a new function to the set int FunctionSet::encapsulate (S_Expression *s, int nargs) { // Construct a name char buffer[16]; sprintf (buffer, "(E%d)", nencapsulated); ++nencapsulated; // If we need more space, allocate it if (n == maxn - 1) { maxn *= 2; functions = (SFunction *) realloc (functions, maxn * sizeof (SFunction)); } for (int i = 0; i < n; ++i) { if (functions[i].s && equiv (s, functions[i].s)) return i; } // Okay, it's not a duplicate, so we add it functions[n].name = strdup (buffer); functions[n].nargs = nargs; functions[n].func = NULL; functions[n].edit = NULL; functions[n].active = 1; functions[n].side_effects = s->side_effects(); functions[n].s = s->copy(); cout << "\nEncapsulating " << buffer << " = " << functions[n].s << '\n'; cout.flush(); n++; return (n-1); }
void tokenlist_to_lua(lua_State * L, int p) { int cmd, chr, cs; int v; int i = 1; v = p; while (v != null && v < (int) fix_mem_end) { i++; v = token_link(v); } i = 1; lua_createtable(L, i, 0); while (p != null && p < (int) fix_mem_end) { if (token_info(p) >= cs_token_flag) { cs = token_info(p) - cs_token_flag; cmd = eq_type(cs); chr = equiv(cs); make_token_table(L, cmd, chr, cs); } else { cmd = token_cmd(token_info(p)); chr = token_chr(token_info(p)); make_token_table(L, cmd, chr, 0); } lua_rawseti(L, -2, i++); p = token_link(p); } }
codec_c file_header_t::get_codec() const { auto f = fourcc_c{fourcc}; return codec_c::look_up( f.equiv("VP80") ? codec_c::type_e::V_VP8 : f.equiv("VP90") ? codec_c::type_e::V_VP9 : codec_c::type_e::UNKNOWN); }
void primitive_def(const char*s,size_t l,quarterword c,halfword o) { int nncs= no_new_control_sequence; no_new_control_sequence= false; cur_val= string_lookup(s,l); no_new_control_sequence= nncs; eq_level(cur_val)= level_one; eq_type(cur_val)= c; equiv(cur_val)= o; }
static inline void slist_check(const slist_t *slist) { g_assert(slist); g_assert(LIST_MAGIC == slist->magic); g_assert(slist->refcount > 0); g_assert(slist->length >= 0); g_assert(equiv(slist->length == 0, !slist->head && !slist->tail)); slist_regression(slist); }
inline static int lua_tokenlib_get_mode(lua_State * L) { lua_token *n = check_istoken(L, 1); halfword t = token_info(n->token); if (t >= cs_token_flag) { lua_pushinteger(L, equiv(t - cs_token_flag)); } else { lua_pushinteger(L, token_chr(t)); } return 1; }
static inline void list_check(const list_t *list) { g_assert(list); g_assert(LIST_MAGIC == list->magic); g_assert(list->refcount > 0); g_assert(list->length >= 0); g_assert(equiv(list->length == 0, !list->head && !list->tail)); list_regression(list); }
boolean is_primitive(str_number csname) { int n,m; char*ss; m= prim_lookup(csname); ss= makecstring(csname); n= string_lookup(ss,str_length(csname)); free(ss); return((n!=undefined_cs_cmd)&& (m!=undefined_primitive)&& (eq_type(n)==prim_eq_type(m))&&(equiv(n)==prim_equiv(m))); }
bool OccArea::isFreeBuilding() const { if ( m_occupant || !hasFreeFloor() ) { return false; } for (int a = getTopLeft().x - 1; a < getBottomRight().x + 1; a++) { if (!equiv(Field::current()->getItem(Coord(a, getTopLeft().y - 1)), WALL)) return false; if (!equiv(Field::current()->getItem(Coord(a, getBottomRight().y)), WALL)) return false; } for (int b = getTopLeft().y;b < getBottomRight().y; b++) { if (!equiv(Field::current()->getItem(Coord(getTopLeft().x - 1, b)), WALL)) return false; if (!equiv(Field::current()->getItem(Coord(getBottomRight().x, b)), WALL)) return false; } return true; }
inline static int lua_tokenlib_get_protected(lua_State * L) { lua_token *n = check_istoken(L, 1); halfword t = token_info(n->token); int cmd = (t >= cs_token_flag ? eq_type(t - cs_token_flag) : token_cmd(t)); if (cmd > max_command_cmd && (cmd >= call_cmd) && (cmd < end_template_cmd)) { int chr = (t >= cs_token_flag ? equiv(t - cs_token_flag) : token_chr(t)); if (token_info(token_link(chr)) == protected_token) { lua_pushboolean(L, 1); } else { lua_pushboolean(L, 0); } } else { lua_pushboolean(L, 0); } return 1; }
static int run_lookup(lua_State * L) { const char *s; size_t l; int cs, cmd, chr; if (lua_type(L, -1) == LUA_TSTRING) { s = lua_tolstring(L, -1, &l); if (l > 0) { cs = string_lookup(s, l); cmd = eq_type(cs); chr = equiv(cs); make_new_token(L, cmd, chr, cs); return 1; } } lua_pushnil(L); return 1; }
static int run_build(lua_State * L) { if (lua_type(L, 1) == LUA_TNUMBER) { int cs = 0; int chr = (int) lua_tointeger(L, 1); int cmd = (int) luaL_optinteger(L, 2, get_cat_code(cat_code_table_par,chr)); if (cmd == 0 || cmd == 9 || cmd == 14 || cmd == 15) { formatted_warning("token lib","not a good token, catcode %i can not be returned, so 12 will be used",(int) cmd); cmd = 12; } else if (cmd == 13) { cs = active_to_cs(chr, false); cmd = eq_type(cs); chr = equiv(cs); } make_new_token(L, cmd, chr, cs); return 1; } else { return run_lookup(L); } }
inline static int lua_tokenlib_get_index(lua_State * L) { int cmd, chr; lua_token *n = check_istoken(L, 1); halfword t = token_info(n->token); if (t >= cs_token_flag) { cmd = eq_type(t - cs_token_flag); chr = equiv(t - cs_token_flag); } else { cmd = token_cmd(t); chr = token_chr(t); } switch (cmd) { case assign_int_cmd: chr -= count_base; break; case assign_attr_cmd: chr -= attribute_base; break; case assign_dimen_cmd: chr -= scaled_base; break; case assign_glue_cmd: chr -= skip_base; break; case assign_mu_glue_cmd: chr -= mu_skip_base; break; case assign_toks_cmd: chr -= toks_base; break; default: break; } if (chr >= 0 && chr <= 65535) { lua_pushinteger(L, chr); } else { lua_pushnil(L); } return 1; }
// configuration-dependent startup static char *config_tests( void ) { // malloc our gauge field and initialise our lattice geometry lat = NULL ; if( ( lat = allocate_lat( ) ) == NULL ) { fprintf( stderr , "[CONFIG-UNIT] Gauge field allocation failure\n" ) ; return NULL ; } init_navig( lat ) ; // randomly generate an SU(NC) field random_suNC( lat ) ; // allocate gauge transformed fields glat = NULL ; if( ( glat = allocate_lat( ) ) == NULL ) { fprintf( stderr , "[CONFIG-UNIT] Gauge field 2 allocation failure\n" ) ; return NULL ; } init_navig( glat ) ; size_t i , mu ; for( i = 0 ; i < LVOLUME ; i++ ) { for( mu = 0 ; mu < ND ; mu++ ) { equiv( glat[i].O[mu] , lat[i].O[mu] ) ; } } // assumes gtrans works properly random_gtrans( glat ) ; // test gauge invariant stuff mu_run_test( av_plaquette_test ) ; mu_run_test( polyakov_test ) ; free( lat ) ; free( glat ) ; return 0 ; }
int get_tex_extension_toks_register(int i) { return equiv(backend_toks_base+i); }
void tex::conditional () { bool b=false; sym s; int m, n; ptr p, q, r; int this_if; ptr save_cond_ptr; int save_scanner_status; push_cond(); save_cond_ptr = cond_ptr; this_if = cur_chr; switch (this_if) { case IF_CHAR_CODE: case IF_CAT_CODE: #define get_x_token_or_active_char() {get_x_token(); \ if (cur_cmd == RELAX && cur_chr == NO_EXPAND_FLAG) { \ cur_cmd = ACTIVE_CHAR; \ cur_chr = tok2sym(cur_tok) - active_base[0]; }} get_x_token_or_active_char(); if (cur_cmd > ACTIVE_CHAR || cur_chr > 255) { m = RELAX; n = 256; } else { m = cur_cmd; n = cur_chr; } get_x_token_or_active_char(); if (cur_cmd > ACTIVE_CHAR || cur_chr > 255) { cur_cmd = RELAX; cur_chr = 256; } if (this_if == IF_CHAR_CODE) { b = n == cur_chr; } else { b = m == cur_cmd; } break; case IF_INT_CODE: case IF_DIM_CODE: if (this_if == IF_INT_CODE) { scan_int(); } else { scan_normal_dimen(); } n = cur_val; get_nbx_token(); if (cur_tok >= OTHER_TOKEN + '<' && cur_tok <= OTHER_TOKEN + '>') { r = cur_tok - OTHER_TOKEN; } else { print_err("Missing = inserted for "); print_cmd_chr(IF_TEST, this_if); help_relation(); back_error(); r = '='; } if (this_if == IF_INT_CODE) { scan_int(); } else { scan_normal_dimen(); } switch (r) { case '<': b = n < cur_val; break; case '=': b = n == cur_val; break; case '>': b = n > cur_val; break; } break; case IF_ODD_CODE: scan_int(); b = odd(cur_val); break; case IF_VMODE_CODE: b = abs(mode) == VMODE; break; case IF_HMODE_CODE: b = abs(mode) == HMODE; break; case IF_MMODE_CODE: b = abs(mode) == MMODE; break; case IF_INNER_CODE: b = mode < 0; break; case IF_VOID_CODE: case IF_HBOX_CODE: case IF_VBOX_CODE: scan_eight_bit_int(); p = box(cur_val); if (this_if == IF_VOID_CODE) { b = p == null; } else if (p == null) { b = FALSE; } else if (this_if == IF_HBOX_CODE) { b = type(p) == HLIST_NODE; } else { b = type(p) == VLIST_NODE; } break; case IFX_CODE: save_scanner_status = scanner_status; scanner_status = NORMAL; get_next(); s = cur_cs; p = cur_cmd; q = cur_chr; get_next(); if (cur_cmd != p) { b = FALSE; } else if (cur_cmd < CALL) { b = cur_chr == q; } else { p = token_link(cur_chr); q = token_link(equiv(s)); if (p == q) { b = TRUE; } else { while (p != null && q != null) { if (token(p) != token(q)) { p = null; } else { p = token_link(p); q = token_link(q); } } b = p == null && q == null; } } scanner_status = save_scanner_status; break; case IF_EOF_CODE: scan_four_bit_int(); b = read_open[cur_val] == CLOSED; break; case IF_TRUE_CODE: b = TRUE; break; case IF_FALSE_CODE: b = FALSE; break; case IF_CASE_CODE: scan_int(); n = cur_val; if (tracing_commands > 1) { begin_diagnostic(); print("{case "); print_int(n); print("}"); end_diagnostic(FALSE); } while (n != 0) { pass_text(); if (cond_ptr == save_cond_ptr) { if (cur_chr == OR_CODE) { decr(n); } else { goto common_end; } } else if (cur_chr == FI_CODE) { pop_cond(); } } change_if_limit(OR_CODE, save_cond_ptr); return; default: break; } if (tracing_commands > 1) { begin_diagnostic(); print(b ? "{true}" : "{false}"); end_diagnostic(FALSE); } if (b) { change_if_limit(ELSE_CODE, save_cond_ptr); return; } loop { pass_text(); if (cond_ptr == save_cond_ptr) { if (cur_chr != OR_CODE) goto common_end; print_err("Extra "); print_esc("or"); help_or(); error(); } else if (cur_chr == FI_CODE) { pop_cond(); } } common_end: if (cur_chr == FI_CODE) { pop_cond(); } else { if_limit = FI_CODE; } }
bool equiv(const QRoutine * a, const QRoutine * b) { LP3_ASSERT(nullptr != a); LP3_ASSERT(nullptr != b); return equiv(*a, *b); }