1 /* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // -------------------------------------------------------------------------*/
11 * NanoCoat Virtual Machine functions.
16 #ifndef SQUIRRELJME_NVMFUNC_H
17 #define SQUIRRELJME_NVMFUNC_H
19 #include "sjme/nvm/nvm.h"
23 #ifndef SJME_CXX_IS_EXTERNED
24 #define SJME_CXX_IS_EXTERNED
25 #define SJME_CXX_SQUIRRELJME_NVMFUNC_H
27 #endif /* #ifdef SJME_CXX_IS_EXTERNED */
28 #endif /* #ifdef __cplusplus */
30 /*--------------------------------------------------------------------------*/
32 sjme_errorCode
sjme_nvm_arrayLength(
33 sjme_attrInNotNull sjme_nvm_frame frame
,
34 sjme_attrInNullable sjme_jobject arrayInstance
,
35 sjme_attrOutNotNull sjme_jint
* outLen
)
38 sjme_tempIndex
sjme_nvm_arrayLoadIntoTemp(
39 sjme_attrInNotNull sjme_nvm_frame frame
,
40 sjme_attrInValue sjme_basicTypeId primitiveType
,
41 sjme_attrInNullable sjme_jobject arrayInstance
,
42 sjme_attrInValue sjme_attrInPositive sjme_jint index
)
43 sjme_attrOutNegativeOnePositive sjme_attrCheckReturn
;
45 sjme_errorCode
sjme_nvm_arrayStore(
46 sjme_attrInNotNull sjme_nvm_frame frame
,
47 sjme_attrInValue sjme_basicTypeId primitiveType
,
48 sjme_attrInNullable sjme_jobject arrayInstance
,
49 sjme_attrInValue sjme_attrInPositive sjme_jint index
,
50 sjme_attrInNotNull sjme_any
* value
)
53 sjme_errorCode
sjme_nvm_checkCast(
54 sjme_attrInNotNull sjme_nvm_frame frame
,
55 sjme_attrInNullable sjme_jobject instance
,
56 sjme_attrInNotNull sjme_dynamic_linkage_data_classObject
* type
)
59 sjme_errorCode
sjme_nvm_countReferenceDown(
60 sjme_attrInNotNull sjme_nvm_frame frame
,
61 sjme_attrInNullable sjme_jobject instance
)
64 sjme_tempIndex
sjme_nvm_fieldGetToTemp(
65 sjme_attrInNotNull sjme_nvm_frame frame
,
66 sjme_attrInNullable sjme_jobject instance
,
67 sjme_attrInNotNull sjme_dynamic_linkage_data_fieldAccess
* field
)
68 sjme_attrOutNegativeOnePositive sjme_attrCheckReturn
;
70 sjme_errorCode
sjme_nvm_fieldPut(
71 sjme_attrInNotNull sjme_nvm_frame frame
,
72 sjme_attrInNullable sjme_jobject instance
,
73 sjme_attrInNotNull sjme_dynamic_linkage_data_fieldAccess
* field
,
74 sjme_attrInNotNull sjme_any
* value
)
78 * Garbage collects an object.
80 * @param frame The frame this is collecting in.
81 * @param instance The instance to be garbage collected.
82 * @return Returns @c SJME_JNI_TRUE on success.
85 sjme_errorCode
sjme_nvm_gcObject(
86 sjme_attrInNotNull sjme_nvm_frame frame
,
87 sjme_attrInNullable sjme_jobject instance
)
90 sjme_errorCode
sjme_nvm_invoke(
91 sjme_attrInNotNull sjme_nvm_frame frame
,
92 sjme_attrInNotNull sjme_dynamic_linkage_data_invokeNormal
* method
)
95 sjme_errorCode
sjme_nvm_localPopDouble(
96 sjme_attrInNotNull sjme_nvm_frame frame
,
97 sjme_attrInValue sjme_attrInPositive sjme_jint localIndex
)
100 sjme_errorCode
sjme_nvm_localPopFloat(
101 sjme_attrInNotNull sjme_nvm_frame frame
,
102 sjme_attrInValue sjme_attrInPositive sjme_jint localIndex
)
103 sjme_attrCheckReturn
;
105 sjme_errorCode
sjme_nvm_localPopInteger(
106 sjme_attrInNotNull sjme_nvm_frame frame
,
107 sjme_attrInValue sjme_attrInPositive sjme_jint localIndex
)
108 sjme_attrCheckReturn
;
110 sjme_errorCode
sjme_nvm_localPopLong(
111 sjme_attrInNotNull sjme_nvm_frame frame
,
112 sjme_attrInValue sjme_attrInPositive sjme_jint localIndex
)
113 sjme_attrCheckReturn
;
115 sjme_errorCode
sjme_nvm_localPopReference(
116 sjme_attrInNotNull sjme_nvm_frame frame
,
117 sjme_attrInValue sjme_attrInPositive sjme_jint localIndex
)
118 sjme_attrCheckReturn
;
120 sjme_errorCode
sjme_nvm_localPushDouble(
121 sjme_attrInNotNull sjme_nvm_frame frame
,
122 sjme_attrInValue sjme_attrInPositive sjme_jint index
)
123 sjme_attrCheckReturn
;
125 sjme_errorCode
sjme_nvm_localPushFloat(
126 sjme_attrInNotNull sjme_nvm_frame frame
,
127 sjme_attrInValue sjme_attrInPositive sjme_jint index
)
128 sjme_attrCheckReturn
;
130 sjme_errorCode
sjme_nvm_localPushInteger(
131 sjme_attrInNotNull sjme_nvm_frame frame
,
132 sjme_attrInValue sjme_attrInPositive sjme_jint index
)
133 sjme_attrCheckReturn
;
135 sjme_errorCode
sjme_nvm_localPushLong(
136 sjme_attrInNotNull sjme_nvm_frame frame
,
137 sjme_attrInValue sjme_attrInPositive sjme_jint index
)
138 sjme_attrCheckReturn
;
140 sjme_errorCode
sjme_nvm_localPushReference(
141 sjme_attrInNotNull sjme_nvm_frame frame
,
142 sjme_attrInValue sjme_attrInPositive sjme_jint index
)
143 sjme_attrCheckReturn
;
145 sjme_errorCode
sjme_nvm_localReadInteger(
146 sjme_attrInNotNull sjme_nvm_frame frame
,
147 sjme_attrInValue sjme_attrInPositive sjme_jint index
,
148 sjme_attrOutNotNull sjme_jint
* outValue
)
149 sjme_attrCheckReturn
;
151 sjme_errorCode
sjme_nvm_localWriteInteger(
152 sjme_attrInNotNull sjme_nvm_frame frame
,
153 sjme_attrInValue sjme_attrInPositive sjme_jint index
,
154 sjme_attrInValue sjme_jint value
)
155 sjme_attrCheckReturn
;
157 sjme_tempIndex
sjme_nvm_lookupClassObjectIntoTemp(
158 sjme_attrInNotNull sjme_nvm_frame frame
,
159 sjme_attrInNotNull sjme_dynamic_linkage_data_classObject
* classLinkage
)
160 sjme_attrOutNegativeOnePositive sjme_attrCheckReturn
;
162 sjme_tempIndex
sjme_nvm_lookupStringIntoTemp(
163 sjme_attrInNotNull sjme_nvm_frame frame
,
164 sjme_attrInNotNull sjme_dynamic_linkage_data_stringObject
* stringLinkage
)
165 sjme_attrOutNegativeOnePositive sjme_attrCheckReturn
;
167 sjme_errorCode
sjme_nvm_monitor(
168 sjme_attrInNotNull sjme_nvm_frame frame
,
169 sjme_attrInNullable sjme_jobject instance
,
170 sjme_attrInValue sjme_jboolean isEnter
)
171 sjme_attrCheckReturn
;
173 sjme_tempIndex
sjme_nvm_newArrayIntoTemp(
174 sjme_attrInNotNull sjme_nvm_frame frame
,
175 sjme_attrInNotNull sjme_dynamic_linkage_data_classObject
* componentType
,
176 sjme_attrInValue sjme_attrInPositive sjme_jint length
)
177 sjme_attrOutNegativeOnePositive sjme_attrCheckReturn
;
179 sjme_tempIndex
sjme_nvm_newInstanceIntoTemp(
180 sjme_attrInNotNull sjme_nvm_frame frame
,
181 sjme_attrInNotNull sjme_dynamic_linkage_data_classObject
* linkage
)
182 sjme_attrOutNegativeOnePositive sjme_attrCheckReturn
;
184 sjme_errorCode
sjme_nvm_returnFromMethod(
185 sjme_attrInNotNull sjme_nvm_frame frame
,
186 sjme_attrInNotNull sjme_any
* value
)
187 sjme_attrCheckReturn
;
189 sjme_errorCode
sjme_nvm_stackPopAny(
190 sjme_attrInNotNull sjme_nvm_frame frame
,
191 sjme_attrOutNotNull sjme_any
* output
)
192 sjme_attrCheckReturn
;
194 sjme_tempIndex
sjme_nvm_stackPopAnyToTemp(
195 sjme_attrInNotNull sjme_nvm_frame frame
)
196 sjme_attrOutNegativeOnePositive sjme_attrCheckReturn
;
198 sjme_jint
sjme_nvm_stackPopInteger(
199 sjme_attrInNotNull sjme_nvm_frame frame
)
200 sjme_attrOutNegativeOnePositive
;
202 sjme_jobject
sjme_nvm_stackPopReference(
203 sjme_attrInNotNull sjme_nvm_frame frame
)
204 sjme_attrOutNullable
;
206 sjme_errorCode
sjme_nvm_stackPopReferenceThenThrow(
207 sjme_attrInNotNull sjme_nvm_frame frame
)
208 sjme_attrCheckReturn
;
210 sjme_tempIndex
sjme_nvm_stackPopReferenceToTemp(
211 sjme_attrInNotNull sjme_nvm_frame frame
)
212 sjme_attrOutNegativeOnePositive sjme_attrCheckReturn
;
214 sjme_errorCode
sjme_nvm_stackPushAny(
215 sjme_attrInNotNull sjme_nvm_frame frame
,
216 sjme_attrInNotNull sjme_any
* input
)
217 sjme_attrCheckReturn
;
219 sjme_errorCode
sjme_nvm_stackPushAnyFromTemp(
220 sjme_attrInNotNull sjme_nvm_frame frame
,
221 sjme_attrInPositive sjme_tempIndex input
)
222 sjme_attrCheckReturn
;
224 sjme_errorCode
sjme_nvm_stackPushDoubleParts(
225 sjme_attrInNotNull sjme_nvm_frame frame
,
226 sjme_attrInValue sjme_jint hi
,
227 sjme_attrInValue sjme_jint lo
)
228 sjme_attrCheckReturn
;
230 sjme_errorCode
sjme_nvm_stackPushFloatRaw(
231 sjme_attrInNotNull sjme_nvm_frame frame
,
232 sjme_attrInValue sjme_jint rawValue
)
233 sjme_attrCheckReturn
;
235 sjme_errorCode
sjme_nvm_stackPushInteger(
236 sjme_attrInNotNull sjme_nvm_frame frame
,
237 sjme_attrInValue sjme_jint value
)
238 sjme_attrCheckReturn
;
240 sjme_errorCode
sjme_nvm_stackPushIntegerIsInstanceOf(
241 sjme_attrInNotNull sjme_nvm_frame frame
,
242 sjme_attrInNullable sjme_jobject instance
,
243 sjme_attrInNotNull sjme_dynamic_linkage_data_classObject
* type
)
244 sjme_attrCheckReturn
;
246 sjme_errorCode
sjme_nvm_stackPushLongParts(
247 sjme_attrInNotNull sjme_nvm_frame frame
,
248 sjme_attrInValue sjme_jint hi
,
249 sjme_attrInValue sjme_jint lo
)
250 sjme_attrCheckReturn
;
252 sjme_errorCode
sjme_nvm_stackPushReference(
253 sjme_attrInNotNull sjme_nvm_frame frame
,
254 sjme_attrInNullable sjme_jobject instance
)
255 sjme_attrCheckReturn
;
257 sjme_errorCode
sjme_nvm_stackPushReferenceFromTemp(
258 sjme_attrInNotNull sjme_nvm_frame frame
,
259 sjme_attrInPositive sjme_tempIndex tempIndex
)
260 sjme_attrCheckReturn
;
262 sjme_errorCode
sjme_nvm_tempDiscard(
263 sjme_attrInNotNull sjme_nvm_frame frame
)
264 sjme_attrCheckReturn
;
266 sjme_errorCode
sjme_nvm_throwExecute(
267 sjme_attrInNotNull sjme_nvm_frame frame
)
268 sjme_attrCheckReturn
;
271 * Returns the top-most frame in the thread.
273 * @param inThread The thread to get the top frame from.
274 * @param outFrame The top most frame.
275 * @return Returns @c SJME_JNI_TRUE on success where the thread is valid and it
276 * has at least one frame.
279 sjme_errorCode
sjme_nvm_topFrame(
280 sjme_attrInNotNull sjme_nvm_thread inThread
,
281 sjme_attrOutNotNull sjme_nvm_frame outFrame
)
282 sjme_attrCheckReturn
;
285 * Ticks the virtual machine.
287 * @param inState The state to tick, @c -1 means to tick forever.
288 * @param maxTics The number of ticks to execute before returning.
289 * @param isTerminated Optional output to check if the VM terminated.
290 * @return Any resultant error, if any.
293 sjme_errorCode
sjme_nvm_tick(
294 sjme_attrInNotNull sjme_nvm inState
,
295 sjme_attrInValue sjme_attrInPositive sjme_jint maxTics
,
296 sjme_attrOutNullable sjme_jboolean
* isTerminated
)
297 sjme_attrCheckReturn
;
299 /*--------------------------------------------------------------------------*/
303 #ifdef SJME_CXX_SQUIRRELJME_NVMFUNC_H
305 #undef SJME_CXX_SQUIRRELJME_NVMFUNC_H
306 #undef SJME_CXX_IS_EXTERNED
307 #endif /* #ifdef SJME_CXX_SQUIRRELJME_NVMFUNC_H */
308 #endif /* #ifdef __cplusplus */
310 #endif /* SQUIRRELJME_NVMFUNC_H */