Lines Matching refs:env

39 void (*crash_ptr)(fcode_env_t *env) = do_crash;
42 next_bytecode(fcode_env_t *env) in next_bytecode() argument
46 byte = *env->fcode_ptr; in next_bytecode()
47 env->fcode_ptr += env->fcode_incr; in next_bytecode()
52 get_next_token(fcode_env_t *env) in get_next_token() argument
54 ushort_t token = next_bytecode(env); in get_next_token()
56 token = (token << 8) | next_bytecode(env); in get_next_token()
58 env->last_fcode = token; in get_next_token()
63 get_short(fcode_env_t *env) in get_short() argument
70 u = next_bytecode(env) << 8; in get_short()
71 return (u | next_bytecode(env)); in get_short()
75 get_int(fcode_env_t *env) in get_int() argument
82 u = get_short(env) << 16; in get_int()
83 return (u | get_short(env)); in get_int()
87 expose_acf(fcode_env_t *env, char *name) in expose_acf() argument
93 LINK_TO_ACF(env->lastlink), name, env->current); in expose_acf()
97 do_code(fcode_env_t *env, int token, char *name, void (*fn)(fcode_env_t *)) in do_code() argument
99 env->table[token].name = name; in do_code()
101 env->table[token].apf = NULL; in do_code()
102 env->table[token].name = name; in do_code()
104 header(env, name, strlen(name), 0); in do_code()
105 env->table[token].apf = (acf_t)HERE; in do_code()
107 expose_acf(env, name); in do_code()
112 define_word(fcode_env_t *env, int flag, char *name, void (*fn)(fcode_env_t *)) in define_word() argument
114 header(env, name, strlen(name), flag); in define_word()
116 expose_acf(env, name); in define_word()
120 end0(fcode_env_t *env) in end0() argument
122 env->interpretting = 0; in end0()
126 end1(fcode_env_t *env) in end1() argument
128 env->interpretting = 0; in end1()
132 blit(fcode_env_t *env) in blit() argument
134 fstack_t d = (int)get_int(env); in blit()
136 literal(env); in blit()
139 void (*bbranch_ptrs[3])(fcode_env_t *env) = {
146 branch_common(fcode_env_t *env, short direction, fstack_t which, int doswap) in branch_common() argument
153 set_temporary_compile(env); in branch_common()
156 bmark(env); in branch_common()
158 swap(env); in branch_common()
160 compile_comma(env); in branch_common()
170 for (sp = env->ds; sp >= env->ds0; sp--) { in branch_common()
176 if (sp < env->ds0) in branch_common()
181 for (; sp < env->ds; sp++) in branch_common()
185 env->level--; in branch_common()
186 compile_comma(env); in branch_common()
187 temporary_execute(env); in branch_common()
192 bbranch(fcode_env_t *env) in bbranch() argument
194 short offset = (short)get_short(env); in bbranch()
196 branch_common(env, offset, 0, 1); in bbranch()
200 bqbranch(fcode_env_t *env) in bqbranch() argument
202 short offset = (short)get_short(env); in bqbranch()
204 branch_common(env, offset, 1, 0); in bqbranch()
208 do_quote(fcode_env_t *env) in do_quote() argument
222 bquote(fcode_env_t *env) in bquote() argument
228 count = len = next_bytecode(env); in bquote()
229 if (env->state) { in bquote()
234 *strptr++ = next_bytecode(env); in bquote()
236 set_here(env, (uchar_t *)strptr, "bquote"); in bquote()
237 token_roundup(env, "bquote"); in bquote()
241 *strptr++ = next_bytecode(env); in bquote()
243 push_string(env, stringbuff, len); in bquote()
276 header(fcode_env_t *env, char *name, int len, flag_t flag) in header() argument
284 token_roundup(env, "header"); in header()
301 *dptr = *((acf_t)env->current); in header()
302 env->lastlink = dptr++; in header()
303 set_here(env, (uchar_t *)dptr, "header"); in header()
305 if (name_is_debugged(env, name)) { in header()
307 add_debug_acf(env, LINK_TO_ACF(env->lastlink)); in header()
313 token_common(fcode_env_t *env, int headered, int visible) in token_common() argument
321 len = next_bytecode(env); in token_common()
323 c = next_bytecode(env); in token_common()
332 token = get_short(env); in token_common()
333 env->last_token = token; in token_common()
338 header(env, namebuff, len, 0); in token_common()
339 env->table[token].flags = 0; in token_common()
341 env->table[token].name = MALLOC(len+1); in token_common()
342 strncpy(env->table[token].name, namebuff, len); in token_common()
344 env->table[token].name = NULL; in token_common()
346 env->last_token = token; in token_common()
350 named_token(fcode_env_t *env) in named_token() argument
352 token_common(env, 1, env->fcode_debug); in named_token()
356 external_token(fcode_env_t *env) in external_token() argument
358 token_common(env, 1, 1); in external_token()
362 new_token(fcode_env_t *env) in new_token() argument
364 token_common(env, 0, 0); in new_token()
368 offset16(fcode_env_t *env) in offset16() argument
370 env->offset_incr = 2; in offset16()
374 minus_one(fcode_env_t *env) in minus_one() argument
380 zero(fcode_env_t *env) in zero() argument
386 one(fcode_env_t *env) in one() argument
392 two(fcode_env_t *env) in two() argument
398 three(fcode_env_t *env) in three() argument
404 version1(fcode_env_t *env) in version1() argument
406 env->fcode_incr = 1; in version1()
410 start0(fcode_env_t *env) in start0() argument
412 env->fcode_incr = 1; in start0()
416 start1(fcode_env_t *env) in start1() argument
418 env->fcode_incr = 1; in start1()
422 start2(fcode_env_t *env) in start2() argument
424 env->fcode_incr = 2; in start2()
428 start4(fcode_env_t *env) in start4() argument
430 env->fcode_incr = 4; in start4()
464 byte_load(fcode_env_t *env) in byte_load() argument
478 fcode_buffer = env->fcode_buffer; in byte_load()
479 fcode_ptr = env->fcode_ptr; in byte_load()
480 fcode_incr = env->fcode_incr; in byte_load()
481 offset_incr = env->offset_incr; in byte_load()
482 interpretting = env->interpretting; in byte_load()
486 CHECK_DEPTH(env, 2, "byte-load"); in byte_load()
488 env->fcode_ptr = env->fcode_buffer = (uchar_t *)POP(DS); in byte_load()
493 length = (env->fcode_buffer[4] << 24) | (env->fcode_buffer[5] << 16) | in byte_load()
494 (env->fcode_buffer[6] << 8) | env->fcode_buffer[7]; in byte_load()
495 if (!check_fcode_header("byte-load", env->fcode_ptr, length)) in byte_load()
498 env->fcode_incr = 1; in byte_load()
499 env->offset_incr = 1; in byte_load()
500 env->interpretting = 1; in byte_load()
501 env->level = 0; in byte_load()
505 debug_msg(db, "byte_load: %p, %d\n", env->fcode_buffer, fcode_xt); in byte_load()
507 env->fcode_buffer[0], env->fcode_buffer[1]); in byte_load()
509 (env->fcode_buffer[2]<<8)|(env->fcode_buffer[3])); in byte_load()
511 env->fcode_ptr += 8; in byte_load()
513 debug_msg(db, "Interpretting: %d\n", env->interpretting); in byte_load()
515 while (env->interpretting) { in byte_load()
520 if (!past_eob && env->fcode_ptr >= env->fcode_buffer + length) { in byte_load()
525 env->last_fcode_ptr = env->fcode_ptr; in byte_load()
526 token = get_next_token(env); in byte_load()
528 entry = &env->table[token]; in byte_load()
531 DEBUGF(BYTELOAD_DS, output_data_stack(env, MSG_FC_DEBUG)); in byte_load()
532 DEBUGF(BYTELOAD_RS, output_return_stack(env, 1, MSG_FC_DEBUG)); in byte_load()
535 ((env->state && (entry->flags & IMMEDIATE) == 0)) ? in byte_load()
537 env->last_fcode_ptr - env->fcode_buffer, token, in byte_load()
544 if ((env->state) && in byte_load()
547 compile_comma(env); in byte_load()
549 execute(env); in byte_load()
558 env->fcode_ptr = fcode_ptr; in byte_load()
559 env->fcode_buffer = fcode_buffer; in byte_load()
560 env->fcode_incr = fcode_incr; in byte_load()
561 env->offset_incr = offset_incr; in byte_load()
562 env->interpretting = interpretting; in byte_load()
566 btick(fcode_env_t *env) in btick() argument
568 int token = get_next_token(env); in btick()
570 PUSH(DS, (fstack_t)env->table[token].apf); in btick()
571 tick_literal(env); in btick()
575 show_fcode_def(fcode_env_t *env, char *type) in show_fcode_def() argument
577 int i = env->last_token; in show_fcode_def()
580 if (env->table[i].name) in show_fcode_def()
582 env->table[i].name, i, env->table[i].apf); in show_fcode_def()
585 env->table[i].apf); in show_fcode_def()
590 bcolon(fcode_env_t *env) in bcolon() argument
592 if (env->state == 0) { in bcolon()
593 env->table[env->last_token].apf = (acf_t)HERE; in bcolon()
594 env->table[env->last_token].flags = 0; in bcolon()
595 show_fcode_def(env, "bcolon"); in bcolon()
597 env->state |= 1; in bcolon()
602 bcreate(fcode_env_t *env) in bcreate() argument
604 env->table[env->last_token].apf = (acf_t)HERE; in bcreate()
605 show_fcode_def(env, "bcreate"); in bcreate()
607 expose_acf(env, "<bcreate>"); in bcreate()
611 get_token_name(fcode_env_t *env, int token, char **name, int *len) in get_token_name() argument
613 *name = env->table[token].name; in get_token_name()
621 bvalue(fcode_env_t *env) in bvalue() argument
623 env->table[env->last_token].apf = (acf_t)HERE; in bvalue()
624 show_fcode_def(env, "bvalue"); in bvalue()
625 make_common_access(env, 0, 0, 1, in bvalue()
626 env->instance_mode, &noop, &noop, &set_value_actions); in bvalue()
630 bvariable(fcode_env_t *env) in bvariable() argument
632 env->table[env->last_token].apf = (acf_t)HERE; in bvariable()
633 show_fcode_def(env, "bvariable"); in bvariable()
635 make_common_access(env, 0, 0, 1, in bvariable()
636 env->instance_mode, &instance_variable, &do_create, NULL); in bvariable()
640 bconstant(fcode_env_t *env) in bconstant() argument
642 env->table[env->last_token].apf = (acf_t)HERE; in bconstant()
643 show_fcode_def(env, "bconstant"); in bconstant()
644 make_common_access(env, 0, 0, 1, in bconstant()
645 env->instance_mode, &do_constant, &do_constant, NULL); in bconstant()
649 bdefer(fcode_env_t *env) in bdefer() argument
651 env->table[env->last_token].apf = (acf_t)HERE; in bdefer()
652 show_fcode_def(env, "bdefer"); in bdefer()
655 make_common_access(env, 0, 0, 1, env->instance_mode, in bdefer()
660 bbuffer_colon(fcode_env_t *env) in bbuffer_colon() argument
662 env->table[env->last_token].apf = (acf_t)HERE; in bbuffer_colon()
663 show_fcode_def(env, "buffer:"); in bbuffer_colon()
665 make_common_access(env, 0, 0, 2, env->instance_mode, in bbuffer_colon()
670 do_field(fcode_env_t *env) in do_field() argument
679 bfield(fcode_env_t *env) in bfield() argument
681 env->table[env->last_token].apf = (acf_t)HERE; in bfield()
682 show_fcode_def(env, "bfield"); in bfield()
684 over(env); in bfield()
685 compile_comma(env); in bfield()
686 add(env); in bfield()
687 expose_acf(env, "<bfield>"); in bfield()
691 bto(fcode_env_t *env) in bto() argument
693 btick(env); in bto()
695 if (env->state) { in bto()
698 do_set_action(env); in bto()
703 get_token(fcode_env_t *env) in get_token() argument
708 CHECK_DEPTH(env, 1, "get-token"); in get_token()
711 PUSH(DS, (fstack_t)env->table[tok].apf); in get_token()
712 if (env->table[tok].flags & IMMEDIATE) immediate = 1; in get_token()
717 set_token(fcode_env_t *env) in set_token() argument
723 CHECK_DEPTH(env, 3, "set-token"); in set_token()
729 env->table[tok].flags |= IMMEDIATE; in set_token()
731 env->table[tok].flags &= ~IMMEDIATE; in set_token()
732 env->table[tok].apf = acf; in set_token()
733 immediate = env->last_token; in set_token()
734 env->last_token = tok; in set_token()
735 show_fcode_def(env, "set_token"); in set_token()
736 env->last_token = immediate; in set_token()
740 bof(fcode_env_t *env) in bof() argument
742 short offset = get_short(env); in bof()
743 branch_common(env, offset, 2, 0); in bof()
747 bcase(fcode_env_t *env) in bcase() argument
749 env->level++; in bcase()
750 set_temporary_compile(env); in bcase()
755 bendcase(fcode_env_t *env) in bendcase() argument
757 COMPILE_TOKEN(env->table[0x46].apf); /* Hack for now... */ in bendcase()
759 bresolve(env); in bendcase()
762 env->level--; in bendcase()
763 temporary_execute(env); in bendcase()
767 bendof(fcode_env_t *env) in bendof() argument
769 short offset = get_short(env); in bendof()
770 branch_common(env, offset, 0, 1); in bendof()
771 bresolve(env); in bendof()
775 fcode_revision(fcode_env_t *env) in fcode_revision() argument
782 alloc_mem(fcode_env_t *env) in alloc_mem() argument
784 CHECK_DEPTH(env, 1, "alloc-mem"); in alloc_mem()
787 throw_from_fclib(env, 1, "alloc-mem failed"); in alloc_mem()
792 free_mem(fcode_env_t *env) in free_mem() argument
796 CHECK_DEPTH(env, 2, "free-mem"); in free_mem()
803 parse_two_int(fcode_env_t *env) in parse_two_int() argument
809 CHECK_DEPTH(env, 2, "parse-2int"); in parse_two_int()
812 str = pop_a_string(env, &len); in parse_two_int()
815 throw_from_fclib(env, 1, "parse_2int"); in parse_two_int()
823 left_parse_string(fcode_env_t *env) in left_parse_string() argument
828 CHECK_DEPTH(env, 3, "left-parse-string"); in left_parse_string()
831 two_dup(env); in left_parse_string()
834 lstr = pop_a_string(env, &llen); in left_parse_string()
862 is_user_word(fcode_env_t *env) in is_user_word() argument
868 CHECK_DEPTH(env, 3, "(is-user-word)"); in is_user_word()
870 name = pop_a_string(env, &len); in is_user_word()
871 header(env, name, len, 0); in is_user_word()
874 expose_acf(env, name); in is_user_word()
878 f_error(fcode_env_t *env) in f_error() argument
881 env->interpretting = 0; in f_error()
883 env->last_fcode); in f_error()
885 forth_abort(env, "Unimplemented FCODE token: 0x%x\n", env->last_fcode); in f_error()
890 fcode_buffer_addr(fcode_env_t *env) in fcode_buffer_addr() argument
892 PUSH(DS, (fstack_t)(env->fcode_buffer)); in fcode_buffer_addr()
900 fcode_env_t *env = initial_env; in _init() local
902 ASSERT(env); in _init()