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 * SquirrelJME NanoCoat Virtual Machine Header Definitions.
16 #ifndef SQUIRRELJME_NVM_H
17 #define SQUIRRELJME_NVM_H
23 #include "sjme/config.h"
27 #ifndef SJME_CXX_IS_EXTERNED
28 #define SJME_CXX_IS_EXTERNED
29 #define SJME_CXX_SQUIRRELJME_NVM_H
31 #endif /* #ifdef SJME_CXX_IS_EXTERNED */
32 #endif /* #ifdef __cplusplus */
34 /*--------------------------------------------------------------------------*/
37 * Posts two tokens together.
39 * @param a The first token.
40 * @param b The second token.
43 #define SJME_TOKEN_PASTE(a, b) a##b
46 * Pasting two tokens but with preprocessing.
48 * @param a The first token.
49 * @param b The second token.
52 #define SJME_TOKEN_PASTE_PP(a, b) SJME_TOKEN_PASTE(a, b)
55 * Stringifies the given token.
57 * @param s The token to stringify.
60 #define SJME_TOKEN_STRING(s) #s
63 * Stringifies the given token.
65 * @param s The token to stringify.
68 #define SJME_TOKEN_STRING_PP(s) SJME_TOKEN_STRING(s)
70 /** SquirrelJME version string. */
71 #define SQUIRRELJME_VERSION SJME_TOKEN_STRING_PP(SQUIRRELJME_VERSION_TRIM)
74 * Calculates the size of a struct member.
76 * @param type The type of the struct.
77 * @param member The member to check.
78 * @return The size of the given member.
81 #define SJME_SIZEOF_STRUCT_MEMBER(type, member) \
82 (sizeof((*((type*)0)).member))
89 typedef uint8_t sjme_jboolean
;
96 typedef int8_t sjme_jbyte
;
103 typedef uint8_t sjme_jubyte
;
110 typedef int16_t sjme_jshort
;
117 typedef uint16_t sjme_jchar
;
124 typedef int32_t sjme_jint
;
127 * Unsigned integer type.
131 typedef uint32_t sjme_juint
;
138 typedef struct sjme_jlong
152 typedef struct sjme_jfloat
162 typedef struct sjme_jdouble
176 typedef sjme_jint sjme_tempIndex
;
179 * Basic data type identifier.
183 typedef enum sjme_basicTypeId
186 SJME_BASIC_TYPE_ID_INTEGER
= 0,
189 SJME_JAVA_TYPE_ID_INTEGER
= SJME_BASIC_TYPE_ID_INTEGER
,
192 SJME_BASIC_TYPE_ID_LONG
= 1,
195 SJME_JAVA_TYPE_ID_LONG
= SJME_BASIC_TYPE_ID_LONG
,
198 SJME_BASIC_TYPE_ID_FLOAT
= 2,
201 SJME_JAVA_TYPE_ID_FLOAT
= SJME_BASIC_TYPE_ID_FLOAT
,
204 SJME_BASIC_TYPE_ID_DOUBLE
= 3,
207 SJME_JAVA_TYPE_ID_DOUBLE
= SJME_BASIC_TYPE_ID_DOUBLE
,
210 SJME_BASIC_TYPE_ID_OBJECT
= 4,
213 SJME_JAVA_TYPE_ID_OBJECT
= SJME_BASIC_TYPE_ID_OBJECT
,
215 /** Boolean or byte. */
216 SJME_BASIC_TYPE_ID_BOOLEAN_OR_BYTE
= 5,
218 /** The number of Java type IDs. */
219 SJME_NUM_JAVA_TYPE_IDS
= SJME_BASIC_TYPE_ID_BOOLEAN_OR_BYTE
,
222 SJME_BASIC_TYPE_ID_SHORT
= 6,
225 SJME_BASIC_TYPE_ID_CHARACTER
= 7,
227 /** Number of basic type IDs. */
228 SJME_NUM_BASIC_TYPE_IDS
= 8
231 /** The Java type ID. */
232 typedef sjme_basicTypeId sjme_javaTypeId
;
235 * Represents multiple type IDs.
239 typedef struct sjme_basicTypeIds
241 /** The number of IDs. */
245 const sjme_javaTypeId ids
[sjme_flexibleArrayCount
];
249 * Program counter address.
253 typedef sjme_jint sjme_pcAddr
;
256 * Static linkage type.
260 typedef sjme_jint sjme_staticLinkageType
;
263 * Base object information.
267 typedef struct sjme_jobjectBase
269 /** The reference count of this object, zero it becomes GCed. */
278 typedef sjme_jobjectBase
* sjme_jobject
;
285 typedef sjme_jobject sjme_jclass
;
292 typedef sjme_jobject sjme_jthrowable
;
294 typedef union sjme_anyData
300 sjme_jobject sjme_jobject
;
302 /** Temporary index. */
303 sjme_tempIndex tempIndex
;
306 typedef struct sjme_any
308 /** Data type used. */
309 sjme_basicTypeId type
;
311 /** Data stored within. */
316 * Represents the virtual machine state.
320 typedef struct sjme_nvm_state sjme_nvm_state
;
323 * Frame of execution within a thread.
327 typedef struct sjme_nvm_frame sjme_nvm_frame
;
329 typedef struct sjme_nvm_thread
331 /** The VM state this thread is in. */
332 sjme_nvm_state
* inState
;
334 /** The thread ID. */
337 /** The top of the stack. */
340 /** The number of frames. */
344 typedef struct sjme_static_constValue
346 /** Integer value. */
350 sjme_jlong sjme_jlong
;
353 sjme_jfloat sjme_jfloat
;
356 sjme_jdouble sjme_jdouble
;
359 const char* sjme_jstring
;
362 const char* sjme_jclass
;
363 } sjme_static_constValue
;
366 * Represents a field type.
370 typedef struct sjme_static_fieldType
372 /** The hash code for the field type. */
375 /** The field descriptor. */
376 const char* descriptor
;
378 /** The basic type. */
379 sjme_basicTypeId basicType
;
380 } sjme_static_fieldType
;
382 typedef struct sjme_static_classField
387 /** The field type. */
388 const sjme_static_fieldType
* type
;
393 /** The constant value type. */
394 sjme_basicTypeId valueType
;
397 sjme_static_constValue value
;
398 } sjme_static_classField
;
400 typedef struct sjme_static_classFields
402 /** The number of fields. */
406 sjme_static_classField fields
[sjme_flexibleArrayCount
];
407 } sjme_static_classFields
;
410 * Type used for method code functions.
412 * @param currentState The current virtual machine state.
413 * @param currentThread The current virtual machine thread.
414 * @return Will return @c true if execution completed without throwing
415 * a @c Throwable object.
418 typedef sjme_jboolean (*sjme_methodCodeFunction
)(
419 struct sjme_nvm_state
* currentState
,
420 struct sjme_nvm_thread
* currentThread
);
423 * The variable mapping and setup for any given method.
427 typedef struct sjme_static_classCodeLimits
429 /** The maximum number of @c sjme_basicTypeId local/stack variables. */
430 const sjme_jubyte maxVariables
[SJME_NUM_JAVA_TYPE_IDS
];
431 } sjme_static_classCodeLimits
;
434 * Contains information about method code and how variables should be placed
435 * on execution and stack handling.
439 typedef struct sjme_static_classCode
441 /** The variable count and thrown index count used. */
442 const sjme_static_classCodeLimits
* limits
;
444 /** The index where thrown objects are placed. */
445 sjme_jshort thrownVarIndex
;
447 /** The method code. */
448 sjme_methodCodeFunction code
;
449 } sjme_static_classCode
;
452 * Represents a standard Java method type, using field descriptors.
456 typedef struct sjme_static_methodType
458 /** The hash code for the method type. */
461 /** The descriptor for the method type. */
462 const char* descriptor
;
464 /** The return type. */
465 const sjme_static_fieldType
* returnType
;
467 /** The number of arguments. */
470 /** The arguments to the method. */
471 const sjme_static_fieldType
* argTypes
[0];
472 } sjme_static_methodType
;
474 typedef struct sjme_static_classMethod
483 const sjme_static_methodType
* type
;
485 /** Method code and any pertaining information. */
486 const sjme_static_classCode
* code
;
487 } sjme_static_classMethod
;
489 typedef struct sjme_static_classMethods
491 /** The number of methods. */
495 sjme_static_classMethod methods
[sjme_flexibleArrayCount
];
496 } sjme_static_classMethods
;
498 typedef struct sjme_static_classInterface
500 const char* interfaceName
;
501 } sjme_static_classInterface
;
503 typedef struct sjme_static_classInterfaces
505 /** The number of interfaces. */
509 sjme_static_classInterface interfaces
[sjme_flexibleArrayCount
];
510 } sjme_static_classInterfaces
;
512 typedef struct sjme_static_resource
514 /** The resource path. */
517 /** The hash for the path. */
520 /** The size of the resource. */
523 /** The resource data. */
524 const sjme_jbyte data
[sjme_flexibleArrayCount
];
525 } sjme_static_resource
;
527 typedef struct sjme_static_linkage_data_classObject
529 /** The class name. */
530 const char* className
;
531 } sjme_static_linkage_data_classObject
;
533 typedef struct sjme_static_linkage_data_fieldAccess
535 /** Is this static? */
536 sjme_jboolean isStatic
;
538 /** Is this a store? */
539 sjme_jboolean isStore
;
541 /** The source method name. */
542 const char* sourceMethodName
;
544 /** The source method type. */
545 const char* sourceMethodType
;
547 /** The target class. */
548 const char* targetClass
;
550 /** The target field name. */
551 const char* targetFieldName
;
553 /** The target field type. */
554 const char* targetFieldType
;
555 } sjme_static_linkage_data_fieldAccess
;
557 typedef struct sjme_static_linkage_data_invokeSpecial
559 /** The source method name. */
560 const char* sourceMethodName
;
562 /** The source method type. */
563 const char* sourceMethodType
;
565 /** The target class. */
566 const char* targetClass
;
568 /** The target method name. */
569 const char* targetMethodName
;
571 /** The target method type. */
572 const char* targetMethodType
;
573 } sjme_static_linkage_data_invokeSpecial
;
575 typedef struct sjme_static_linkage_data_invokeNormal
577 /** Is this a static invocation? */
578 sjme_jboolean isStatic
;
580 /** The source method name. */
581 const char* sourceMethodName
;
583 /** The source method type. */
584 const char* sourceMethodType
;
586 /** The target class. */
587 const char* targetClass
;
589 /** The target method name. */
590 const char* targetMethodName
;
592 /** The target method type. */
593 const char* targetMethodType
;
594 } sjme_static_linkage_data_invokeNormal
;
596 typedef struct sjme_static_linkage_data_stringObject
598 /** The string value. */
600 } sjme_static_linkage_data_stringObject
;
602 typedef union sjme_static_linkage_data
604 /** Reference to class object. */
605 sjme_static_linkage_data_classObject classObject
;
608 sjme_static_linkage_data_fieldAccess fieldAccess
;
610 /** Special invocation. */
611 sjme_static_linkage_data_invokeSpecial invokeSpecial
;
613 /** Normal invocation. */
614 sjme_static_linkage_data_invokeNormal invokeNormal
;
616 /** String object. */
617 sjme_static_linkage_data_stringObject stringObject
;
618 } sjme_static_linkage_data
;
625 typedef struct sjme_static_linkage
627 /** The type of linkage this is. */
628 sjme_staticLinkageType type
;
631 sjme_static_linkage_data data
;
632 } sjme_static_linkage
;
634 typedef struct sjme_static_linkages
636 /** The number of linkages. */
639 /** The define linkages. */
640 sjme_static_linkage linkages
[sjme_flexibleArrayCount
];
641 } sjme_static_linkages
;
643 typedef struct sjme_static_classInfo
645 /** This class name. */
646 const char* thisName
;
648 /** Hash of the current class name. */
651 /** The super name. */
652 const char* superName
;
655 const sjme_static_classInterfaces
* interfaceNames
;
661 const sjme_static_classFields
* fields
;
664 const sjme_static_classMethods
* methods
;
666 /** Linkages, effectively the constant pool. */
667 const sjme_static_linkages
* linkages
;
668 } sjme_static_classInfo
;
670 typedef struct sjme_static_library_classes
672 /** The number of classes. */
676 const struct sjme_static_classInfo
* classes
[sjme_flexibleArrayCount
];
677 } sjme_static_library_classes
;
679 typedef struct sjme_static_library_resources
681 /** The number of resources. */
685 const struct sjme_static_resource
* resources
[sjme_flexibleArrayCount
];
686 } sjme_static_library_resources
;
688 typedef struct sjme_static_library
693 /** Hashcode for the name. */
696 /** The hash of the original library, to detect changes. */
697 const char* originalLibHash
;
700 const sjme_static_library_resources
* resources
;
703 const sjme_static_library_classes
* classes
;
704 } sjme_static_library
;
706 typedef struct sjme_dynamic_linkage_data_classObject
709 } sjme_dynamic_linkage_data_classObject
;
711 typedef struct sjme_dynamic_linkage_data_fieldAccess
714 } sjme_dynamic_linkage_data_fieldAccess
;
716 typedef struct sjme_dynamic_linkage_data_invokeSpecial
719 } sjme_dynamic_linkage_data_invokeSpecial
;
721 typedef struct sjme_dynamic_linkage_data_invokeNormal
724 } sjme_dynamic_linkage_data_invokeNormal
;
726 typedef struct sjme_dynamic_linkage_data_stringObject
729 } sjme_dynamic_linkage_data_stringObject
;
731 typedef union sjme_dynamic_linkage_data
733 /** Reference to class object. */
734 sjme_dynamic_linkage_data_classObject classObject
;
737 sjme_dynamic_linkage_data_fieldAccess fieldAccess
;
739 /** Special invocation. */
740 sjme_dynamic_linkage_data_invokeSpecial invokeSpecial
;
742 /** Normal invocation. */
743 sjme_dynamic_linkage_data_invokeNormal invokeNormal
;
745 /** String object. */
746 sjme_dynamic_linkage_data_stringObject stringObject
;
747 } sjme_dynamic_linkage_data
;
754 typedef struct sjme_dynamic_linkage
756 /** The type of linkage this is. */
757 sjme_staticLinkageType type
;
760 sjme_dynamic_linkage_data data
;
761 } sjme_dynamic_linkage
;
764 * Represents the frame of a stack tread.
768 typedef struct sjme_nvm_frameTread
770 /** The number of items in this tread. */
773 /** The base index for the stack index. */
774 sjme_jint stackBaseIndex
;
776 /** The maximum size this tread can be. */
779 /** Values within the tread. */
782 /** Integer values. */
783 sjme_jint sjme_jints
[sjme_flexibleArrayCountUnion
];
786 sjme_jlong sjme_jlongs
[sjme_flexibleArrayCountUnion
];
789 sjme_jfloat sjme_jfloats
[sjme_flexibleArrayCountUnion
];
791 /** Double values. */
792 sjme_jdouble sjme_jdoubles
[sjme_flexibleArrayCountUnion
];
794 /** Object references. */
795 sjme_jobject sjme_jobjects
[sjme_flexibleArrayCountUnion
];
797 } sjme_nvm_frameTread
;
800 * Calculates the size of a frame tread for a given type.
802 * @param type The type to get the size for.
803 * @param count The number if items to store.
804 * @return The size in bytes for the tread.
807 #define SJME_SIZEOF_FRAME_TREAD(type, count) \
808 (sizeof(sjme_nvm_frameTread) + \
809 /* Need to handle cases where values could be aligned up... */ \
810 (offsetof(sjme_nvm_frameTread, values.SJME_TOKEN_PASTE(type,s)[0]) - \
811 offsetof(sjme_nvm_frameTread, values)) + \
812 (sizeof(type) * (size_t)(count)))
815 * Calculates the size of a frame tread for a given type via variable.
817 * @param typeId The type to get the size for.
818 * @param count The number if items to store.
819 * @return The size in bytes for the tread.
822 static inline size_t SJME_SIZEOF_FRAME_TREAD_VAR(sjme_javaTypeId typeId
,
827 case SJME_JAVA_TYPE_ID_INTEGER
:
828 return SJME_SIZEOF_FRAME_TREAD(sjme_jint
, count
);
830 case SJME_JAVA_TYPE_ID_LONG
:
831 return SJME_SIZEOF_FRAME_TREAD(sjme_jlong
, count
);
833 case SJME_JAVA_TYPE_ID_FLOAT
:
834 return SJME_SIZEOF_FRAME_TREAD(sjme_jfloat
, count
);
836 case SJME_JAVA_TYPE_ID_DOUBLE
:
837 return SJME_SIZEOF_FRAME_TREAD(sjme_jdouble
, count
);
839 case SJME_JAVA_TYPE_ID_OBJECT
:
840 return SJME_SIZEOF_FRAME_TREAD(sjme_jobject
, count
);
848 * Represents information on a frame's stack storage.
852 typedef struct sjme_nvm_frameStack
854 /** The number of items in the stack. */
857 /** The current limit of this structure. */
860 /** The stack order. */
861 sjme_javaTypeId order
[sjme_flexibleArrayCount
];
862 } sjme_nvm_frameStack
;
865 * Calculates the size of a frame stack.
867 * @param count The number if items to store.
868 * @return The size in bytes for the tread.
871 #define SJME_SIZEOF_FRAME_STACK(count) \
872 (sizeof(sjme_nvm_frameStack) + \
873 (sizeof(sjme_javaTypeId) * (size_t)(count)))
875 typedef struct sjme_nvm_frameLocalMap
877 /** The maximum number of locals. */
880 /** Mapping of a specific variable to a given type index. */
883 sjme_jbyte to
[SJME_NUM_JAVA_TYPE_IDS
];
884 } maps
[sjme_flexibleArrayCount
];
885 } sjme_nvm_frameLocalMap
;
888 * Calculates the size of the frame local variable map.
890 * @param count The number of items in the mapping.
891 * @return The size in bytes of the local mapping.
894 #define SJME_SIZEOF_FRAME_LOCAL_MAP(count) \
895 (sizeof(sjme_nvm_frameLocalMap) + \
896 (SJME_SIZEOF_STRUCT_MEMBER(sjme_nvm_frameLocalMap, maps[0]) * (count)))
898 struct sjme_nvm_frame
900 /** The thread this frame is in. */
901 sjme_nvm_thread
* inThread
;
903 /** The parent frame. */
904 sjme_nvm_frame
* parent
;
906 /** The frame index in the thread. */
907 sjme_jint frameIndex
;
909 /** The current program counter. */
912 /** Object which is waiting to be thrown for exception handling. */
913 sjme_jobject waitingThrown
;
915 /** Frame linkage. */
916 sjme_dynamic_linkage
* linkage
;
918 /** Temporary stack. */
921 /** Reference to this. */
922 sjme_jobject thisRef
;
924 /** Class reference. */
925 sjme_jclass classObjectRef
;
927 /** The current stack information. */
928 sjme_nvm_frameStack
* stack
;
930 /** Treads for the stack and locals. */
931 sjme_nvm_frameTread
* treads
[SJME_NUM_BASIC_TYPE_IDS
];
933 /** Mapping of local variables to the tread indexes per type. */
934 const sjme_nvm_frameLocalMap
* localMap
;
936 /** Current exception handler go back. */
937 jmp_buf exceptionPoint
;
940 typedef struct sjme_static_libraries
942 /** The number of libraries. */
945 /** The libraries. */
946 const sjme_static_library
* libraries
[sjme_flexibleArrayCount
];
947 } sjme_static_libraries
;
954 typedef struct sjme_static_rom
956 /** The ROM source set. */
957 const char* sourceSet
;
959 /** The ROM clutter level. */
960 const char* clutterLevel
;
962 /** The ROM libraries, is always last. */
963 const sjme_static_libraries
* libraries
;
967 * Contains the payload information.
971 typedef struct sjme_static_payload sjme_static_payload
;
974 * Boot configuration for NanoCoat.
978 typedef struct sjme_nvm_bootConfig
980 /** The payload to use for booting the virtual machine. */
981 const sjme_static_payload
* payload
;
982 } sjme_nvm_bootConfig
;
985 * Hook for garbage collection detection and/or cancel capability.
987 * @param frame The frame this is garbage collecting in.
988 * @param gcWhat what is being garbage collected?
989 * @return Returns @c SJME_JNI_TRUE if garbage collection should continue.
992 typedef sjme_jboolean (*sjme_nvm_StateHookGc
)(sjme_nvm_frame
* frame
,
993 sjme_jobject gcWhat
);
996 * Hooks for alternative function.
1000 typedef struct sjme_nvm_stateHooks
1002 /** Garbage collection. */
1003 sjme_nvm_StateHookGc gc
;
1004 } sjme_nvm_stateHooks
;
1007 * Represents the virtual machine state.
1011 struct sjme_nvm_state
1013 /** The copy of the boot config. */
1014 sjme_nvm_bootConfig bootConfig
;
1016 /** Combined library set. */
1017 sjme_static_libraries
* libraries
;
1019 /** Special value, is optional and front-end specific. */
1022 /** Hooks for the state. */
1023 const sjme_nvm_stateHooks
* hooks
;
1031 #define SJME_JNI_TRUE ((sjme_jboolean)1)
1038 #define SJME_JNI_FALSE ((sjme_jboolean)0)
1041 * Method initialization start.
1045 #define SJME_NANOCOAT_START_CALL ((sjme_pcAddr)-1)
1048 * Method closing end.
1052 #define SJME_NANOCOAT_END_CALL ((sjme_pcAddr)-2)
1059 typedef enum sjme_errorCode
1062 SJME_ERROR_CODE_NONE
= 0,
1064 /** Null arguments. */
1065 SJME_ERROR_CODE_NULL_ARGUMENTS
= -1,
1067 /** Local variable out of bounds. */
1068 SJME_ERROR_CODE_LOCAL_INDEX_INVALID
= -2,
1070 /** Stack variable out of bounds. */
1071 SJME_ERROR_CODE_STACK_INDEX_INVALID
= -3,
1073 /** Stack underflow. */
1074 SJME_ERROR_CODE_STACK_UNDERFLOW
= -4,
1076 /** Stack overflow. */
1077 SJME_ERROR_CODE_STACK_OVERFLOW
= -5,
1079 /** Top is not an integer type. */
1080 SJME_ERROR_CODE_TOP_NOT_INTEGER
= -6,
1082 /** Top is not a long type. */
1083 SJME_ERROR_CODE_TOP_NOT_LONG
= -7,
1085 /** Top is not a float type. */
1086 SJME_ERROR_CODE_TOP_NOT_FLOAT
= -8,
1088 /** Top is not a double type. */
1089 SJME_ERROR_CODE_TOP_NOT_DOUBLE
= -9,
1091 /** Top is not a object type. */
1092 SJME_ERROR_CODE_TOP_NOT_OBJECT
= -10,
1094 /** Frame is missing stack treads. */
1095 SJME_ERROR_FRAME_MISSING_STACK_TREADS
= -11,
1097 /** Invalid read of stack. */
1098 SJME_ERROR_CODE_STACK_INVALID_READ
= -12,
1100 /** Invalid write of stack. */
1101 SJME_ERROR_CODE_STACK_INVALID_WRITE
= -13,
1103 /** Invalid read of stack. */
1104 SJME_ERROR_CODE_LOCAL_INVALID_READ
= -14,
1106 /** Invalid write of stack. */
1107 SJME_ERROR_CODE_LOCAL_INVALID_WRITE
= -15,
1109 /** Invalid reference pop. */
1110 SJME_ERROR_INVALID_REFERENCE_POP
= -16,
1112 /** Invalid reference push. */
1113 SJME_ERROR_INVALID_REFERENCE_PUSH
= -17,
1115 /** Failed to garbage collect object. */
1116 SJME_ERROR_COULD_NOT_GC_OBJECT
= -18,
1118 /** Object reference count is not zero. */
1119 SJME_ERROR_OBJECT_REFCOUNT_NOT_ZERO
= -19,
1121 /** Garbage collection of object cancelled. */
1122 SJME_ERROR_OBJECT_GC_CANCELLED
= -20,
1124 /** The number of error codes. */
1125 SJME_NUM_ERROR_CODES
= -21
1128 sjme_jboolean
sjme_nvm_arrayLength(
1129 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1130 sjme_attrInNullable sjme_jobject arrayInstance
,
1131 sjme_attrOutNotNull sjme_jint
* outLen
)
1132 sjme_attrCheckReturn
;
1134 sjme_tempIndex
sjme_nvm_arrayLoadIntoTemp(
1135 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1136 sjme_attrInValue sjme_basicTypeId primitiveType
,
1137 sjme_attrInNullable sjme_jobject arrayInstance
,
1138 sjme_attrInValue sjme_attrInPositive sjme_jint index
)
1139 sjme_attrOutNegativeOnePositive sjme_attrCheckReturn
;
1141 sjme_jboolean
sjme_nvm_arrayStore(
1142 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1143 sjme_attrInValue sjme_basicTypeId primitiveType
,
1144 sjme_attrInNullable sjme_jobject arrayInstance
,
1145 sjme_attrInValue sjme_attrInPositive sjme_jint index
,
1146 sjme_attrInNotNull sjme_any
* value
)
1147 sjme_attrCheckReturn
;
1149 sjme_jboolean
sjme_nvm_checkCast(
1150 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1151 sjme_attrInNullable sjme_jobject instance
,
1152 sjme_attrInNotNull sjme_dynamic_linkage_data_classObject
* type
)
1153 sjme_attrCheckReturn
;
1155 sjme_jboolean
sjme_nvm_countReferenceDown(
1156 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1157 sjme_attrInNullable sjme_jobject instance
)
1158 sjme_attrCheckReturn
;
1160 sjme_tempIndex
sjme_nvm_fieldGetToTemp(
1161 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1162 sjme_attrInNullable sjme_jobject instance
,
1163 sjme_attrInNotNull sjme_dynamic_linkage_data_fieldAccess
* field
)
1164 sjme_attrOutNegativeOnePositive sjme_attrCheckReturn
;
1166 sjme_jboolean
sjme_nvm_fieldPut(
1167 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1168 sjme_attrInNullable sjme_jobject instance
,
1169 sjme_attrInNotNull sjme_dynamic_linkage_data_fieldAccess
* field
,
1170 sjme_attrInNotNull sjme_any
* value
)
1171 sjme_attrCheckReturn
;
1174 * Garbage collects an object.
1176 * @param frame The frame this is collecting in.
1177 * @param instance The instance to be garbage collected.
1178 * @return Returns @c SJME_JNI_TRUE on success.
1181 sjme_jboolean
sjme_nvm_gcObject(
1182 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1183 sjme_attrInNullable sjme_jobject instance
)
1184 sjme_attrCheckReturn
;
1186 sjme_jboolean
sjme_nvm_invoke(
1187 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1188 sjme_attrInNotNull sjme_dynamic_linkage_data_invokeNormal
* method
)
1189 sjme_attrCheckReturn
;
1191 sjme_jboolean
sjme_nvm_localPopDouble(
1192 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1193 sjme_attrInValue sjme_attrInPositive sjme_jint localIndex
)
1194 sjme_attrCheckReturn
;
1196 sjme_jboolean
sjme_nvm_localPopFloat(
1197 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1198 sjme_attrInValue sjme_attrInPositive sjme_jint localIndex
)
1199 sjme_attrCheckReturn
;
1201 sjme_jboolean
sjme_nvm_localPopInteger(
1202 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1203 sjme_attrInValue sjme_attrInPositive sjme_jint localIndex
)
1204 sjme_attrCheckReturn
;
1206 sjme_jboolean
sjme_nvm_localPopLong(
1207 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1208 sjme_attrInValue sjme_attrInPositive sjme_jint localIndex
)
1209 sjme_attrCheckReturn
;
1211 sjme_jboolean
sjme_nvm_localPopReference(
1212 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1213 sjme_attrInValue sjme_attrInPositive sjme_jint localIndex
)
1214 sjme_attrCheckReturn
;
1216 sjme_jboolean
sjme_nvm_localPushDouble(
1217 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1218 sjme_attrInValue sjme_attrInPositive sjme_jint index
)
1219 sjme_attrCheckReturn
;
1221 sjme_jboolean
sjme_nvm_localPushFloat(
1222 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1223 sjme_attrInValue sjme_attrInPositive sjme_jint index
)
1224 sjme_attrCheckReturn
;
1226 sjme_jboolean
sjme_nvm_localPushInteger(
1227 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1228 sjme_attrInValue sjme_attrInPositive sjme_jint index
)
1229 sjme_attrCheckReturn
;
1231 sjme_jboolean
sjme_nvm_localPushLong(
1232 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1233 sjme_attrInValue sjme_attrInPositive sjme_jint index
)
1234 sjme_attrCheckReturn
;
1236 sjme_jboolean
sjme_nvm_localPushReference(
1237 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1238 sjme_attrInValue sjme_attrInPositive sjme_jint index
)
1239 sjme_attrCheckReturn
;
1241 sjme_jboolean
sjme_nvm_localReadInteger(
1242 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1243 sjme_attrInValue sjme_attrInPositive sjme_jint index
,
1244 sjme_attrOutNotNull sjme_jint
* outValue
)
1245 sjme_attrCheckReturn
;
1247 sjme_jboolean
sjme_nvm_localWriteInteger(
1248 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1249 sjme_attrInValue sjme_attrInPositive sjme_jint index
,
1250 sjme_attrInValue sjme_jint value
)
1251 sjme_attrCheckReturn
;
1253 sjme_tempIndex
sjme_nvm_lookupClassObjectIntoTemp(
1254 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1255 sjme_attrInNotNull sjme_dynamic_linkage_data_classObject
* classLinkage
)
1256 sjme_attrOutNegativeOnePositive sjme_attrCheckReturn
;
1258 sjme_tempIndex
sjme_nvm_lookupStringIntoTemp(
1259 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1260 sjme_attrInNotNull sjme_dynamic_linkage_data_stringObject
* stringLinkage
)
1261 sjme_attrOutNegativeOnePositive sjme_attrCheckReturn
;
1263 sjme_jboolean
sjme_nvm_monitor(
1264 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1265 sjme_attrInNullable sjme_jobject instance
,
1266 sjme_attrInValue sjme_jboolean isEnter
)
1267 sjme_attrCheckReturn
;
1269 sjme_tempIndex
sjme_nvm_newArrayIntoTemp(
1270 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1271 sjme_attrInNotNull sjme_dynamic_linkage_data_classObject
* componentType
,
1272 sjme_attrInValue sjme_attrInPositive sjme_jint length
)
1273 sjme_attrOutNegativeOnePositive sjme_attrCheckReturn
;
1275 sjme_tempIndex
sjme_nvm_newInstanceIntoTemp(
1276 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1277 sjme_attrInNotNull sjme_dynamic_linkage_data_classObject
* linkage
)
1278 sjme_attrOutNegativeOnePositive sjme_attrCheckReturn
;
1280 sjme_jboolean
sjme_nvm_returnFromMethod(
1281 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1282 sjme_attrInNotNull sjme_any
* value
)
1283 sjme_attrCheckReturn
;
1285 sjme_jboolean
sjme_nvm_stackPopAny(
1286 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1287 sjme_attrOutNotNull sjme_any
* output
)
1288 sjme_attrCheckReturn
;
1290 sjme_tempIndex
sjme_nvm_stackPopAnyToTemp(
1291 sjme_attrInNotNull sjme_nvm_frame
* frame
)
1292 sjme_attrOutNegativeOnePositive sjme_attrCheckReturn
;
1294 sjme_jint
sjme_nvm_stackPopInteger(
1295 sjme_attrInNotNull sjme_nvm_frame
* frame
)
1296 sjme_attrOutNegativeOnePositive
;
1298 sjme_jobject
sjme_nvm_stackPopReference(
1299 sjme_attrInNotNull sjme_nvm_frame
* frame
)
1300 sjme_attrOutNullable
;
1302 sjme_jboolean
sjme_nvm_stackPopReferenceThenThrow(
1303 sjme_attrInNotNull sjme_nvm_frame
* frame
)
1304 sjme_attrCheckReturn
;
1306 sjme_tempIndex
sjme_nvm_stackPopReferenceToTemp(
1307 sjme_attrInNotNull sjme_nvm_frame
* frame
)
1308 sjme_attrOutNegativeOnePositive sjme_attrCheckReturn
;
1310 sjme_jboolean
sjme_nvm_stackPushAny(
1311 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1312 sjme_attrInNotNull sjme_any
* input
)
1313 sjme_attrCheckReturn
;
1315 sjme_jboolean
sjme_nvm_stackPushAnyFromTemp(
1316 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1317 sjme_attrInPositive sjme_tempIndex input
)
1318 sjme_attrCheckReturn
;
1320 sjme_jboolean
sjme_nvm_stackPushDoubleParts(
1321 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1322 sjme_attrInValue sjme_jint hi
,
1323 sjme_attrInValue sjme_jint lo
)
1324 sjme_attrCheckReturn
;
1326 sjme_jboolean
sjme_nvm_stackPushFloatRaw(
1327 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1328 sjme_attrInValue sjme_jint rawValue
)
1329 sjme_attrCheckReturn
;
1331 sjme_jboolean
sjme_nvm_stackPushInteger(
1332 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1333 sjme_attrInValue sjme_jint value
)
1334 sjme_attrCheckReturn
;
1336 sjme_jboolean
sjme_nvm_stackPushIntegerIsInstanceOf(
1337 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1338 sjme_attrInNullable sjme_jobject instance
,
1339 sjme_attrInNotNull sjme_dynamic_linkage_data_classObject
* type
)
1340 sjme_attrCheckReturn
;
1342 sjme_jboolean
sjme_nvm_stackPushLongParts(
1343 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1344 sjme_attrInValue sjme_jint hi
,
1345 sjme_attrInValue sjme_jint lo
)
1346 sjme_attrCheckReturn
;
1348 sjme_jboolean
sjme_nvm_stackPushReference(
1349 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1350 sjme_attrInNullable sjme_jobject instance
)
1351 sjme_attrCheckReturn
;
1353 sjme_jboolean
sjme_nvm_stackPushReferenceFromTemp(
1354 sjme_attrInNotNull sjme_nvm_frame
* frame
,
1355 sjme_attrInPositive sjme_tempIndex tempIndex
)
1356 sjme_attrCheckReturn
;
1358 sjme_jboolean
sjme_nvm_tempDiscard(
1359 sjme_attrInNotNull sjme_nvm_frame
* frame
)
1360 sjme_attrCheckReturn
;
1362 sjme_jboolean
sjme_nvm_throwExecute(
1363 sjme_attrInNotNull sjme_nvm_frame
* frame
)
1364 sjme_attrCheckReturn
;
1367 * Returns the top-most frame in the thread.
1369 * @param inThread The thread to get the top frame from.
1370 * @param outFrame The top most frame.
1371 * @return Returns @c SJME_JNI_TRUE on success where the thread is valid and it
1372 * has at least one frame.
1375 sjme_jboolean
sjme_nvm_topFrame(
1376 sjme_attrInNotNull sjme_nvm_thread
* inThread
,
1377 sjme_attrOutNotNull sjme_nvm_frame
* outFrame
)
1378 sjme_attrCheckReturn
;
1381 * Ticks the virtual machine.
1383 * @param state The state to tick, @c -1 means to tick forever.
1384 * @param maxTics The number of ticks to execute before returning.
1385 * @return Returns @c SJME_JNI_TRUE if the machine is still running.
1388 sjme_jboolean
sjme_nvm_tick(sjme_attrInNotNull sjme_nvm_state
* state
,
1389 sjme_attrInValue sjme_attrInPositive sjme_jint maxTics
)
1390 sjme_attrCheckReturn
;
1392 /*--------------------------------------------------------------------------*/
1396 #ifdef SJME_CXX_SQUIRRELJME_NVM_H
1398 #undef SJME_CXX_SQUIRRELJME_NVM_H
1399 #undef SJME_CXX_IS_EXTERNED
1400 #endif /* #ifdef SJME_CXX_SQUIRRELJME_NVM_H */
1401 #endif /* #ifdef __cplusplus */
1403 #endif /* SQUIRRELJME_NVM_H */