fm: remove sparc-only modules
[unleashed.git] / usr / src / lib / efcode / engine / interp.c
blobe0e41dba01ac8525f42885332e53464f0884711a
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright (c) 1999 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <stdio.h>
31 #include <fcode/private.h>
32 #include <fcode/log.h>
34 void
35 do_run(fcode_env_t *env, int next)
37 token_t target, indirect;
38 void (*fn)(fcode_env_t *env);
39 int debug_state = current_debug_state(env);
40 extern void do_memory_watch(fcode_env_t *env);
42 for (; ; ) {
43 if (next) {
44 DEBUGF(NEXT_VITALS, output_vitals(env);
45 log_message(MSG_FC_DEBUG, "\n"));
46 CHECK_INTERRUPT;
47 if (IP == NULL)
48 break;
49 WA = (token_t *) *IP;
50 IP++;
52 check_for_debug_entry(env);
53 indirect = *WA;
54 if (indirect & 1) {
55 target = indirect & ~1;
56 target = *((token_t *)target);
57 } else
58 target = indirect;
59 fn = (void (*)(fcode_env_t *)) target;
60 if (do_exec_debug(env, (void *)fn))
61 break;
62 if (indirect & 1) {
63 PUSH(DS, (fstack_t) (WA+1));
64 WA = (token_t *) target;
66 WA++;
67 fn(env);
68 check_vitals(env);
69 check_for_debug_exit(env);
70 do_memory_watch(env);
71 next = 1;
73 clear_debug_state(env, debug_state);
76 void
77 do_semi(fcode_env_t *env)
79 CHECK_RETURN_DEPTH(env, 1, ";");
80 check_semi_debug_exit(env);
81 IP = (token_t *) POP(RS);
84 void
85 do_colon(fcode_env_t *env)
87 PUSH(RS, (fstack_t) IP);
88 IP = WA;
91 void
92 do_alias(fcode_env_t *env)
94 token_t *ip;
96 ip = IP;
97 IP = 0;
98 WA = (token_t *) *WA;
99 do_run(env, 0);
100 IP = ip;
103 void
104 execute(fcode_env_t *env)
106 token_t *ip, *wa;
109 * In order to ensure that only this token executes we
110 * force IP to zero after stashing it, then when the stack
111 * unwinds (do_run returns) we can restore the old value.
113 CHECK_DEPTH(env, 1, "execute");
114 ip = IP;
115 wa = WA;
116 IP = 0;
117 WA = (token_t *) POP(DS);
118 do_run(env, 0);
119 IP = ip;
120 WA = wa;