fm: remove sparc-only modules
[unleashed.git] / usr / src / lib / efcode / engine / instance.c
blob380d1d62977dcf30b171d6a1db870d983edfbf24
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
24 * Copyright (c) 1999 by Sun Microsystems, Inc.
25 * All rights reserved.
28 #pragma ident "%Z%%M% %I% %E% SMI"
30 #include <stdio.h>
32 #include <fcode/private.h>
35 * Return a pointer to the allocated instance data.
36 * If the data was initialised then return a pointer to the initialisation
37 * buffer otherwise return a pointer to the un-init data.
39 token_t *
40 alloc_instance_data(fcode_env_t *env, int init, int n, int *offset)
42 int ptr;
44 *offset = ptr = MYSELF->device->data_size[init];
45 MYSELF->device->data_size[init] += n;
46 if (init == INIT_DATA)
47 return (&MYSELF->device->init_data[ptr]);
48 else
49 return (&MYSELF->data[init][ptr]);
52 token_t *
53 get_instance_address(fcode_env_t *env)
55 int which;
56 token_t *ptr;
57 token_t offset;
59 CHECK_DEPTH(env, 1, "get_instance_address");
60 ptr = (token_t *) POP(DS);
61 offset = *ptr;
62 if (offset < 0) {
63 offset = -offset;
64 which = UINIT_DATA;
65 } else {
66 which = INIT_DATA;
68 return (&MYSELF->data[which][offset]);
71 void
72 fetch_instance_data(fcode_env_t *env)
74 token_t *ptr;
76 CHECK_DEPTH(env, 1, "get_instance_data");
77 ptr = get_instance_address(env);
78 PUSH(DS, *ptr);
81 void
82 set_instance_data(fcode_env_t *env)
84 token_t *ptr;
86 CHECK_DEPTH(env, 2, "set_instance_data");
87 ptr = get_instance_address(env);
88 *ptr = POP(DS);
91 void
92 address_instance_data(fcode_env_t *env)
94 token_t *ptr;
96 CHECK_DEPTH(env, 1, "address_instance_data");
97 ptr = get_instance_address(env);
98 PUSH(DS, (fstack_t) ptr);
101 void
102 instance_variable(fcode_env_t *env)
104 token_t *ptr;
106 PUSH(DS, (fstack_t) WA);
107 ptr = get_instance_address(env);
108 PUSH(DS, (fstack_t) ptr);
111 void
112 idefer_exec(fcode_env_t *env)
114 CHECK_DEPTH(env, 1, "idefer_exec");
115 fetch_instance_data(env);
116 execute(env);