2016-09-28 14:40:37 +00:00
|
|
|
/*
|
2018-02-07 14:13:13 +00:00
|
|
|
Copyright (c) 2016-2018 Chung, Hyung-Hwan. All rights reserved.
|
2016-09-28 14:40:37 +00:00
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
1. Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
|
|
|
documentation and/or other materials provided with the distribution.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
|
|
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _HCL_PRV_H_
|
|
|
|
#define _HCL_PRV_H_
|
|
|
|
|
2021-01-12 09:06:25 +00:00
|
|
|
#include <hcl.h>
|
2023-11-21 15:24:57 +00:00
|
|
|
#include <hcl-chr.h>
|
2024-10-15 07:36:25 +00:00
|
|
|
#include <hcl-cmgr.h>
|
2021-01-12 09:06:25 +00:00
|
|
|
#include <hcl-fmt.h>
|
2024-10-14 09:57:10 +00:00
|
|
|
#include <hcl-str.h>
|
2021-01-12 09:06:25 +00:00
|
|
|
#include <hcl-utl.h>
|
2016-09-28 14:40:37 +00:00
|
|
|
|
|
|
|
/* you can define this to either 1 or 2 */
|
2021-01-29 12:39:31 +00:00
|
|
|
#define HCL_CODE_LONG_PARAM_SIZE 2
|
2016-09-28 14:40:37 +00:00
|
|
|
|
2021-03-28 03:44:27 +00:00
|
|
|
/* this is useful for debugging. hcl_gc() can be called
|
2016-09-28 14:40:37 +00:00
|
|
|
* while hcl has not been fully initialized when this is defined*/
|
|
|
|
#define HCL_SUPPORT_GC_DURING_IGNITION
|
|
|
|
|
2018-02-05 10:43:25 +00:00
|
|
|
/* define this to enable karatsuba multiplication in bigint */
|
|
|
|
#define HCL_ENABLE_KARATSUBA
|
|
|
|
#define HCL_KARATSUBA_CUTOFF 32
|
|
|
|
#define HCL_KARATSUBA_CUTOFF_DEBUG 3
|
|
|
|
|
2020-11-15 10:26:14 +00:00
|
|
|
/* enable floating-pointer number support in the basic formatting functions */
|
|
|
|
#define HCL_ENABLE_FLTFMT
|
|
|
|
|
2018-02-21 09:30:18 +00:00
|
|
|
#if defined(HCL_BUILD_DEBUG)
|
2021-01-27 08:47:08 +00:00
|
|
|
/*#define HCL_DEBUG_LEXER 1*/
|
2018-02-08 09:21:18 +00:00
|
|
|
#define HCL_DEBUG_VM_PROCESSOR 1
|
|
|
|
#define HCL_DEBUG_VM_EXEC 1
|
2021-01-03 13:51:23 +00:00
|
|
|
/*#define HCL_PROFILE_VM 1*/
|
2018-02-08 09:21:18 +00:00
|
|
|
#endif
|
2016-09-28 14:40:37 +00:00
|
|
|
|
2016-10-06 17:49:47 +00:00
|
|
|
/* allow the caller to drive process switching by calling
|
|
|
|
* stix_switchprocess(). */
|
|
|
|
#define HCL_EXTERNAL_PROCESS_SWITCH
|
|
|
|
|
2016-09-28 14:40:37 +00:00
|
|
|
/* limit the maximum object size such that:
|
|
|
|
* 1. an index to an object field can be represented in a small integer.
|
|
|
|
* 2. the maximum number of bits including bit-shifts can be represented
|
|
|
|
* in the hcl_oow_t type.
|
|
|
|
*/
|
|
|
|
#define HCL_LIMIT_OBJ_SIZE
|
|
|
|
|
2018-03-08 10:00:57 +00:00
|
|
|
|
|
|
|
#define HCL_BC_BUFFER_INIT 10240
|
|
|
|
#define HCL_BC_BUFFER_ALIGN 10240
|
|
|
|
|
|
|
|
#define HCL_LIT_BUFFER_INIT 1024
|
|
|
|
#define HCL_LIT_BUFFER_ALIGN 1024
|
|
|
|
|
2016-09-28 14:40:37 +00:00
|
|
|
#if defined(__has_builtin)
|
2018-02-21 13:02:05 +00:00
|
|
|
|
|
|
|
# if (!__has_builtin(__builtin_memset) || !__has_builtin(__builtin_memcpy) || !__has_builtin(__builtin_memmove) || !__has_builtin(__builtin_memcmp))
|
|
|
|
# include <string.h>
|
|
|
|
# endif
|
|
|
|
|
2016-09-28 14:40:37 +00:00
|
|
|
# if __has_builtin(__builtin_memset)
|
|
|
|
# define HCL_MEMSET(dst,src,size) __builtin_memset(dst,src,size)
|
|
|
|
# else
|
|
|
|
# define HCL_MEMSET(dst,src,size) memset(dst,src,size)
|
|
|
|
# endif
|
|
|
|
# if __has_builtin(__builtin_memcpy)
|
|
|
|
# define HCL_MEMCPY(dst,src,size) __builtin_memcpy(dst,src,size)
|
|
|
|
# else
|
|
|
|
# define HCL_MEMCPY(dst,src,size) memcpy(dst,src,size)
|
|
|
|
# endif
|
|
|
|
# if __has_builtin(__builtin_memmove)
|
|
|
|
# define HCL_MEMMOVE(dst,src,size) __builtin_memmove(dst,src,size)
|
|
|
|
# else
|
|
|
|
# define HCL_MEMMOVE(dst,src,size) memmove(dst,src,size)
|
|
|
|
# endif
|
|
|
|
# if __has_builtin(__builtin_memcmp)
|
|
|
|
# define HCL_MEMCMP(dst,src,size) __builtin_memcmp(dst,src,size)
|
|
|
|
# else
|
|
|
|
# define HCL_MEMCMP(dst,src,size) memcmp(dst,src,size)
|
|
|
|
# endif
|
|
|
|
|
|
|
|
#else
|
2022-07-19 02:58:28 +00:00
|
|
|
|
|
|
|
/* g++ 2.95 had a problem with __builtin_memxxx functions:
|
|
|
|
* implicit declaration of function `__builtin_memmove' */
|
|
|
|
# if defined(__cplusplus) && defined(__GNUC__) && (__GNUC__ <= 2)
|
|
|
|
# undef HAVE___BUILTIN_MEMSET
|
|
|
|
# undef HAVE___BUILTIN_MEMCPY
|
|
|
|
# undef HAVE___BUILTIN_MEMMOVE
|
|
|
|
# undef HAVE___BUILTIN_MEMCMP
|
|
|
|
# endif
|
|
|
|
|
|
|
|
# if !defined(HAVE___BUILTIN_MEMSET) || \
|
|
|
|
!defined(HAVE___BUILTIN_MEMCPY) || \
|
|
|
|
!defined(HAVE___BUILTIN_MEMMOVE) || \
|
2023-10-23 09:49:15 +00:00
|
|
|
!defined(HAVE___BUILTIN_MEMCMP)
|
2022-07-19 02:58:28 +00:00
|
|
|
# include <string.h>
|
|
|
|
# endif
|
|
|
|
|
|
|
|
# if defined(HAVE___BUILTIN_MEMSET)
|
|
|
|
# define HCL_MEMSET(dst,src,size) __builtin_memset(dst,src,size)
|
|
|
|
# else
|
|
|
|
# define HCL_MEMSET(dst,src,size) memset(dst,src,size)
|
|
|
|
# endif
|
|
|
|
# if defined(HAVE___BUILTIN_MEMCPY)
|
|
|
|
# define HCL_MEMCPY(dst,src,size) __builtin_memcpy(dst,src,size)
|
|
|
|
# else
|
|
|
|
# define HCL_MEMCPY(dst,src,size) memcpy(dst,src,size)
|
|
|
|
# endif
|
|
|
|
# if defined(HAVE___BUILTIN_MEMMOVE)
|
|
|
|
# define HCL_MEMMOVE(dst,src,size) __builtin_memmove(dst,src,size)
|
|
|
|
# else
|
|
|
|
# define HCL_MEMMOVE(dst,src,size) memmove(dst,src,size)
|
|
|
|
# endif
|
|
|
|
# if defined(HAVE___BUILTIN_MEMCMP)
|
|
|
|
# define HCL_MEMCMP(dst,src,size) __builtin_memcmp(dst,src,size)
|
|
|
|
# else
|
|
|
|
# define HCL_MEMCMP(dst,src,size) memcmp(dst,src,size)
|
|
|
|
# endif
|
|
|
|
|
2016-09-28 14:40:37 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HCL_LIMIT_OBJ_SIZE)
|
|
|
|
/* limit the maximum object size such that:
|
|
|
|
* 1. an index to an object field can be represented in a small integer.
|
|
|
|
* 2. the maximum number of bit shifts can be represented in the hcl_oow_t type.
|
|
|
|
*/
|
|
|
|
# define HCL_OBJ_SIZE_MAX ((hcl_oow_t)HCL_SMOOI_MAX)
|
2019-05-04 17:56:45 +00:00
|
|
|
# define HCL_OBJ_SIZE_BITS_MAX (HCL_OBJ_SIZE_MAX * HCL_BITS_PER_BYTE)
|
2016-09-28 14:40:37 +00:00
|
|
|
#else
|
|
|
|
# define HCL_OBJ_SIZE_MAX ((hcl_oow_t)HCL_TYPE_MAX(hcl_oow_t))
|
2019-05-04 17:56:45 +00:00
|
|
|
# define HCL_OBJ_SIZE_BITS_MAX (HCL_OBJ_SIZE_MAX * HCL_BITS_PER_BYTE)
|
2016-09-28 14:40:37 +00:00
|
|
|
#endif
|
|
|
|
|
2024-03-03 13:17:14 +00:00
|
|
|
/* ========================================================================= */
|
|
|
|
/* CLASS SPEC ENCODING */
|
|
|
|
/* ========================================================================= */
|
|
|
|
/*
|
|
|
|
* The spec field of a class object encodes the number of the fixed part
|
|
|
|
* and the type of the indexed part. The fixed part is the number of
|
|
|
|
* named instance variables. If the spec of a class is indexed, the object
|
|
|
|
* of the class can be instantiated with the size of the indexed part.
|
|
|
|
*
|
|
|
|
* For example, on a platform where sizeof(hcl_oow_t) is 4,
|
|
|
|
* the layout of the spec field of a class as an OOP value looks like this:
|
|
|
|
*
|
|
|
|
* 31 12 11 10 9 8 7 6 5 4 3 2 1 0
|
|
|
|
* |number of named instance variables|indexed-type|flags |oop-tag|
|
|
|
|
*
|
|
|
|
* the number of named instance variables is stored in high 21 bits.
|
|
|
|
* the indexed type takes up bit 5 to bit 10 (assuming HCL_OBJ_TYPE_BITS is 6.
|
|
|
|
* HCL_OBJ_TYPE_XXX enumerators are used to represent actual values).
|
|
|
|
* and the indexability is stored in the flag bits which span from bit 2 to 4.
|
|
|
|
*
|
|
|
|
* The maximum number of named(fixed) instance variables for a class is:
|
|
|
|
* 2 ^ ((BITS-IN-OOW - HCL_OOP_TAG_BITS_LO) - HCL_OBJ_TYPE_BITS - 1 - 2) - 1
|
|
|
|
*
|
|
|
|
* HCL_OOP_TAG_BITS_LO are decremented from the number of bits in OOW because
|
|
|
|
* the spec field is always encoded as a small integer.
|
|
|
|
*
|
|
|
|
* The number of named instance variables can be greater than 0 if the
|
|
|
|
* class spec is not indexed or if it's a pointer indexed class
|
|
|
|
* (indexed_type == HCL_OBJ_TYPE_OOP)
|
|
|
|
*
|
|
|
|
* indexed_type is one of the #hcl_obj_type_t enumerators.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define HCL_CLASS_SPEC_FLAG_BITS (3)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The HCL_CLASS_SPEC_MAKE() macro creates a class spec value.
|
|
|
|
* _class->spec = HCL_SMOOI_TO_OOP(HCL_CLASS_SPEC_MAKE(0, 1, HCL_OBJ_TYPE_CHAR));
|
|
|
|
*/
|
|
|
|
#define HCL_CLASS_SPEC_MAKE(named_instvar,flags,indexed_type) ( \
|
|
|
|
(((hcl_oow_t)(named_instvar)) << (HCL_OBJ_FLAGS_TYPE_BITS + HCL_CLASS_SPEC_FLAG_BITS)) | \
|
|
|
|
(((hcl_oow_t)(indexed_type)) << (HCL_CLASS_SPEC_FLAG_BITS)) | (((hcl_oow_t)flags) & HCL_LBMASK(hcl_oow_t,HCL_CLASS_SPEC_FLAG_BITS)))
|
|
|
|
|
|
|
|
/* what is the number of named instance variables?
|
|
|
|
* HCL_CLASS_SPEC_NAMED_INSTVARS(HCL_OOP_TO_SMOOI(_class->spec))
|
|
|
|
* ensure to update Class<<specNumInstVars if you change this macro. */
|
|
|
|
#define HCL_CLASS_SPEC_NAMED_INSTVARS(spec) \
|
|
|
|
(((hcl_oow_t)(spec)) >> (HCL_OBJ_FLAGS_TYPE_BITS + HCL_CLASS_SPEC_FLAG_BITS))
|
|
|
|
|
|
|
|
/* is it a user-indexable class?
|
|
|
|
* all objects can be indexed with basicAt:.
|
|
|
|
* this indicates if an object can be instantiated with a dynamic size
|
|
|
|
* (new: size) and and can be indexed with at:.
|
|
|
|
*/
|
|
|
|
#define HCL_CLASS_SPEC_FLAGS(spec) (((hcl_oow_t)(spec)) & HCL_LBMASK(hcl_oow_t,HCL_CLASS_SPEC_FLAG_BITS))
|
|
|
|
|
|
|
|
/* if so, what is the indexing type? character? pointer? etc? */
|
|
|
|
#define HCL_CLASS_SPEC_INDEXED_TYPE(spec) \
|
|
|
|
((((hcl_oow_t)(spec)) >> HCL_CLASS_SPEC_FLAG_BITS) & HCL_LBMASK(hcl_oow_t, HCL_OBJ_FLAGS_TYPE_BITS))
|
|
|
|
|
2024-10-07 12:46:41 +00:00
|
|
|
/* If you add more than 4 items, you must update code related to CLASS_ENTER instruction
|
|
|
|
* and class attributes as well as HCL_CLASS_SPEC_FLAG_BITS. */
|
2024-03-03 13:17:14 +00:00
|
|
|
#define HCL_CLASS_SPEC_FLAG_INDEXED (1 << 0)
|
|
|
|
#define HCL_CLASS_SPEC_FLAG_IMMUTABLE (1 << 1)
|
|
|
|
#define HCL_CLASS_SPEC_FLAG_UNCOPYABLE (1 << 2)
|
|
|
|
|
|
|
|
#define HCL_CLASS_SPEC_IS_INDEXED(spec) (HCL_CLASS_SPEC_FLAGS(spec) & HCL_CLASS_SPEC_FLAG_INDEXED)
|
|
|
|
#define HCL_CLASS_SPEC_IS_IMMUTABLE(spec) (HCL_CLASS_SPEC_FLAGS(spec) & HCL_CLASS_SPEC_FLAG_IMMUTABLE)
|
|
|
|
#define HCL_CLASS_SPEC_IS_UNCOPYABLE(spec) (HCL_CLASS_SPEC_FLAGS(spec) & HCL_CLASS_SPEC_FLAG_UNCOPYABLE)
|
|
|
|
|
|
|
|
/* What is the maximum number of named instance variables?
|
|
|
|
* This limit is set this way because the number must be encoded into
|
|
|
|
* the spec field of the class with limited number of bits assigned to
|
|
|
|
* the number of named instance variables.
|
|
|
|
*/
|
2024-07-23 14:50:29 +00:00
|
|
|
#define HCL_CLASS_SPEC_INSTVAR_BITS (HCL_SMOOI_ABS_BITS - (HCL_OBJ_FLAGS_TYPE_BITS + HCL_CLASS_SPEC_FLAG_BITS))
|
|
|
|
#define HCL_MAX_NAMED_INSTVARS HCL_BITS_MAX(hcl_oow_t, HCL_CLASS_SPEC_INSTVAR_BITS)
|
2024-03-03 13:17:14 +00:00
|
|
|
|
|
|
|
/* Given the number of named instance variables, what is the maximum number
|
|
|
|
* of indexed instance variables? The number of indexed instance variables
|
|
|
|
* is not stored in the spec field of the class. It only affects the actual
|
|
|
|
* size of an object(obj->_size) selectively combined with the number of
|
|
|
|
* named instance variables. So it's the maximum value of obj->_size minus
|
|
|
|
* the number of named instance variables.
|
|
|
|
*/
|
|
|
|
#define HCL_MAX_INDEXED_INSTVARS(named_instvar) (HCL_OBJ_SIZE_MAX - named_instvar)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* self-specification of a class
|
|
|
|
* | classinstvars | classvars | flags |
|
|
|
|
*
|
|
|
|
* When converted to a small integer
|
|
|
|
* | sign-bit | classinstvars | classvars | flags | tag |
|
|
|
|
*/
|
|
|
|
#define HCL_CLASS_SELFSPEC_FLAG_BITS (3)
|
|
|
|
#define HCL_CLASS_SELFSPEC_CLASSINSTVAR_BITS ((HCL_SMOOI_ABS_BITS - HCL_CLASS_SELFSPEC_FLAG_BITS) / 2)
|
|
|
|
#define HCL_CLASS_SELFSPEC_CLASSVAR_BITS (HCL_SMOOI_ABS_BITS - (HCL_CLASS_SELFSPEC_CLASSINSTVAR_BITS + HCL_CLASS_SELFSPEC_FLAG_BITS))
|
|
|
|
|
|
|
|
#define HCL_CLASS_SELFSPEC_MAKE(class_var,classinst_var,flag) \
|
|
|
|
((((hcl_oow_t)class_var) << (HCL_CLASS_SELFSPEC_CLASSINSTVAR_BITS + HCL_CLASS_SELFSPEC_FLAG_BITS)) | \
|
|
|
|
(((hcl_oow_t)classinst_var) << (HCL_CLASS_SELFSPEC_FLAG_BITS)) | \
|
|
|
|
(((hcl_oow_t)flag) << (0)))
|
|
|
|
|
|
|
|
#define HCL_CLASS_SELFSPEC_CLASSVARS(spec) \
|
|
|
|
(((hcl_oow_t)spec) >> (HCL_CLASS_SELFSPEC_CLASSINSTVAR_BITS + HCL_CLASS_SELFSPEC_FLAG_BITS))
|
|
|
|
|
|
|
|
#define HCL_CLASS_SELFSPEC_CLASSINSTVARS(spec) \
|
|
|
|
((((hcl_oow_t)spec) >> HCL_CLASS_SELFSPEC_FLAG_BITS) & HCL_LBMASK(hcl_oow_t, HCL_CLASS_SELFSPEC_CLASSINSTVAR_BITS))
|
|
|
|
|
|
|
|
#define HCL_CLASS_SELFSPEC_FLAGS(spec) \
|
|
|
|
(((hcl_oow_t)spec) & HCL_LBMASK(hcl_oow_t, HCL_CLASS_SELFSPEC_FLAG_BITS))
|
|
|
|
|
2024-10-07 12:46:41 +00:00
|
|
|
/* If you add more than 4 items, you must update code related to CLASS_ENTER instruction
|
|
|
|
* and class attributes as well as HCL_CLASS_SELFSPEC_FLAG_BITS. */
|
2024-03-03 13:17:14 +00:00
|
|
|
#define HCL_CLASS_SELFSPEC_FLAG_FINAL (1 << 0)
|
2024-10-06 16:42:40 +00:00
|
|
|
#define HCL_CLASS_SELFSPEC_FLAG_LIMITED (1 << 1) /* not allowed to instantiate normally */
|
2024-03-03 13:17:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define HCL_MAX_CLASSVARS HCL_BITS_MAX(hcl_oow_t, HCL_CLASS_SELFSPEC_CLASSVAR_BITS)
|
|
|
|
#define HCL_MAX_CLASSINSTVARS HCL_BITS_MAX(hcl_oow_t, HCL_CLASS_SELFSPEC_CLASSINSTVAR_BITS)
|
|
|
|
|
|
|
|
/* ========================================================================= */
|
|
|
|
/* END OF CLASS SPEC ENCODING */
|
|
|
|
/* ========================================================================= */
|
|
|
|
|
|
|
|
|
2016-09-28 14:40:37 +00:00
|
|
|
|
|
|
|
#if defined(HCL_INCLUDE_COMPILER)
|
|
|
|
|
|
|
|
/* ========================================================================= */
|
|
|
|
/* SOURCE CODE I/O FOR COMPILER */
|
|
|
|
/* ========================================================================= */
|
2023-11-04 13:58:31 +00:00
|
|
|
enum hcl_tok_type_t
|
2018-02-26 15:24:45 +00:00
|
|
|
{
|
2023-11-07 10:19:06 +00:00
|
|
|
HCL_TOK_EOF,
|
2024-01-25 14:48:06 +00:00
|
|
|
|
2024-09-04 16:12:20 +00:00
|
|
|
/* the following 5 items must be in this order for code
|
|
|
|
* in flx_quoted_token() in read.c */
|
2023-11-07 10:19:06 +00:00
|
|
|
HCL_TOK_CHARLIT,
|
2024-01-25 14:48:06 +00:00
|
|
|
HCL_TOK_BCHRLIT,
|
2023-11-07 10:19:06 +00:00
|
|
|
HCL_TOK_STRLIT,
|
2024-01-25 14:48:06 +00:00
|
|
|
HCL_TOK_BSTRLIT,
|
2024-09-04 16:12:20 +00:00
|
|
|
HCL_TOK_SYMLIT,
|
2024-01-25 14:48:06 +00:00
|
|
|
|
2023-11-07 10:19:06 +00:00
|
|
|
HCL_TOK_NUMLIT,
|
|
|
|
HCL_TOK_RADNUMLIT,
|
|
|
|
HCL_TOK_FPDECLIT,
|
|
|
|
HCL_TOK_SMPTRLIT,
|
|
|
|
HCL_TOK_ERRLIT,
|
2024-08-20 16:00:29 +00:00
|
|
|
|
2023-11-07 10:19:06 +00:00
|
|
|
HCL_TOK_NIL,
|
|
|
|
HCL_TOK_TRUE,
|
|
|
|
HCL_TOK_FALSE,
|
|
|
|
HCL_TOK_SELF,
|
|
|
|
HCL_TOK_SUPER,
|
|
|
|
|
2024-08-22 07:06:59 +00:00
|
|
|
HCL_TOK_CLASS,
|
|
|
|
HCL_TOK_FUN,
|
2024-10-11 15:24:02 +00:00
|
|
|
HCL_TOK_VAR,
|
2024-08-22 16:07:08 +00:00
|
|
|
HCL_TOK_DO,
|
2024-08-20 16:00:29 +00:00
|
|
|
HCL_TOK_IF,
|
|
|
|
HCL_TOK_ELIF,
|
|
|
|
HCL_TOK_ELSE,
|
2024-08-21 13:19:41 +00:00
|
|
|
HCL_TOK_THROW,
|
|
|
|
HCL_TOK_TRY,
|
|
|
|
HCL_TOK_CATCH,
|
2024-08-22 07:06:59 +00:00
|
|
|
HCL_TOK_BREAK,
|
|
|
|
HCL_TOK_CONTINUE,
|
|
|
|
HCL_TOK_UNTIL,
|
|
|
|
HCL_TOK_WHILE,
|
2024-08-22 09:10:41 +00:00
|
|
|
HCL_TOK_RETURN,
|
|
|
|
HCL_TOK_REVERT,
|
2024-10-03 12:41:59 +00:00
|
|
|
HCL_TOK_AND,
|
|
|
|
HCL_TOK_OR,
|
|
|
|
HCL_TOK_PLUS,
|
|
|
|
HCL_TOK_SET,
|
|
|
|
HCL_TOK_SET_R,
|
2024-08-20 16:00:29 +00:00
|
|
|
|
2024-02-04 12:35:31 +00:00
|
|
|
HCL_TOK_BINOP,
|
2023-11-07 10:19:06 +00:00
|
|
|
HCL_TOK_IDENT,
|
|
|
|
HCL_TOK_IDENT_DOTTED,
|
2023-12-01 18:35:59 +00:00
|
|
|
HCL_TOK_IDENT_DOTTED_CLA,
|
2023-11-07 10:19:06 +00:00
|
|
|
HCL_TOK_DOT, /* . */
|
|
|
|
HCL_TOK_DBLDOTS, /* .. */
|
|
|
|
HCL_TOK_ELLIPSIS, /* ... */
|
|
|
|
HCL_TOK_COLON, /* : */
|
|
|
|
HCL_TOK_DBLCOLONS, /* :: */
|
|
|
|
HCL_TOK_TRPCOLONS, /* ::: */
|
2024-01-05 06:01:59 +00:00
|
|
|
HCL_TOK_COLONEQ, /* := */
|
2024-02-03 09:59:17 +00:00
|
|
|
HCL_TOK_COLONGT, /* :+ */
|
|
|
|
HCL_TOK_COLONLT, /* :+ */
|
2023-11-07 10:47:37 +00:00
|
|
|
HCL_TOK_SEMICOLON, /* ; */
|
2023-11-07 10:19:06 +00:00
|
|
|
HCL_TOK_COMMA, /* , */
|
|
|
|
HCL_TOK_LPAREN, /* ( */
|
|
|
|
HCL_TOK_RPAREN, /* ) */
|
2024-01-03 12:11:23 +00:00
|
|
|
|
|
|
|
#if 0 /* use the (obj:message ... ) syntax instad. no more mlist by (: */
|
2023-11-07 10:19:06 +00:00
|
|
|
HCL_TOK_LPARCOLON, /* (: */
|
2024-01-03 12:11:23 +00:00
|
|
|
#define HCL_TOK_LPARCOLON HCL_TOK_LPARCOLON
|
|
|
|
#endif
|
|
|
|
|
2024-01-27 15:03:40 +00:00
|
|
|
HCL_TOK_APAREN, /* #[ - array parenthesis */
|
|
|
|
HCL_TOK_BAPAREN, /* #b[ - byte array parenthesis */
|
|
|
|
HCL_TOK_CAPAREN, /* #c[ - character array parenthesis */
|
2024-02-02 05:57:46 +00:00
|
|
|
#if 0
|
2024-01-27 15:03:40 +00:00
|
|
|
HCL_TOK_WAPAREN, /* #w[ - word array parenthesis */
|
2024-02-02 05:57:46 +00:00
|
|
|
HCL_TOK_HWAPAREN, /* #hw[ - half-word array parenthesis */
|
2024-01-27 15:03:40 +00:00
|
|
|
#endif
|
2023-11-07 10:19:06 +00:00
|
|
|
HCL_TOK_QLPAREN, /* #( - quoted-list parenthesis */
|
|
|
|
HCL_TOK_DLPAREN, /* #{ - dictionary parenthese */
|
2024-01-27 15:03:40 +00:00
|
|
|
HCL_TOK_LBRACK, /* [ - group */
|
2023-11-07 10:19:06 +00:00
|
|
|
HCL_TOK_RBRACK, /* ] */
|
|
|
|
HCL_TOK_LBRACE, /* { - block */
|
|
|
|
HCL_TOK_RBRACE, /* } */
|
|
|
|
HCL_TOK_VBAR, /* | */
|
|
|
|
HCL_TOK_EOL, /* end of line */
|
|
|
|
|
|
|
|
HCL_TOK_INCLUDE,
|
|
|
|
HCL_TOK_PRAGMA
|
2018-02-26 15:24:45 +00:00
|
|
|
};
|
2023-11-04 13:58:31 +00:00
|
|
|
typedef enum hcl_tok_type_t hcl_tok_type_t;
|
2018-02-26 15:24:45 +00:00
|
|
|
|
2023-11-04 13:58:31 +00:00
|
|
|
typedef struct hcl_tok_t hcl_tok_t;
|
|
|
|
struct hcl_tok_t
|
2016-09-28 14:40:37 +00:00
|
|
|
{
|
2023-11-04 13:58:31 +00:00
|
|
|
hcl_tok_type_t type;
|
2016-09-28 14:40:37 +00:00
|
|
|
hcl_oocs_t name;
|
|
|
|
hcl_oow_t name_capa;
|
2023-11-04 13:58:31 +00:00
|
|
|
hcl_loc_t loc;
|
2016-09-28 14:40:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2023-11-04 13:58:31 +00:00
|
|
|
typedef struct hcl_link_t hcl_link_t;
|
|
|
|
struct hcl_link_t
|
2016-09-28 14:40:37 +00:00
|
|
|
{
|
2023-11-04 13:58:31 +00:00
|
|
|
hcl_link_t* link;
|
2016-09-28 14:40:37 +00:00
|
|
|
};
|
|
|
|
|
2021-01-03 17:58:57 +00:00
|
|
|
enum hcl_cnode_type_t
|
|
|
|
{
|
|
|
|
HCL_CNODE_CHARLIT,
|
2024-01-25 14:48:06 +00:00
|
|
|
HCL_CNODE_BCHRLIT,
|
2021-01-12 09:06:25 +00:00
|
|
|
HCL_CNODE_SYMBOL,
|
2021-01-17 17:45:39 +00:00
|
|
|
HCL_CNODE_DSYMBOL, /* dotted symbol */
|
2021-01-03 17:58:57 +00:00
|
|
|
HCL_CNODE_STRLIT,
|
2024-01-25 14:48:06 +00:00
|
|
|
HCL_CNODE_BSTRLIT,
|
2024-09-04 16:12:20 +00:00
|
|
|
HCL_CNODE_SYMLIT,
|
2021-01-03 17:58:57 +00:00
|
|
|
HCL_CNODE_NUMLIT,
|
|
|
|
HCL_CNODE_RADNUMLIT,
|
|
|
|
HCL_CNODE_FPDECLIT,
|
|
|
|
HCL_CNODE_SMPTRLIT,
|
2024-10-03 08:21:08 +00:00
|
|
|
HCL_CNODE_ERRLIT, /* last item for HCL_CNODE_IS_FOR_DATA_LITERAL */
|
2024-08-20 16:00:29 +00:00
|
|
|
|
2021-01-03 17:58:57 +00:00
|
|
|
HCL_CNODE_NIL,
|
|
|
|
HCL_CNODE_TRUE,
|
|
|
|
HCL_CNODE_FALSE,
|
2022-02-05 17:35:10 +00:00
|
|
|
HCL_CNODE_SELF,
|
2024-10-03 08:21:08 +00:00
|
|
|
HCL_CNODE_SUPER, /* last item for HCL_CNODE_IS_FOR_DATA_SIMPLE */
|
2024-08-22 07:06:59 +00:00
|
|
|
|
2024-10-01 15:33:34 +00:00
|
|
|
HCL_CNODE_CONS,
|
|
|
|
HCL_CNODE_ELIST, /* empty list */
|
|
|
|
HCL_CNODE_SHELL, /* pseudo-node to hold another actual node */
|
|
|
|
|
|
|
|
/* If HCL_CNODE_SHELL is not the last item before the horizontal line,
|
|
|
|
* HCL_CNDOE_IS_FOR_DATA(x) must be revised */
|
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
|
|
|
|
/* the cnode types from here don't represent actual data.
|
|
|
|
* these represent syntactical elements of the language only. */
|
2024-10-03 08:21:08 +00:00
|
|
|
HCL_CNODE_CLASS, /* first item for HCL_CNODE_IS_FOR_LANG */
|
2024-08-22 07:06:59 +00:00
|
|
|
HCL_CNODE_FUN,
|
2024-10-11 15:24:02 +00:00
|
|
|
HCL_CNODE_VAR,
|
2024-08-22 16:07:08 +00:00
|
|
|
HCL_CNODE_DO,
|
2024-08-20 16:00:29 +00:00
|
|
|
HCL_CNODE_IF,
|
|
|
|
HCL_CNODE_ELIF,
|
|
|
|
HCL_CNODE_ELSE,
|
2024-08-21 13:19:41 +00:00
|
|
|
HCL_CNODE_THROW,
|
|
|
|
HCL_CNODE_TRY,
|
|
|
|
HCL_CNODE_CATCH,
|
2024-08-22 07:06:59 +00:00
|
|
|
HCL_CNODE_BREAK,
|
|
|
|
HCL_CNODE_CONTINUE,
|
|
|
|
HCL_CNODE_UNTIL,
|
|
|
|
HCL_CNODE_WHILE,
|
2024-08-22 09:10:41 +00:00
|
|
|
HCL_CNODE_RETURN,
|
2024-10-03 12:41:59 +00:00
|
|
|
HCL_CNODE_REVERT,
|
|
|
|
HCL_CNODE_AND,
|
|
|
|
HCL_CNODE_OR,
|
|
|
|
HCL_CNODE_PLUS,
|
|
|
|
HCL_CNODE_SET,
|
|
|
|
HCL_CNODE_SET_R, /* language item for HCL_CODE_IS_FOR_LANG */
|
2024-08-20 16:00:29 +00:00
|
|
|
|
2024-10-01 15:41:54 +00:00
|
|
|
HCL_CNODE_ELLIPSIS, /* ... */
|
|
|
|
HCL_CNODE_TRPCOLONS, /* ::: */
|
2024-02-03 16:57:53 +00:00
|
|
|
HCL_CNODE_DBLCOLONS, /* :: */
|
2024-05-26 14:18:26 +00:00
|
|
|
HCL_CNODE_COLON, /* : */
|
2024-02-03 09:59:17 +00:00
|
|
|
HCL_CNODE_COLONGT, /* :> */
|
2024-10-01 15:41:54 +00:00
|
|
|
HCL_CNODE_COLONLT /* :< */
|
2021-01-03 17:58:57 +00:00
|
|
|
};
|
|
|
|
typedef enum hcl_cnode_type_t hcl_cnode_type_t;
|
|
|
|
|
2023-11-27 16:44:13 +00:00
|
|
|
enum hcl_cnode_flag_t
|
|
|
|
{
|
|
|
|
HCL_CNODE_AUTO_FORGED = (1 << 0)
|
|
|
|
};
|
2024-04-06 07:52:53 +00:00
|
|
|
typedef enum hcl_cnode_flag_t hcl_cnode_flag_t;
|
2023-11-27 16:44:13 +00:00
|
|
|
|
2021-01-19 14:07:42 +00:00
|
|
|
#define HCL_CNODE_GET_TYPE(x) ((x)->cn_type)
|
2023-11-27 16:44:13 +00:00
|
|
|
#define HCL_CNODE_GET_FLAGS(x) ((x)->cn_flags)
|
2021-01-19 14:07:42 +00:00
|
|
|
#define HCL_CNODE_GET_LOC(x) (&(x)->cn_loc)
|
|
|
|
#define HCL_CNODE_GET_TOK(x) (&(x)->cn_tok)
|
|
|
|
#define HCL_CNODE_GET_TOKPTR(x) ((x)->cn_tok.ptr)
|
|
|
|
#define HCL_CNODE_GET_TOKLEN(x) ((x)->cn_tok.len)
|
|
|
|
|
2024-08-20 16:00:29 +00:00
|
|
|
#define HCL_CNODE_IS_TYPED(x, _type) ((x)->cn_type == _type)
|
2024-10-01 15:33:34 +00:00
|
|
|
#define HCL_CNODE_IS_FOR_DATA(x) ((x)->cn_type <= HCL_CNODE_SHELL)
|
2024-10-03 08:21:08 +00:00
|
|
|
#define HCL_CNODE_IS_FOR_DATA_SIMPLE(x) ((x)->cn_type <= HCL_CNODE_SUPER)
|
|
|
|
#define HCL_CNODE_IS_FOR_DATA_LITERAL(x) ((x)->cn_type <= HCL_CNODE_ERRLIT)
|
|
|
|
|
|
|
|
/* words to compose the language itself.
|
|
|
|
* the words pointing to data items(e.g. super, self, nil, true, false) are excluded */
|
2024-10-03 12:41:59 +00:00
|
|
|
#define HCL_CNODE_IS_FOR_LANG(x)((x)->cn_type >= HCL_CNODE_CLASS && (x)->cn_type <= HCL_CNODE_SET_R)
|
2024-08-20 16:00:29 +00:00
|
|
|
|
2021-05-07 08:53:01 +00:00
|
|
|
#define HCL_CNODE_IS_ELLIPSIS(x) ((x)->cn_type == HCL_CNODE_ELLIPSIS)
|
2021-05-09 15:32:54 +00:00
|
|
|
#define HCL_CNODE_IS_TRPCOLONS(x) ((x)->cn_type == HCL_CNODE_TRPCOLONS)
|
2024-02-03 16:57:53 +00:00
|
|
|
#define HCL_CNODE_IS_DBLCOLONS(x) ((x)->cn_type == HCL_CNODE_DBLCOLONS)
|
2024-05-26 14:18:26 +00:00
|
|
|
#define HCL_CNODE_IS_COLON(x) ((x)->cn_type == HCL_CNODE_COLON)
|
2024-02-03 09:59:17 +00:00
|
|
|
#define HCL_CNODE_IS_COLONGT(x) ((x)->cn_type == HCL_CNODE_COLONGT)
|
|
|
|
#define HCL_CNODE_IS_COLONLT(x) ((x)->cn_type == HCL_CNODE_COLONLT)
|
2021-05-07 08:53:01 +00:00
|
|
|
|
2021-01-19 14:07:42 +00:00
|
|
|
#define HCL_CNODE_IS_SYMBOL(x) ((x)->cn_type == HCL_CNODE_SYMBOL)
|
2024-10-03 15:39:41 +00:00
|
|
|
#define HCL_CNODE_IS_SYMBOL_IDENT(x) (HCL_CNODE_IS_SYMBOL(x) && !hcl_is_binop_char((x)->cn_tok.ptr[0]))
|
|
|
|
#define HCL_CNODE_IS_SYMBOL_BINOP(x) (HCL_CNODE_IS_SYMBOL(x) && hcl_is_binop_char((x)->cn_tok.ptr[0]))
|
2021-01-19 14:07:42 +00:00
|
|
|
|
2021-01-22 15:07:47 +00:00
|
|
|
#define HCL_CNODE_IS_DSYMBOL(x) ((x)->cn_type == HCL_CNODE_DSYMBOL)
|
2023-12-01 18:35:59 +00:00
|
|
|
#define HCL_CNODE_IS_DSYMBOL_CLA(x) ((x)->cn_type == HCL_CNODE_DSYMBOL && (x)->u.dsymbol.is_cla)
|
2021-01-22 15:07:47 +00:00
|
|
|
|
2021-01-19 14:07:42 +00:00
|
|
|
#define HCL_CNODE_IS_CONS(x) ((x)->cn_type == HCL_CNODE_CONS)
|
|
|
|
#define HCL_CNODE_IS_CONS_CONCODED(x, code) ((x)->cn_type == HCL_CNODE_CONS && (x)->u.cons.concode == (code))
|
|
|
|
#define HCL_CNODE_CONS_CONCODE(x) ((x)->u.cons.concode)
|
|
|
|
#define HCL_CNODE_CONS_CAR(x) ((x)->u.cons.car)
|
|
|
|
#define HCL_CNODE_CONS_CDR(x) ((x)->u.cons.cdr)
|
|
|
|
|
2021-01-25 15:23:24 +00:00
|
|
|
#define HCL_CNODE_IS_ELIST(x) ((x)->cn_type == HCL_CNODE_ELIST)
|
2021-02-01 13:20:46 +00:00
|
|
|
#define HCL_CNODE_IS_ELIST_CONCODED(x, code) ((x)->cn_type == HCL_CNODE_ELIST && (x)->u.elist.concode == (code))
|
2021-01-25 15:23:24 +00:00
|
|
|
#define HCL_CNODE_ELIST_CONCODE(x) ((x)->u.elist.concode)
|
2021-01-19 14:07:42 +00:00
|
|
|
|
2021-01-03 17:58:57 +00:00
|
|
|
/* NOTE: hcl_cnode_t used by the built-in compiler is not an OOP object */
|
|
|
|
struct hcl_cnode_t
|
|
|
|
{
|
2021-01-19 14:07:42 +00:00
|
|
|
hcl_cnode_type_t cn_type;
|
2023-11-27 16:44:13 +00:00
|
|
|
int cn_flags;
|
2023-11-04 13:58:31 +00:00
|
|
|
hcl_loc_t cn_loc;
|
2021-01-19 14:07:42 +00:00
|
|
|
hcl_oocs_t cn_tok;
|
2021-01-03 17:58:57 +00:00
|
|
|
|
|
|
|
union
|
|
|
|
{
|
2021-01-06 09:37:29 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
hcl_ooch_t v;
|
|
|
|
} charlit;
|
2021-01-19 14:07:42 +00:00
|
|
|
struct
|
2024-01-25 14:48:06 +00:00
|
|
|
{
|
|
|
|
hcl_oob_t v;
|
|
|
|
} bchrlit;
|
|
|
|
struct
|
2023-12-01 18:35:59 +00:00
|
|
|
{
|
|
|
|
int is_cla; /* class-level accessor. prefixed with self or super */
|
|
|
|
} dsymbol;
|
|
|
|
struct
|
2021-01-10 16:04:36 +00:00
|
|
|
{
|
|
|
|
hcl_oow_t v;
|
|
|
|
} smptrlit;
|
|
|
|
struct
|
2021-01-06 09:37:29 +00:00
|
|
|
{
|
|
|
|
hcl_ooi_t v;
|
|
|
|
} errlit;
|
2021-01-10 16:04:36 +00:00
|
|
|
struct
|
|
|
|
{
|
2021-01-19 14:07:42 +00:00
|
|
|
hcl_concode_t concode;
|
2021-01-10 16:04:36 +00:00
|
|
|
hcl_cnode_t* car;
|
|
|
|
hcl_cnode_t* cdr;
|
|
|
|
} cons;
|
2021-01-13 09:54:44 +00:00
|
|
|
struct
|
|
|
|
{
|
2021-01-19 14:07:42 +00:00
|
|
|
hcl_concode_t concode;
|
2021-01-25 15:23:24 +00:00
|
|
|
} elist;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
hcl_cnode_t* obj;
|
|
|
|
} shell;
|
2021-01-03 17:58:57 +00:00
|
|
|
} u;
|
|
|
|
};
|
|
|
|
|
2021-11-23 14:42:20 +00:00
|
|
|
struct hcl_var_info_t
|
|
|
|
{
|
|
|
|
int type;
|
|
|
|
/* ctx_offset 0 means the current context.
|
|
|
|
* 1 means current->home.
|
2023-10-23 09:49:15 +00:00
|
|
|
* 2 means current->home->home.
|
2021-11-23 14:42:20 +00:00
|
|
|
* index_in_ctx is a relative index within the context found.
|
|
|
|
*/
|
|
|
|
hcl_oow_t ctx_offset; /* context offset */
|
|
|
|
hcl_oow_t index_in_ctx; /* index in the current scope */
|
|
|
|
};
|
|
|
|
typedef struct hcl_var_info_t hcl_var_info_t;
|
|
|
|
|
|
|
|
|
2016-09-28 14:40:37 +00:00
|
|
|
/* NOTE: hcl_cframe_t used by the built-in compiler is not an OOP object */
|
|
|
|
struct hcl_cframe_t
|
2021-01-17 17:45:39 +00:00
|
|
|
{
|
|
|
|
int opcode;
|
|
|
|
hcl_cnode_t* operand;
|
|
|
|
|
|
|
|
union
|
|
|
|
{
|
2021-05-15 05:31:36 +00:00
|
|
|
/* COP_COMPILE_OBJECT_R */
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
hcl_ooi_t nrets;
|
|
|
|
} obj_r;
|
|
|
|
|
2021-01-28 08:17:50 +00:00
|
|
|
/* COP_EMIT_CALL */
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
hcl_ooi_t index;
|
2021-05-15 05:31:36 +00:00
|
|
|
hcl_ooi_t nrets;
|
2021-01-28 08:17:50 +00:00
|
|
|
} call;
|
|
|
|
|
2022-01-22 15:40:38 +00:00
|
|
|
/* COP_EMIT_SEND_MESSAGE */
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
hcl_ooi_t nargs;
|
|
|
|
hcl_ooi_t nrets;
|
2022-02-19 17:26:26 +00:00
|
|
|
int to_super;
|
2022-01-22 15:40:38 +00:00
|
|
|
} sendmsg;
|
|
|
|
|
2021-01-28 08:17:50 +00:00
|
|
|
/* COP_EMIT_SET */
|
2021-01-17 17:45:39 +00:00
|
|
|
struct
|
|
|
|
{
|
2021-11-23 15:52:01 +00:00
|
|
|
int mode; /* VAR_ACCESS_STORE or VAR_ACCESS_POP */
|
2021-11-23 14:42:20 +00:00
|
|
|
hcl_var_info_t vi;
|
2021-01-17 17:45:39 +00:00
|
|
|
} set;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
hcl_ooi_t cond_pos;
|
|
|
|
hcl_ooi_t body_pos;
|
2021-01-28 10:09:38 +00:00
|
|
|
hcl_ooi_t jump_inst_pos;
|
2023-11-04 13:58:31 +00:00
|
|
|
hcl_loc_t start_loc;
|
2021-01-17 17:45:39 +00:00
|
|
|
} post_while;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
hcl_ooi_t body_pos;
|
2021-01-28 08:17:50 +00:00
|
|
|
hcl_ooi_t jump_inst_pos;
|
2023-11-04 13:58:31 +00:00
|
|
|
hcl_loc_t start_loc;
|
2023-11-13 15:31:50 +00:00
|
|
|
hcl_cnode_t* cmd_cnode;
|
2021-01-17 17:45:39 +00:00
|
|
|
} post_if;
|
|
|
|
|
2021-01-28 10:09:38 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
hcl_ooi_t jump_inst_pos;
|
|
|
|
} post_and;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
hcl_ooi_t jump_inst_pos;
|
|
|
|
} post_or;
|
|
|
|
|
2021-04-22 09:35:26 +00:00
|
|
|
/* COP_POST_TRY */
|
2021-02-22 09:20:45 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
hcl_oow_t jump_inst_pos;
|
2021-04-22 09:35:26 +00:00
|
|
|
} post_try;
|
|
|
|
|
|
|
|
/* COP_POST_CATCH */
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
hcl_oow_t jump_inst_pos;
|
|
|
|
hcl_oow_t exarg_offset;
|
|
|
|
} post_catch;
|
2021-02-22 09:20:45 +00:00
|
|
|
|
2022-05-03 14:43:12 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
hcl_oow_t lvar_start;
|
|
|
|
hcl_oow_t lvar_end;
|
|
|
|
} post_do;
|
|
|
|
|
2021-01-28 07:25:05 +00:00
|
|
|
/* COP_COMPILE_ARRAY_LIST, COP_POP_INTO_ARRAY, COP_EMIT_MAKE_ARRAY */
|
2021-01-17 17:45:39 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
hcl_ooi_t index;
|
|
|
|
} array_list;
|
|
|
|
|
2024-09-15 02:51:11 +00:00
|
|
|
/* COP_COMPILE_PURE_ARRAY_LIST, COP_POP_INTO_PURE_ARRAY, COP_EMIT_MAKE_PURE_ARRAY */
|
2021-01-17 17:45:39 +00:00
|
|
|
struct
|
|
|
|
{
|
2024-02-02 05:57:46 +00:00
|
|
|
int elem_type;
|
2021-01-17 17:45:39 +00:00
|
|
|
hcl_ooi_t index;
|
2024-09-15 02:51:11 +00:00
|
|
|
} pure_array_list;
|
2021-01-17 17:45:39 +00:00
|
|
|
|
2021-01-28 07:25:05 +00:00
|
|
|
/* COP_EMIT_MAKE_DIC */
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
hcl_ooi_t index;
|
|
|
|
} dic_list;
|
|
|
|
|
2024-07-20 10:15:27 +00:00
|
|
|
/* COP_POST_FUN, COP_EMIT_FUN */
|
2021-01-17 17:45:39 +00:00
|
|
|
struct
|
|
|
|
{
|
2024-05-29 14:19:25 +00:00
|
|
|
unsigned int fun_type;
|
2021-01-27 08:47:08 +00:00
|
|
|
hcl_oow_t jump_inst_pos;
|
2021-01-17 17:45:39 +00:00
|
|
|
hcl_ooi_t lfbase_pos;
|
|
|
|
hcl_ooi_t lfsize_pos;
|
2024-03-31 16:24:00 +00:00
|
|
|
hcl_cnode_t* class_name; /* class name for out-of-class method definition */
|
2024-07-20 10:15:27 +00:00
|
|
|
} fun;
|
2021-01-27 08:47:08 +00:00
|
|
|
|
2021-01-27 16:01:36 +00:00
|
|
|
/* COP_EMIT_RETURN */
|
2021-01-27 08:47:08 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
int from_home;
|
|
|
|
} _return;
|
2021-01-29 08:13:18 +00:00
|
|
|
|
2021-02-01 13:20:46 +00:00
|
|
|
/* COP_POST_BREAK */
|
2021-01-29 08:13:18 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
hcl_ooi_t jump_inst_pos;
|
|
|
|
} _break;
|
2021-06-25 15:19:11 +00:00
|
|
|
|
|
|
|
/* COP_COMPILE_CLASS_P1, COP_COMPILE_CLASS_P2 */
|
2023-10-23 09:49:15 +00:00
|
|
|
struct
|
2021-06-25 15:19:11 +00:00
|
|
|
{
|
|
|
|
hcl_ooi_t nsuperclasses;
|
2024-10-04 15:05:52 +00:00
|
|
|
unsigned int indexed_type;
|
2023-11-04 13:58:31 +00:00
|
|
|
hcl_loc_t start_loc;
|
2023-11-14 08:57:20 +00:00
|
|
|
hcl_cnode_t* cmd_cnode;
|
2024-10-11 15:24:02 +00:00
|
|
|
hcl_cnode_t* class_name_cnode;
|
2021-06-25 15:19:11 +00:00
|
|
|
} _class;
|
2021-01-17 17:45:39 +00:00
|
|
|
} u;
|
|
|
|
};
|
2021-01-29 09:41:39 +00:00
|
|
|
typedef struct hcl_cframe_t hcl_cframe_t;
|
2021-01-17 17:45:39 +00:00
|
|
|
|
2024-10-11 15:24:02 +00:00
|
|
|
enum hcl_ctlblk_type_t
|
2021-04-09 01:23:08 +00:00
|
|
|
{
|
2024-10-11 15:24:02 +00:00
|
|
|
HCL_CTLBLK_TYPE_LOOP,
|
|
|
|
HCL_CTLBLK_TYPE_TRY,
|
|
|
|
HCL_CTLBLK_TYPE_CLASS
|
2021-04-09 01:23:08 +00:00
|
|
|
};
|
2024-10-11 15:24:02 +00:00
|
|
|
typedef enum hcl_ctlblk_type_t hcl_ctlblk_type_t;
|
2021-04-09 01:23:08 +00:00
|
|
|
|
2021-06-07 01:11:17 +00:00
|
|
|
/* control block information for the compiler */
|
2024-10-11 15:24:02 +00:00
|
|
|
struct hcl_ctlblk_info_t
|
2021-04-09 01:23:08 +00:00
|
|
|
{
|
2024-10-11 15:24:02 +00:00
|
|
|
hcl_ctlblk_type_t _type;
|
2021-04-09 01:23:08 +00:00
|
|
|
};
|
2024-10-11 15:24:02 +00:00
|
|
|
typedef struct hcl_ctlblk_info_t hcl_ctlblk_info_t;
|
2021-04-09 01:23:08 +00:00
|
|
|
|
2021-06-07 01:11:17 +00:00
|
|
|
/* function block information for the compiler */
|
2024-10-11 15:24:02 +00:00
|
|
|
struct hcl_funblk_info_t
|
2020-09-28 15:44:04 +00:00
|
|
|
{
|
2024-05-29 14:19:25 +00:00
|
|
|
unsigned int fun_type;
|
2022-02-24 16:47:26 +00:00
|
|
|
|
2021-06-02 16:28:34 +00:00
|
|
|
hcl_oow_t tmprlen; /* accumulated length of the temporaries string including outer blocks */
|
|
|
|
hcl_oow_t tmprcnt; /* accumulated number of temporaries including outer blocks */
|
|
|
|
|
|
|
|
hcl_oow_t tmpr_va; /* 0 or 1 */
|
|
|
|
hcl_oow_t tmpr_nargs; /* number of fixed arguments */
|
|
|
|
hcl_oow_t tmpr_nrvars; /* number of return variables */
|
|
|
|
hcl_oow_t tmpr_nlvars; /* number of local variables */
|
|
|
|
|
2021-04-22 09:35:26 +00:00
|
|
|
hcl_oow_t make_inst_pos;
|
2020-10-05 09:37:26 +00:00
|
|
|
hcl_oow_t lfbase;
|
2021-04-09 01:23:08 +00:00
|
|
|
|
2024-10-11 15:24:02 +00:00
|
|
|
hcl_ooi_t ctlblk_base;
|
2021-05-09 15:32:54 +00:00
|
|
|
|
2021-06-18 18:54:50 +00:00
|
|
|
hcl_ooi_t clsblk_base;
|
|
|
|
hcl_ooi_t clsblk_top;
|
|
|
|
|
2021-05-09 15:32:54 +00:00
|
|
|
unsigned int access_outer: 1;
|
|
|
|
unsigned int accessed_by_inner: 1;
|
2020-09-28 15:44:04 +00:00
|
|
|
};
|
2024-10-11 15:24:02 +00:00
|
|
|
typedef struct hcl_funblk_info_t hcl_funblk_info_t;
|
2020-09-28 15:44:04 +00:00
|
|
|
|
2021-06-07 01:11:17 +00:00
|
|
|
/* class block information for the compiler */
|
|
|
|
|
|
|
|
struct hcl_clsblk_info_t
|
|
|
|
{
|
2024-10-11 15:24:02 +00:00
|
|
|
hcl_cnode_t* class_name;
|
|
|
|
|
2024-10-18 17:31:54 +00:00
|
|
|
hcl_oocsc_t ivars;
|
|
|
|
hcl_oocsc_t cvars;
|
|
|
|
|
2021-06-07 01:11:17 +00:00
|
|
|
hcl_oow_t nivars;
|
|
|
|
hcl_oow_t ncvars;
|
2021-06-27 17:47:51 +00:00
|
|
|
hcl_ooch_t* ivars_str;
|
|
|
|
hcl_ooch_t* cvars_str;
|
2021-06-07 01:11:17 +00:00
|
|
|
hcl_oow_t spec; /* TODO: byte indexed, word indexed? */
|
|
|
|
|
2024-10-11 15:24:02 +00:00
|
|
|
hcl_ooi_t funblk_base;
|
2021-12-24 00:05:58 +00:00
|
|
|
hcl_ooi_t class_start_inst_pos; /* the position of the first instruction in the class body after CLASS_ENTER */
|
2024-10-18 17:31:54 +00:00
|
|
|
hcl_ooi_t class_enter_inst_pos; /* the position of the CLASS_ENTER instruction */
|
2021-06-07 01:11:17 +00:00
|
|
|
};
|
|
|
|
typedef struct hcl_clsblk_info_t hcl_clsblk_info_t;
|
|
|
|
|
|
|
|
|
|
|
|
/* reader stack for list reading */
|
2021-01-13 09:54:44 +00:00
|
|
|
typedef struct hcl_rstl_t hcl_rstl_t;
|
2023-10-23 09:49:15 +00:00
|
|
|
struct hcl_rstl_t
|
2021-01-13 09:54:44 +00:00
|
|
|
{
|
|
|
|
hcl_cnode_t* head;
|
|
|
|
hcl_cnode_t* tail;
|
2023-11-04 13:58:31 +00:00
|
|
|
hcl_loc_t loc;
|
2021-01-13 09:54:44 +00:00
|
|
|
int flagv;
|
|
|
|
hcl_oow_t count;
|
|
|
|
hcl_rstl_t* prev;
|
|
|
|
};
|
|
|
|
|
2022-07-22 08:02:14 +00:00
|
|
|
typedef struct hcl_flx_dt_t hcl_flx_dt_t; /* delemiter token */
|
|
|
|
struct hcl_flx_dt_t
|
2022-05-25 14:23:43 +00:00
|
|
|
{
|
|
|
|
int row_start;
|
|
|
|
int row_end;
|
|
|
|
int col_next;
|
|
|
|
};
|
|
|
|
|
2024-09-04 16:12:20 +00:00
|
|
|
typedef struct hcl_flx_di_t hcl_flx_di_t; /* dollared-signed identifier */
|
|
|
|
struct hcl_flx_di_t
|
|
|
|
{
|
|
|
|
/* state data */
|
|
|
|
hcl_oow_t char_count;
|
|
|
|
};
|
2022-07-23 06:57:01 +00:00
|
|
|
|
|
|
|
typedef struct hcl_flx_hc_t hcl_flx_hc_t; /* hash-marked character like #\, #\newline */
|
|
|
|
struct hcl_flx_hc_t
|
|
|
|
{
|
|
|
|
/* state data */
|
|
|
|
hcl_oow_t char_count;
|
|
|
|
};
|
|
|
|
|
2022-07-23 10:09:36 +00:00
|
|
|
typedef struct hcl_flx_hi_t hcl_flx_hi_t; /* hash-marked identifier */
|
|
|
|
struct hcl_flx_hi_t
|
|
|
|
{
|
|
|
|
/* state data */
|
|
|
|
hcl_oow_t char_count;
|
|
|
|
};
|
|
|
|
|
2024-09-20 15:51:19 +00:00
|
|
|
typedef struct hcl_flx_hbc_t hcl_flx_hbc_t; /* intermediate state for #b */
|
|
|
|
struct hcl_flx_hbc_t
|
2024-01-27 10:10:56 +00:00
|
|
|
{
|
|
|
|
/* state data */
|
2024-02-02 05:57:46 +00:00
|
|
|
hcl_ooch_t start_c;
|
2024-01-27 10:10:56 +00:00
|
|
|
};
|
|
|
|
|
2022-07-26 00:06:29 +00:00
|
|
|
typedef struct hcl_flx_pi_t hcl_flx_pi_t;
|
|
|
|
struct hcl_flx_pi_t
|
|
|
|
{
|
|
|
|
/* state data */
|
|
|
|
hcl_oow_t char_count;
|
|
|
|
hcl_oow_t seg_count;
|
|
|
|
hcl_oow_t seg_len;
|
|
|
|
hcl_oow_t non_ident_seg_count;
|
2023-11-04 13:58:31 +00:00
|
|
|
hcl_tok_type_t last_non_ident_type;
|
2023-12-01 18:35:59 +00:00
|
|
|
int is_cla; /* class-level accrssor. prefixed with self/super */
|
2022-07-26 00:06:29 +00:00
|
|
|
};
|
|
|
|
|
2024-02-04 12:35:31 +00:00
|
|
|
typedef struct hcl_flx_binop_t hcl_flx_binop_t;
|
|
|
|
struct hcl_flx_binop_t
|
|
|
|
{
|
|
|
|
hcl_oow_t _not_used;
|
|
|
|
};
|
|
|
|
|
2022-07-26 00:06:29 +00:00
|
|
|
typedef struct hcl_flx_pn_t hcl_flx_pn_t;
|
|
|
|
struct hcl_flx_pn_t
|
|
|
|
{
|
|
|
|
/* state data */
|
|
|
|
int fpdec;
|
2024-09-21 17:33:01 +00:00
|
|
|
int radix;
|
2024-09-24 10:41:42 +00:00
|
|
|
int radix_cand_overflown;
|
|
|
|
hcl_oow_t radix_cand;
|
|
|
|
hcl_tok_type_t tok_type;
|
2022-07-26 00:06:29 +00:00
|
|
|
hcl_oow_t digit_count[2];
|
2024-09-21 17:33:01 +00:00
|
|
|
hcl_ooch_t start_digit;
|
2022-07-26 00:06:29 +00:00
|
|
|
};
|
|
|
|
|
2022-07-22 08:02:14 +00:00
|
|
|
typedef struct hcl_flx_qt_t hcl_flx_qt_t; /* quoted token */
|
|
|
|
struct hcl_flx_qt_t
|
2022-05-25 14:23:43 +00:00
|
|
|
{
|
2022-07-22 08:02:14 +00:00
|
|
|
/* input data */
|
2023-11-04 13:58:31 +00:00
|
|
|
hcl_tok_type_t tok_type;
|
2022-07-23 06:57:01 +00:00
|
|
|
hcl_synerrnum_t synerr_code;
|
2022-07-22 08:02:14 +00:00
|
|
|
hcl_ooch_t end_char;
|
|
|
|
hcl_ooch_t esc_char;
|
|
|
|
hcl_oow_t min_len;
|
|
|
|
hcl_oow_t max_len;
|
2024-01-24 09:38:33 +00:00
|
|
|
unsigned int is_byte: 1;
|
|
|
|
unsigned int regex: 1;
|
2022-07-22 08:02:14 +00:00
|
|
|
|
|
|
|
/* state data */
|
2024-01-24 09:38:33 +00:00
|
|
|
unsigned int escaped: 4; /* must be large enough to hold 1, 2, 4, 8 */
|
2022-07-22 08:02:14 +00:00
|
|
|
int digit_count;
|
|
|
|
hcl_ooci_t c_acc;
|
2022-05-25 14:23:43 +00:00
|
|
|
};
|
2022-07-22 08:02:14 +00:00
|
|
|
|
2022-07-26 00:06:29 +00:00
|
|
|
typedef struct hcl_flx_st_t hcl_flx_st_t;
|
|
|
|
struct hcl_flx_st_t
|
|
|
|
{
|
|
|
|
/* input data */
|
|
|
|
hcl_ooch_t sign_c;
|
|
|
|
|
|
|
|
/* state data */
|
|
|
|
hcl_oow_t char_count;
|
|
|
|
int hmarked;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2024-02-02 05:57:46 +00:00
|
|
|
typedef struct hcl_flx_bcp_t hcl_flx_bcp_t;
|
|
|
|
struct hcl_flx_bcp_t
|
2024-01-24 07:26:30 +00:00
|
|
|
{
|
|
|
|
hcl_ooch_t start_c;
|
|
|
|
};
|
|
|
|
|
2022-07-22 08:02:14 +00:00
|
|
|
enum hcl_flx_state_t
|
|
|
|
{
|
|
|
|
HCL_FLX_START,
|
2024-01-18 14:55:50 +00:00
|
|
|
HCL_FLX_BACKSLASHED,
|
2022-07-22 08:02:14 +00:00
|
|
|
HCL_FLX_COMMENT,
|
2022-07-23 06:57:01 +00:00
|
|
|
HCL_FLX_DELIM_TOKEN,
|
2024-09-04 16:12:20 +00:00
|
|
|
HCL_FLX_DOLLARED_IDENT,
|
2022-07-26 00:06:29 +00:00
|
|
|
HCL_FLX_HMARKED_TOKEN, /* hash-marked token */
|
2024-09-20 15:51:19 +00:00
|
|
|
HCL_FLX_HMARKED_BC, /* #b - intermediate state before #b[, #c[, or #b-radixed binary number */
|
2024-09-16 02:12:11 +00:00
|
|
|
HCL_FLX_HMARKED_BINOP, /* #++ - binary operator symbol */
|
2022-07-26 00:06:29 +00:00
|
|
|
HCL_FLX_HMARKED_CHAR, /* hash-marked character that begins with #\ */
|
2024-09-20 15:51:19 +00:00
|
|
|
HCL_FLX_HMARKED_IDENT, /* literal symbol */
|
2022-07-26 00:06:29 +00:00
|
|
|
HCL_FLX_PLAIN_IDENT, /* plain identifier */
|
2024-02-04 12:35:31 +00:00
|
|
|
HCL_FLX_BINOP, /* binary operator */
|
2022-07-26 00:06:29 +00:00
|
|
|
HCL_FLX_PLAIN_NUMBER, /* plain number */
|
|
|
|
HCL_FLX_QUOTED_TOKEN, /* string, character */
|
2024-01-24 07:26:30 +00:00
|
|
|
HCL_FLX_SIGNED_TOKEN, /* prefixed with + or - */
|
2024-02-02 05:57:46 +00:00
|
|
|
HCL_FLX_BC_PREFIX /* b or C prefix before " or ' */
|
2022-07-22 08:02:14 +00:00
|
|
|
};
|
|
|
|
typedef enum hcl_flx_state_t hcl_flx_state_t;
|
2022-05-25 14:23:43 +00:00
|
|
|
|
2022-07-26 15:06:53 +00:00
|
|
|
typedef struct hcl_frd_t hcl_frd_t;
|
|
|
|
struct hcl_frd_t
|
|
|
|
{
|
|
|
|
int level;
|
|
|
|
int flagv;
|
2022-07-28 14:07:18 +00:00
|
|
|
int expect_include_file;
|
2022-07-30 03:02:57 +00:00
|
|
|
int expect_vlist_item;
|
2022-07-28 14:20:28 +00:00
|
|
|
int do_include_file;
|
2022-07-26 15:06:53 +00:00
|
|
|
hcl_cnode_t* obj;
|
2023-11-12 12:54:17 +00:00
|
|
|
hcl_loc_t list_loc;
|
2022-07-26 15:06:53 +00:00
|
|
|
};
|
|
|
|
|
2016-09-28 14:40:37 +00:00
|
|
|
struct hcl_compiler_t
|
|
|
|
{
|
2023-11-09 15:03:03 +00:00
|
|
|
/* flags passed in via hcl_compile() */
|
|
|
|
int flags;
|
|
|
|
|
2023-05-18 01:24:01 +00:00
|
|
|
/* callback pointer registerd upon compiler creation */
|
|
|
|
hcl_cb_t* cbp;
|
2016-09-28 14:40:37 +00:00
|
|
|
|
|
|
|
/* input handler */
|
2023-11-05 13:31:33 +00:00
|
|
|
hcl_io_impl_t cci_rdr;
|
2016-09-28 14:40:37 +00:00
|
|
|
|
|
|
|
/* static input data buffer */
|
2023-11-05 13:31:33 +00:00
|
|
|
hcl_io_cciarg_t cci_arg;
|
2016-09-28 14:40:37 +00:00
|
|
|
|
|
|
|
/* pointer to the current input data. initially, it points to &inarg */
|
2023-11-05 13:31:33 +00:00
|
|
|
hcl_io_cciarg_t* curinp;
|
2016-09-28 14:40:37 +00:00
|
|
|
|
|
|
|
/* information about the last meaningful character read.
|
|
|
|
* this is a copy of curinp->lxc if no ungetting is performed.
|
|
|
|
* if there is something in the unget buffer, this is overwritten
|
|
|
|
* by a value from the buffer when the request to read a character
|
|
|
|
* is served */
|
2023-11-04 13:58:31 +00:00
|
|
|
hcl_lxc_t lxc;
|
2016-09-28 14:40:37 +00:00
|
|
|
|
|
|
|
/* unget buffer */
|
2023-11-04 13:58:31 +00:00
|
|
|
hcl_lxc_t ungot[10];
|
2023-11-04 14:13:52 +00:00
|
|
|
int nungots;
|
2016-09-28 14:40:37 +00:00
|
|
|
|
|
|
|
/* the last token read */
|
2023-11-04 14:13:52 +00:00
|
|
|
hcl_tok_t tok;
|
2023-11-04 13:58:31 +00:00
|
|
|
hcl_link_t* sr_names;
|
2016-09-28 14:40:37 +00:00
|
|
|
|
|
|
|
hcl_synerr_t synerr;
|
|
|
|
|
|
|
|
/* temporary space to handle an illegal character */
|
|
|
|
hcl_ooch_t ilchr;
|
|
|
|
hcl_oocs_t ilchr_ucs;
|
|
|
|
|
|
|
|
/* == READER == */
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
hcl_oop_t s; /* stack for reading */
|
|
|
|
hcl_oop_t e; /* last object read */
|
2021-01-13 09:54:44 +00:00
|
|
|
hcl_rstl_t* st;
|
2016-09-28 14:40:37 +00:00
|
|
|
} r; /* reading */
|
|
|
|
/* == END READER == */
|
|
|
|
|
2022-05-25 14:23:43 +00:00
|
|
|
struct
|
|
|
|
{
|
2023-11-03 09:04:46 +00:00
|
|
|
#if defined(HCL_OOCH_IS_UCH)
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
hcl_bch_t buf[HCL_BCSIZE_MAX];
|
|
|
|
hcl_oow_t len;
|
|
|
|
int no_check;
|
|
|
|
} rsd; /* residue - incomplete sequence at the end of the last data fed by hcl_feedbchars() */
|
|
|
|
#endif
|
|
|
|
|
2022-05-25 14:23:43 +00:00
|
|
|
struct
|
|
|
|
{
|
2022-07-22 08:02:14 +00:00
|
|
|
hcl_flx_state_t state;
|
2023-11-04 13:58:31 +00:00
|
|
|
hcl_loc_t loc;
|
|
|
|
hcl_loc_t _oloc;
|
2022-07-22 08:02:14 +00:00
|
|
|
|
2023-10-23 09:49:15 +00:00
|
|
|
union
|
2022-07-22 08:02:14 +00:00
|
|
|
{
|
|
|
|
hcl_flx_dt_t dt; /* delimiter token */
|
2024-09-04 16:12:20 +00:00
|
|
|
hcl_flx_di_t di; /* dollar-signed identifier */
|
2022-07-23 06:57:01 +00:00
|
|
|
hcl_flx_hc_t hc; /* hash-marked character */
|
2024-09-20 15:51:19 +00:00
|
|
|
hcl_flx_hi_t hi; /* hash-marked identifier - literal symbol */
|
|
|
|
hcl_flx_hbc_t hbc; /* #b #c ... */
|
2022-07-26 00:06:29 +00:00
|
|
|
hcl_flx_pi_t pi; /* plain identifier */
|
2024-02-04 12:35:31 +00:00
|
|
|
hcl_flx_binop_t binop; /* binary operator */
|
2022-07-26 00:06:29 +00:00
|
|
|
hcl_flx_pn_t pn; /* plain number */
|
2022-07-22 08:02:14 +00:00
|
|
|
hcl_flx_qt_t qt; /* quoted token */
|
2022-07-26 00:06:29 +00:00
|
|
|
hcl_flx_st_t st; /* signed token */
|
2024-02-02 05:57:46 +00:00
|
|
|
hcl_flx_bcp_t bcp; /* b or c prefix */
|
2022-07-22 08:02:14 +00:00
|
|
|
} u;
|
2022-05-25 14:23:43 +00:00
|
|
|
} lx;
|
|
|
|
|
2022-07-26 15:06:53 +00:00
|
|
|
struct hcl_frd_t rd;
|
2022-07-29 11:29:47 +00:00
|
|
|
hcl_on_cnode_t on_cnode;
|
2022-05-25 14:23:43 +00:00
|
|
|
} feed;
|
|
|
|
|
2016-09-28 14:40:37 +00:00
|
|
|
/* == COMPILER STACK == */
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
hcl_cframe_t* ptr;
|
|
|
|
hcl_ooi_t top;
|
|
|
|
hcl_oow_t capa;
|
|
|
|
} cfs;
|
|
|
|
/* == END COMPILER STACK == */
|
2016-09-29 13:20:09 +00:00
|
|
|
|
2021-01-21 14:59:01 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
hcl_oocs_t s; /* buffer */
|
|
|
|
hcl_oow_t capa; /* bufer capacity */
|
|
|
|
hcl_oow_t wcount; /* word count */
|
2021-02-01 13:20:46 +00:00
|
|
|
} tv; /* temporary variables including arguments */
|
2021-01-17 17:45:39 +00:00
|
|
|
|
2016-09-29 13:20:09 +00:00
|
|
|
struct
|
|
|
|
{
|
2021-04-09 01:23:08 +00:00
|
|
|
hcl_ooi_t depth; /* signed because it starts with -1 */
|
2024-10-11 15:24:02 +00:00
|
|
|
hcl_ctlblk_info_t* info;
|
2021-04-09 01:23:08 +00:00
|
|
|
hcl_oow_t info_capa;
|
2024-10-11 15:24:02 +00:00
|
|
|
} ctlblk; /* control block - loop, try-catch */
|
2021-04-09 01:23:08 +00:00
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
hcl_ooi_t depth; /* signed because it starts with -1 */
|
2024-10-11 15:24:02 +00:00
|
|
|
hcl_funblk_info_t* info;
|
2020-09-28 15:44:04 +00:00
|
|
|
hcl_oow_t info_capa;
|
2024-10-11 15:24:02 +00:00
|
|
|
} funblk; /* function block */
|
2021-06-07 01:11:17 +00:00
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
hcl_ooi_t depth; /* signed because it starts with -1 */
|
|
|
|
hcl_clsblk_info_t* info;
|
|
|
|
hcl_oow_t info_capa;
|
|
|
|
} clsblk; /* class block */
|
2023-11-12 12:54:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
hcl_cnode_t cons_to_nil;
|
|
|
|
hcl_cnode_t nil;
|
|
|
|
} fake_cnode;
|
2016-09-28 14:40:37 +00:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2021-05-04 09:48:19 +00:00
|
|
|
|
2024-05-31 06:16:31 +00:00
|
|
|
/* hcl_context_t, hcl_block_t, hcl_function_t stores the local variable information
|
2023-10-23 09:49:15 +00:00
|
|
|
*
|
2021-05-04 09:48:19 +00:00
|
|
|
* Use up to 29 bits in a 32-bit hcl_ooi_t. Exclude the tag bit and the sign bit.
|
2022-03-19 07:32:51 +00:00
|
|
|
* | SIGN | INSTA | VA | NARGS | NRVARS | NLVARS | TAG |
|
|
|
|
* 1 1 8 8 11 2 <= 32
|
2021-05-04 09:48:19 +00:00
|
|
|
* -----------------------------------------------------------
|
2024-05-31 06:16:31 +00:00
|
|
|
* Parameters to the MAKE_BLOCK or MAKE_FUNCTION instructions
|
2023-10-23 09:49:15 +00:00
|
|
|
* | INSTA | VA | NARGS | NRVARS | NLVARS
|
2022-03-19 07:32:51 +00:00
|
|
|
* 1 1 4 4 6 <= 16 (HCL_CODE_LONG_PARAM_SIZE 1, two params)
|
|
|
|
* 1 1 8 8 11 <= 32 (HCL_CODE_LONG_PARAM_SIZE 2, two params, use 29 bits to avoid collection when converted to a smooi)
|
2021-05-11 15:04:53 +00:00
|
|
|
*
|
2024-05-26 14:18:26 +00:00
|
|
|
* INSTA indicates the class instantiation method.
|
2021-05-11 15:04:53 +00:00
|
|
|
* NARGS and NRVARS are also used for the CALL and CALL2 instructions.
|
|
|
|
* CALL encodes NARGS in one parameter.
|
|
|
|
* CALLR encodes NARGS in one parameter and NRVARS in another parameter.
|
2023-10-23 09:49:15 +00:00
|
|
|
* NARGS and NRVARS must not exceed a single parameter size.
|
2021-05-04 09:48:19 +00:00
|
|
|
*/
|
2023-10-23 09:49:15 +00:00
|
|
|
|
2021-01-29 12:39:31 +00:00
|
|
|
#if defined(HCL_CODE_LONG_PARAM_SIZE) && (HCL_CODE_LONG_PARAM_SIZE == 1)
|
2021-05-11 15:04:53 +00:00
|
|
|
|
2022-03-17 13:22:17 +00:00
|
|
|
# define MAX_CODE_NBLKARGS (0xFu) /* 15 - 4 bits*/
|
|
|
|
# define MAX_CODE_NBLKRVARS (0xFu) /* 15 - 4 bits*/
|
|
|
|
# define MAX_CODE_NBLKLVARS (0x3Fu) /* 63 - 6 bits */
|
|
|
|
|
|
|
|
# define ENCODE_BLK_MASK(insta,va,nargs,nrvars,nlvars) \
|
|
|
|
((((insta) & 0x1) << 15) | (((va) & 0x1) << 14) | (((nargs) & 0xF) << 10) | (((nrvars) & 0xF) << 6) | (((nlvars) & 0x3FF)))
|
|
|
|
# define GET_BLK_MASK_INSTA(x) (((x) >> 15) & 0x1)
|
|
|
|
# define GET_BLK_MASK_VA(x) (((x) >> 14) & 0x1)
|
|
|
|
# define GET_BLK_MASK_NARGS(x) (((x) >> 10) & 0xF)
|
|
|
|
# define GET_BLK_MASK_NRVARS(x) (((x) >> 6) & 0xF)
|
|
|
|
# define GET_BLK_MASK_NLVARS(x) ((x) & 0x3F)
|
2021-05-04 09:48:19 +00:00
|
|
|
|
2016-09-28 14:40:37 +00:00
|
|
|
# define MAX_CODE_JUMP (0xFFu)
|
|
|
|
# define MAX_CODE_PARAM (0xFFu)
|
2022-03-17 13:22:17 +00:00
|
|
|
# define MAX_CODE_PARAM2 (0xFFFFu) /* 16 bits */
|
2021-01-29 12:39:31 +00:00
|
|
|
#elif defined(HCL_CODE_LONG_PARAM_SIZE) && (HCL_CODE_LONG_PARAM_SIZE == 2)
|
2021-05-11 15:04:53 +00:00
|
|
|
|
2022-03-17 13:22:17 +00:00
|
|
|
# define MAX_CODE_NBLKARGS (0xFFu) /* 255, 8 bits */
|
|
|
|
# define MAX_CODE_NBLKRVARS (0xFFu) /* 255, 8 bits */
|
2022-03-19 07:32:51 +00:00
|
|
|
# define MAX_CODE_NBLKLVARS (0x7FFu) /* 2047, 11 bits */
|
2022-03-17 13:22:17 +00:00
|
|
|
# define ENCODE_BLK_MASK(insta,va,nargs,nrvars,nlvars) \
|
2022-03-19 07:32:51 +00:00
|
|
|
((((insta) & 0x1) << 28) | (((va) & 0x1) << 27) | (((nargs) & 0xFF) << 19) | (((nrvars) & 0xFF) << 11) | (((nlvars) & 0x7FF)))
|
|
|
|
# define GET_BLK_MASK_INSTA(x) (((x) >> 28) & 0x1)
|
|
|
|
# define GET_BLK_MASK_VA(x) (((x) >> 27) & 0x1)
|
|
|
|
# define GET_BLK_MASK_NARGS(x) (((x) >> 19) & 0xFF)
|
|
|
|
# define GET_BLK_MASK_NRVARS(x) (((x) >> 11) & 0xFF)
|
|
|
|
# define GET_BLK_MASK_NLVARS(x) ((x) & 0x7FF)
|
2023-10-23 09:49:15 +00:00
|
|
|
|
2016-09-28 14:40:37 +00:00
|
|
|
# define MAX_CODE_JUMP (0xFFFFu)
|
|
|
|
# define MAX_CODE_PARAM (0xFFFFu)
|
2022-03-17 13:22:17 +00:00
|
|
|
# define MAX_CODE_PARAM2 (0xFFFFFFFFu) /* 32 bits */
|
2016-09-28 14:40:37 +00:00
|
|
|
#else
|
2021-01-29 12:39:31 +00:00
|
|
|
# error Unsupported HCL_CODE_LONG_PARAM_SIZE
|
2016-09-28 14:40:37 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2021-05-04 09:48:19 +00:00
|
|
|
|
2016-09-28 14:40:37 +00:00
|
|
|
/*
|
|
|
|
----------------------------------------------------------------------------------------------------------------
|
|
|
|
SHORT INSTRUCTION CODE LONG INSTRUCTION CODE
|
|
|
|
----------------------------------------------------------------------------------------------------------------
|
|
|
|
v v
|
2022-02-17 12:40:22 +00:00
|
|
|
0-3 0000 00XX STORE_INTO_INSTVAR 128 1000 0000 XXXXXXXX STORE_INTO_IVAR_X (bit 4 off, bit 3 off)
|
2016-09-28 14:40:37 +00:00
|
|
|
4-7 0000 01XX STORE_INTO_INSTVAR
|
2022-02-17 12:40:22 +00:00
|
|
|
8-11 0000 10XX POP_INTO_INSTVAR 136 1000 1000 XXXXXXXX POP_INTO_IVAR_X (bit 4 off, bit 3 on)
|
2016-09-28 14:40:37 +00:00
|
|
|
12-15 0000 11XX POP_INTO_INSTVAR
|
2022-02-17 12:40:22 +00:00
|
|
|
16-19 0001 00XX PUSH_INSTVAR 144 1001 0000 XXXXXXXX PUSH_IVAR_X (bit 4 on)
|
2016-09-28 14:40:37 +00:00
|
|
|
20-23 0001 01XX PUSH_INSTVAR
|
|
|
|
|
|
|
|
v v
|
|
|
|
24-27 0001 10XX PUSH_TEMPVAR 152 1001 1000 XXXXXXXX PUSH_TEMPVAR_X (bit 4 on)
|
|
|
|
28-31 0001 11XX PUSH_TEMPVAR
|
|
|
|
32-35 0010 00XX STORE_INTO_TEMPVAR 160 1010 0000 XXXXXXXX STORE_INTO_TEMPVAR_X (bit 4 off, bit 3 off)
|
|
|
|
36-39 0010 01XX STORE_INTO_TEMPVAR
|
|
|
|
40-43 0010 10XX POP_INTO_TEMPVAR 168 1010 1000 XXXXXXXX POP_INTO_TEMPVAR_X (bit 4 off, bit 3 on)
|
|
|
|
44-47 0010 11XX POP_INTO_TEMPVAR
|
|
|
|
|
|
|
|
48-51 0011 00XX PUSH_LITERAL 176 1011 0000 XXXXXXXX PUSH_LITERAL_X
|
|
|
|
52-55 0011 01XX PUSH_LITERAL 177 1011 0001 XXXXXXXX XXXXXXXX PUSH_LITERAL_X2
|
|
|
|
|
|
|
|
vv
|
|
|
|
56-59 0011 10XX STORE_INTO_OBJECT 184 1011 1000 XXXXXXXX STORE_INTO_OBJECT (bit 3 on, bit 2 off)
|
|
|
|
60-63 0011 11XX POP_INTO_OBJECT 188 1011 1100 XXXXXXXX POP_INTO_OBJECT (bit 3 on, bit 2 on)
|
|
|
|
64-67 0100 00XX PUSH_OBJECT 192 1100 0000 XXXXXXXX PUSH_OBJECT (bit 3 off)
|
|
|
|
|
|
|
|
|
|
|
|
68-71 0100 01XX JUMP_FORWARD 196 1100 0100 XXXXXXXX JUMP_FORWARD_X
|
2016-10-15 08:49:27 +00:00
|
|
|
197 1100 0101 XXXXXXXX JUMP2_FORWARD
|
2016-09-28 14:40:37 +00:00
|
|
|
72-75 0100 10XX JUMP_BACKWARD 200 1100 1000 XXXXXXXX JUMP_BACKWARD_X
|
2016-10-15 08:49:27 +00:00
|
|
|
201 1100 1001 XXXXXXXX JUMP2_BACKWARD
|
2016-10-12 07:30:54 +00:00
|
|
|
76-79 0100 11XX UNUSED 204 1100 1100 XXXXXXXX JUMP_FORWARD_IF_TRUE
|
|
|
|
205 1100 1101 XXXXXXXX JUMP2_FORWARD_IF_TRUE
|
2021-01-24 15:45:28 +00:00
|
|
|
206 1100 1110 XXXXXXXX JUMP_BACKWARD_IF_TRUE
|
|
|
|
207 1100 1111 XXXXXXXX JUMP2_BACKWARD_IF_TRUE
|
2016-10-12 07:30:54 +00:00
|
|
|
80-83 0101 00XX UNUSED 208 1101 0000 XXXXXXXX JUMP_FORWARD_IF_FALSE
|
|
|
|
209 1101 0001 XXXXXXXX JUMP2_FORWARD_IF_FALSE
|
2021-01-24 15:45:28 +00:00
|
|
|
210 1101 0010 XXXXXXXX JUMP_BACKWARD_IF_FALSE
|
|
|
|
211 1101 0011 XXXXXXXX JUMP2_BACKWARD_IF_FALSE
|
2016-09-28 14:40:37 +00:00
|
|
|
|
|
|
|
84-87 0101 01XX CALL 212 1101 0100 XXXXXXXX CALL_X
|
|
|
|
|
|
|
|
vv
|
|
|
|
88-91 0101 10XX YYYYYYYY STORE_INTO_CTXTEMPVAR 216 1101 1000 XXXXXXXX YYYYYYYY STORE_INTO_CTXTEMPVAR_X (bit 3 on, bit 2 off)
|
|
|
|
92-95 0101 11XX YYYYYYYY POP_INTO_CTXTEMPVAR 220 1101 1100 XXXXXXXX YYYYYYYY POP_INTO_CTXTEMPVAR_X (bit 3 on, bit 2 on)
|
|
|
|
96-99 0110 00XX YYYYYYYY PUSH_CTXTEMPVAR 224 1110 0000 XXXXXXXX YYYYYYYY PUSH_CTXTEMPVAR_X (bit 3 off)
|
|
|
|
# XXXth outer-frame, YYYYYYYY local variable
|
|
|
|
|
|
|
|
100-103 0110 01XX YYYYYYYY PUSH_OBJVAR 228 1110 0100 XXXXXXXX YYYYYYYY PUSH_OBJVAR_X (bit 3 off)
|
|
|
|
104-107 0110 10XX YYYYYYYY STORE_INTO_OBJVAR 232 1110 1000 XXXXXXXX YYYYYYYY STORE_INTO_OBJVAR_X (bit 3 on, bit 2 off)
|
|
|
|
108-111 0110 11XX YYYYYYYY POP_INTO_OBJVAR 236 1110 1100 XXXXXXXX YYYYYYYY POP_INTO_OBJVAR_X (bit 3 on, bit 2 on)
|
|
|
|
# XXXth instance variable of YYYYYYYY object
|
|
|
|
|
|
|
|
v
|
2022-01-23 16:46:13 +00:00
|
|
|
112-115 0111 00XX YYYYYYYY SEND_MESSAGE 240 1111 0000 XXXXXXXX YYYYYYYY SEND_X (bit 2 off)
|
|
|
|
116-119 0111 01XX YYYYYYYY SEND_TO_SUPER 244 1111 0100 XXXXXXXX YYYYYYYY SEND_TO_SUPER_X (bit 2 on)
|
2016-09-28 14:40:37 +00:00
|
|
|
# XXX args, YYYYYYYY message
|
|
|
|
|
2022-02-17 12:40:22 +00:00
|
|
|
120 0111 1000 YYYYYYYY PUSH_CVAR_I_X
|
|
|
|
121 0111 1001 YYYYYYYY STORE_INTO_CVAR_I_X
|
|
|
|
122 0111 1010 YYYYYYYY POP_INTO_CVAR_I_X
|
2022-01-01 14:58:57 +00:00
|
|
|
|
2022-02-17 12:40:22 +00:00
|
|
|
123 0111 1011 YYYYYYYY PUSH_CVAR_M_X
|
|
|
|
124 0111 1100 YYYYYYYY STORE_INTO_CVAR_M_X
|
|
|
|
125 0111 1101 YYYYYYYY POP_INTO_CVAR_M_X
|
2022-01-09 16:47:38 +00:00
|
|
|
|
|
|
|
126 0111 1110 UNUSED
|
|
|
|
127 0111 1111 UNUSED
|
2016-09-28 14:40:37 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
## "SHORT_CODE_0 | 0x80" becomes "LONG_CODE_X".
|
|
|
|
## A special single byte instruction is assigned an unused number greater than 128.
|
|
|
|
##
|
|
|
|
*/
|
|
|
|
|
|
|
|
enum hcl_bcode_t
|
|
|
|
{
|
2022-02-17 12:40:22 +00:00
|
|
|
HCL_CODE_STORE_INTO_IVAR_0 = 0x00,
|
|
|
|
HCL_CODE_STORE_INTO_IVAR_1 = 0x01,
|
|
|
|
HCL_CODE_STORE_INTO_IVAR_2 = 0x02,
|
|
|
|
HCL_CODE_STORE_INTO_IVAR_3 = 0x03,
|
|
|
|
|
|
|
|
HCL_CODE_STORE_INTO_IVAR_4 = 0x04,
|
|
|
|
HCL_CODE_STORE_INTO_IVAR_5 = 0x05,
|
|
|
|
HCL_CODE_STORE_INTO_IVAR_6 = 0x06,
|
|
|
|
HCL_CODE_STORE_INTO_IVAR_7 = 0x07,
|
|
|
|
|
|
|
|
HCL_CODE_POP_INTO_IVAR_0 = 0x08,
|
|
|
|
HCL_CODE_POP_INTO_IVAR_1 = 0x09,
|
|
|
|
HCL_CODE_POP_INTO_IVAR_2 = 0x0A,
|
|
|
|
HCL_CODE_POP_INTO_IVAR_3 = 0x0B,
|
|
|
|
|
|
|
|
HCL_CODE_POP_INTO_IVAR_4 = 0x0C,
|
|
|
|
HCL_CODE_POP_INTO_IVAR_5 = 0x0D,
|
|
|
|
HCL_CODE_POP_INTO_IVAR_6 = 0x0E,
|
|
|
|
HCL_CODE_POP_INTO_IVAR_7 = 0x0F,
|
|
|
|
|
|
|
|
HCL_CODE_PUSH_IVAR_0 = 0x10,
|
|
|
|
HCL_CODE_PUSH_IVAR_1 = 0x11,
|
|
|
|
HCL_CODE_PUSH_IVAR_2 = 0x12,
|
|
|
|
HCL_CODE_PUSH_IVAR_3 = 0x13,
|
|
|
|
|
|
|
|
HCL_CODE_PUSH_IVAR_4 = 0x14,
|
|
|
|
HCL_CODE_PUSH_IVAR_5 = 0x15,
|
|
|
|
HCL_CODE_PUSH_IVAR_6 = 0x16,
|
|
|
|
HCL_CODE_PUSH_IVAR_7 = 0x17,
|
2020-09-22 09:19:53 +00:00
|
|
|
|
|
|
|
HCL_CODE_PUSH_TEMPVAR_0 = 0x18,
|
|
|
|
HCL_CODE_PUSH_TEMPVAR_1 = 0x19,
|
|
|
|
HCL_CODE_PUSH_TEMPVAR_2 = 0x1A,
|
|
|
|
HCL_CODE_PUSH_TEMPVAR_3 = 0x1B,
|
|
|
|
|
|
|
|
HCL_CODE_PUSH_TEMPVAR_4 = 0x1C,
|
|
|
|
HCL_CODE_PUSH_TEMPVAR_5 = 0x1D,
|
|
|
|
HCL_CODE_PUSH_TEMPVAR_6 = 0x1E,
|
|
|
|
HCL_CODE_PUSH_TEMPVAR_7 = 0x1F,
|
|
|
|
|
|
|
|
HCL_CODE_STORE_INTO_TEMPVAR_0 = 0x20,
|
|
|
|
HCL_CODE_STORE_INTO_TEMPVAR_1 = 0x21,
|
|
|
|
HCL_CODE_STORE_INTO_TEMPVAR_2 = 0x22,
|
|
|
|
HCL_CODE_STORE_INTO_TEMPVAR_3 = 0x23,
|
|
|
|
|
|
|
|
HCL_CODE_STORE_INTO_TEMPVAR_4 = 0x24,
|
|
|
|
HCL_CODE_STORE_INTO_TEMPVAR_5 = 0x25,
|
|
|
|
HCL_CODE_STORE_INTO_TEMPVAR_6 = 0x26,
|
|
|
|
HCL_CODE_STORE_INTO_TEMPVAR_7 = 0x27,
|
|
|
|
|
|
|
|
HCL_CODE_POP_INTO_TEMPVAR_0 = 0x28,
|
|
|
|
HCL_CODE_POP_INTO_TEMPVAR_1 = 0x29,
|
|
|
|
HCL_CODE_POP_INTO_TEMPVAR_2 = 0x2A,
|
|
|
|
HCL_CODE_POP_INTO_TEMPVAR_3 = 0x2B,
|
|
|
|
|
|
|
|
HCL_CODE_POP_INTO_TEMPVAR_4 = 0x2C,
|
|
|
|
HCL_CODE_POP_INTO_TEMPVAR_5 = 0x2D,
|
|
|
|
HCL_CODE_POP_INTO_TEMPVAR_6 = 0x2E,
|
|
|
|
HCL_CODE_POP_INTO_TEMPVAR_7 = 0x2F,
|
|
|
|
|
|
|
|
HCL_CODE_PUSH_LITERAL_0 = 0x30,
|
|
|
|
HCL_CODE_PUSH_LITERAL_1 = 0x31,
|
|
|
|
HCL_CODE_PUSH_LITERAL_2 = 0x32,
|
|
|
|
HCL_CODE_PUSH_LITERAL_3 = 0x33,
|
|
|
|
|
|
|
|
HCL_CODE_PUSH_LITERAL_4 = 0x34,
|
|
|
|
HCL_CODE_PUSH_LITERAL_5 = 0x35,
|
|
|
|
HCL_CODE_PUSH_LITERAL_6 = 0x36,
|
|
|
|
HCL_CODE_PUSH_LITERAL_7 = 0x37,
|
2016-09-28 14:40:37 +00:00
|
|
|
|
|
|
|
/* -------------------------------------- */
|
|
|
|
|
|
|
|
HCL_CODE_STORE_INTO_OBJECT_0 = 0x38,
|
|
|
|
HCL_CODE_STORE_INTO_OBJECT_1 = 0x39,
|
|
|
|
HCL_CODE_STORE_INTO_OBJECT_2 = 0x3A,
|
|
|
|
HCL_CODE_STORE_INTO_OBJECT_3 = 0x3B,
|
|
|
|
|
2020-09-22 09:19:53 +00:00
|
|
|
HCL_CODE_POP_INTO_OBJECT_0 = 0x3C,
|
|
|
|
HCL_CODE_POP_INTO_OBJECT_1 = 0x3D,
|
|
|
|
HCL_CODE_POP_INTO_OBJECT_2 = 0x3E,
|
|
|
|
HCL_CODE_POP_INTO_OBJECT_3 = 0x3F,
|
2016-10-10 11:36:24 +00:00
|
|
|
|
|
|
|
HCL_CODE_PUSH_OBJECT_0 = 0x40,
|
|
|
|
HCL_CODE_PUSH_OBJECT_1 = 0x41,
|
|
|
|
HCL_CODE_PUSH_OBJECT_2 = 0x42,
|
|
|
|
HCL_CODE_PUSH_OBJECT_3 = 0x43,
|
|
|
|
|
|
|
|
HCL_CODE_JUMP_FORWARD_0 = 0x44, /* 68 */
|
|
|
|
HCL_CODE_JUMP_FORWARD_1 = 0x45, /* 69 */
|
|
|
|
HCL_CODE_JUMP_FORWARD_2 = 0x46, /* 70 */
|
|
|
|
HCL_CODE_JUMP_FORWARD_3 = 0x47, /* 71 */
|
|
|
|
|
2016-10-12 07:30:54 +00:00
|
|
|
HCL_CODE_JUMP_BACKWARD_0 = 0x48, /* 72 */
|
|
|
|
HCL_CODE_JUMP_BACKWARD_1 = 0x49, /* 73 */
|
|
|
|
HCL_CODE_JUMP_BACKWARD_2 = 0x4A, /* 74 */
|
|
|
|
HCL_CODE_JUMP_BACKWARD_3 = 0x4B, /* 75 */
|
2016-10-10 11:36:24 +00:00
|
|
|
|
2021-01-24 15:45:28 +00:00
|
|
|
/* UNUSED 0x4C - 0x53 */
|
2018-02-06 13:52:58 +00:00
|
|
|
|
2016-10-10 11:36:24 +00:00
|
|
|
HCL_CODE_CALL_0 = 0x54, /* 84 */
|
|
|
|
HCL_CODE_CALL_1 = 0x55, /* 85 */
|
|
|
|
HCL_CODE_CALL_2 = 0x56, /* 86 */
|
|
|
|
HCL_CODE_CALL_3 = 0x57, /* 87 */
|
2016-09-28 14:40:37 +00:00
|
|
|
|
2016-09-29 13:20:09 +00:00
|
|
|
HCL_CODE_STORE_INTO_CTXTEMPVAR_0 = 0x58, /* 88 */
|
|
|
|
HCL_CODE_STORE_INTO_CTXTEMPVAR_1 = 0x59, /* 89 */
|
|
|
|
HCL_CODE_STORE_INTO_CTXTEMPVAR_2 = 0x5A, /* 90 */
|
|
|
|
HCL_CODE_STORE_INTO_CTXTEMPVAR_3 = 0x5B, /* 91 */
|
2016-09-28 14:40:37 +00:00
|
|
|
|
2020-09-22 09:19:53 +00:00
|
|
|
HCL_CODE_POP_INTO_CTXTEMPVAR_0 = 0x5C, /* 92 */
|
|
|
|
HCL_CODE_POP_INTO_CTXTEMPVAR_1 = 0x5D, /* 93 */
|
|
|
|
HCL_CODE_POP_INTO_CTXTEMPVAR_2 = 0x5E, /* 94 */
|
|
|
|
HCL_CODE_POP_INTO_CTXTEMPVAR_3 = 0x5F, /* 95 */
|
2016-10-10 11:36:24 +00:00
|
|
|
|
|
|
|
HCL_CODE_PUSH_CTXTEMPVAR_0 = 0x60, /* 96 */
|
|
|
|
HCL_CODE_PUSH_CTXTEMPVAR_1 = 0x61, /* 97 */
|
|
|
|
HCL_CODE_PUSH_CTXTEMPVAR_2 = 0x62, /* 98 */
|
|
|
|
HCL_CODE_PUSH_CTXTEMPVAR_3 = 0x63, /* 99 */
|
|
|
|
|
2020-09-22 09:19:53 +00:00
|
|
|
HCL_CODE_PUSH_OBJVAR_0 = 0x64,
|
|
|
|
HCL_CODE_PUSH_OBJVAR_1 = 0x65,
|
|
|
|
HCL_CODE_PUSH_OBJVAR_2 = 0x66,
|
|
|
|
HCL_CODE_PUSH_OBJVAR_3 = 0x67,
|
2016-10-10 11:36:24 +00:00
|
|
|
|
2020-09-22 09:19:53 +00:00
|
|
|
HCL_CODE_STORE_INTO_OBJVAR_0 = 0x68,
|
|
|
|
HCL_CODE_STORE_INTO_OBJVAR_1 = 0x69,
|
|
|
|
HCL_CODE_STORE_INTO_OBJVAR_2 = 0x6A,
|
|
|
|
HCL_CODE_STORE_INTO_OBJVAR_3 = 0x6B,
|
2016-10-10 11:36:24 +00:00
|
|
|
|
2020-09-22 09:19:53 +00:00
|
|
|
HCL_CODE_POP_INTO_OBJVAR_0 = 0x6C,
|
|
|
|
HCL_CODE_POP_INTO_OBJVAR_1 = 0x6D,
|
|
|
|
HCL_CODE_POP_INTO_OBJVAR_2 = 0x6E,
|
|
|
|
HCL_CODE_POP_INTO_OBJVAR_3 = 0x6F,
|
2016-10-10 11:36:24 +00:00
|
|
|
|
2022-01-23 16:46:13 +00:00
|
|
|
HCL_CODE_SEND_0 = 0x70, /* 112 */
|
|
|
|
HCL_CODE_SEND_1 = 0x71, /* 113 */
|
|
|
|
HCL_CODE_SEND_2 = 0x72, /* 114 */
|
|
|
|
HCL_CODE_SEND_3 = 0x73, /* 115 */
|
2022-01-01 14:58:57 +00:00
|
|
|
|
2022-01-23 16:46:13 +00:00
|
|
|
HCL_CODE_SEND_TO_SUPER_0 = 0x74, /* 116 */
|
|
|
|
HCL_CODE_SEND_TO_SUPER_1 = 0x75, /* 117 */
|
|
|
|
HCL_CODE_SEND_TO_SUPER_2 = 0x76, /* 118 */
|
|
|
|
HCL_CODE_SEND_TO_SUPER_3 = 0x77, /* 119 */
|
2022-01-01 14:58:57 +00:00
|
|
|
|
2022-02-17 12:40:22 +00:00
|
|
|
HCL_CODE_PUSH_CVAR_I_X = 0x78, /* 120 */
|
|
|
|
HCL_CODE_STORE_INTO_CVAR_I_X = 0x79, /* 121 */
|
|
|
|
HCL_CODE_POP_INTO_CVAR_I_X = 0x7A, /* 122 */
|
2022-01-09 16:47:38 +00:00
|
|
|
|
2022-02-17 12:40:22 +00:00
|
|
|
HCL_CODE_PUSH_CVAR_M_X = 0x7B, /* 123 */
|
|
|
|
HCL_CODE_STORE_INTO_CVAR_M_X = 0x7C, /* 124 */
|
|
|
|
HCL_CODE_POP_INTO_CVAR_M_X = 0x7D, /* 125 */
|
2016-09-28 14:40:37 +00:00
|
|
|
|
2022-01-23 16:46:13 +00:00
|
|
|
/* UNUSED 0x7E - 0x7F */
|
2022-02-17 12:40:22 +00:00
|
|
|
HCL_CODE_STORE_INTO_IVAR_X = 0x80, /* 128 */
|
2016-09-28 14:40:37 +00:00
|
|
|
|
2020-09-22 09:19:53 +00:00
|
|
|
HCL_CODE_PUSH_RECEIVER = 0x81, /* 129 */
|
2018-02-06 13:52:58 +00:00
|
|
|
HCL_CODE_PUSH_NIL = 0x82, /* 130 */
|
|
|
|
HCL_CODE_PUSH_TRUE = 0x83, /* 131 */
|
|
|
|
HCL_CODE_PUSH_FALSE = 0x84, /* 132 */
|
2020-09-22 09:19:53 +00:00
|
|
|
HCL_CODE_PUSH_CONTEXT = 0x85, /* 133 */
|
|
|
|
HCL_CODE_PUSH_PROCESS = 0x86, /* 134 */
|
2022-03-21 15:38:31 +00:00
|
|
|
/* UNUSED 0x87 */
|
2016-09-28 14:40:37 +00:00
|
|
|
|
2022-02-17 12:40:22 +00:00
|
|
|
HCL_CODE_POP_INTO_IVAR_X = 0x88, /* 136 ## */
|
2016-09-28 14:40:37 +00:00
|
|
|
|
2018-02-06 13:52:58 +00:00
|
|
|
HCL_CODE_PUSH_NEGONE = 0x89, /* 137 */
|
|
|
|
HCL_CODE_PUSH_ZERO = 0x8A, /* 138 */
|
|
|
|
HCL_CODE_PUSH_ONE = 0x8B, /* 139 */
|
|
|
|
HCL_CODE_PUSH_TWO = 0x8C, /* 140 */
|
2016-09-28 14:40:37 +00:00
|
|
|
|
2022-02-17 12:40:22 +00:00
|
|
|
HCL_CODE_PUSH_IVAR_X = 0x90, /* 144 ## */
|
2018-02-06 13:52:58 +00:00
|
|
|
HCL_CODE_PUSH_TEMPVAR_X = 0x98, /* 152 ## */
|
|
|
|
HCL_CODE_STORE_INTO_TEMPVAR_X = 0xA0, /* 160 ## */
|
2020-09-22 09:19:53 +00:00
|
|
|
HCL_CODE_POP_INTO_TEMPVAR_X = 0xA8, /* 168 ## */
|
2016-09-28 14:40:37 +00:00
|
|
|
|
2018-02-06 13:52:58 +00:00
|
|
|
HCL_CODE_PUSH_LITERAL_X = 0xB0, /* 176 ## */
|
|
|
|
HCL_CODE_PUSH_LITERAL_X2 = 0xB1, /* 177 */
|
2016-09-28 14:40:37 +00:00
|
|
|
|
2018-02-06 13:52:58 +00:00
|
|
|
HCL_CODE_PUSH_INTLIT = 0xB2, /* 178 */
|
|
|
|
HCL_CODE_PUSH_NEGINTLIT = 0xB3, /* 179 */
|
|
|
|
HCL_CODE_PUSH_CHARLIT = 0xB4, /* 180 */
|
2016-09-28 14:40:37 +00:00
|
|
|
|
2022-03-21 15:38:31 +00:00
|
|
|
HCL_CODE_PLUS = 0xB5, /* 181 TOOD: move it to a lower code number later after killing OBJVAR instructions */
|
|
|
|
/* UNUSED - 0xB6 - 0xB7 */
|
2021-01-24 15:45:28 +00:00
|
|
|
|
2018-02-06 13:52:58 +00:00
|
|
|
HCL_CODE_STORE_INTO_OBJECT_X = 0xB8, /* 184 ## */
|
2020-09-22 09:19:53 +00:00
|
|
|
HCL_CODE_POP_INTO_OBJECT_X = 0xBC, /* 188 ## */
|
2018-02-06 13:52:58 +00:00
|
|
|
HCL_CODE_PUSH_OBJECT_X = 0xC0, /* 192 ## */
|
2016-09-28 14:40:37 +00:00
|
|
|
|
2021-01-24 15:45:28 +00:00
|
|
|
/* UNUSED - 0xC1 - 0xC3 */
|
|
|
|
|
2018-02-06 13:52:58 +00:00
|
|
|
HCL_CODE_JUMP_FORWARD_X = 0xC4, /* 196 ## */
|
2016-10-10 11:36:24 +00:00
|
|
|
HCL_CODE_JUMP2_FORWARD = 0xC5, /* 197 */
|
2018-02-06 13:52:58 +00:00
|
|
|
|
2021-01-24 15:45:28 +00:00
|
|
|
/* UNUSED - 0xC6 - 0xC7 */
|
|
|
|
|
2018-02-06 13:52:58 +00:00
|
|
|
HCL_CODE_JUMP_BACKWARD_X = 0xC8, /* 200 ## */
|
2016-10-10 11:36:24 +00:00
|
|
|
HCL_CODE_JUMP2_BACKWARD = 0xC9, /* 201 */
|
2018-02-06 13:52:58 +00:00
|
|
|
|
2021-01-24 15:45:28 +00:00
|
|
|
/* UNUSED - 0xCA - 0xCB */
|
|
|
|
|
2018-02-06 13:52:58 +00:00
|
|
|
HCL_CODE_JUMP_FORWARD_IF_TRUE = 0xCC, /* 204 ## */
|
2016-10-12 07:30:54 +00:00
|
|
|
HCL_CODE_JUMP2_FORWARD_IF_TRUE = 0xCD, /* 205 */
|
2021-01-24 15:45:28 +00:00
|
|
|
HCL_CODE_JUMP_BACKWARD_IF_TRUE = 0xCE, /* 206 ## */
|
|
|
|
HCL_CODE_JUMP2_BACKWARD_IF_TRUE = 0xCF, /* 207 */
|
|
|
|
|
2018-02-06 13:52:58 +00:00
|
|
|
HCL_CODE_JUMP_FORWARD_IF_FALSE = 0xD0, /* 208 ## */
|
2016-10-12 07:30:54 +00:00
|
|
|
HCL_CODE_JUMP2_FORWARD_IF_FALSE = 0xD1, /* 209 */
|
2021-01-24 15:45:28 +00:00
|
|
|
HCL_CODE_JUMP_BACKWARD_IF_FALSE = 0xD2, /* 210 ## */
|
|
|
|
HCL_CODE_JUMP2_BACKWARD_IF_FALSE = 0xD3, /* 211 */
|
2016-09-28 14:40:37 +00:00
|
|
|
|
2021-05-11 15:04:53 +00:00
|
|
|
HCL_CODE_CALL_X = 0xD4, /* 212 ## */
|
|
|
|
HCL_CODE_CALL_R = 0xD5, /* 213 ## ##*/
|
2023-10-23 09:49:15 +00:00
|
|
|
HCL_CODE_PUSH_RETURN_R = 0xD6, /* 214 */
|
|
|
|
HCL_CODE_TRY_ENTER = 0xD7, /* 215 ## */
|
2021-05-11 15:04:53 +00:00
|
|
|
|
2018-02-06 13:52:58 +00:00
|
|
|
HCL_CODE_STORE_INTO_CTXTEMPVAR_X = 0xD8, /* 216 ## */
|
2023-10-23 09:49:15 +00:00
|
|
|
HCL_CODE_TRY_ENTER2 = 0xD9, /* 217 ## */
|
2021-05-13 14:43:40 +00:00
|
|
|
HCL_CODE_TRY_EXIT = 0xDA, /* 218 */
|
|
|
|
HCL_CODE_THROW = 0xDB, /* 219 */
|
2021-01-24 15:45:28 +00:00
|
|
|
|
2020-09-22 09:19:53 +00:00
|
|
|
HCL_CODE_POP_INTO_CTXTEMPVAR_X = 0xDC, /* 220 ## */
|
2024-04-13 08:17:15 +00:00
|
|
|
HCL_CODE_CLASS_LOAD = 0xDD, /* 221 ## */
|
2024-09-15 02:51:11 +00:00
|
|
|
HCL_CODE_MAKE_CHARARRAY = 0xDE, /* 222 ## */
|
|
|
|
HCL_CODE_POP_INTO_CHARARRAY = 0xDF, /* 223 ## */
|
2021-01-24 15:45:28 +00:00
|
|
|
|
2018-02-06 13:52:58 +00:00
|
|
|
HCL_CODE_PUSH_CTXTEMPVAR_X = 0xE0, /* 224 ## */
|
2021-06-18 18:54:50 +00:00
|
|
|
HCL_CODE_CLASS_ENTER = 0xE1, /* 225 ## */
|
2021-12-24 00:05:58 +00:00
|
|
|
HCL_CODE_CLASS_EXIT = 0xE2, /* 226 */
|
2022-01-29 17:43:11 +00:00
|
|
|
HCL_CODE_CLASS_PEXIT = 0xE3, /* 227 */
|
2018-02-06 13:52:58 +00:00
|
|
|
|
2020-09-22 09:19:53 +00:00
|
|
|
HCL_CODE_PUSH_OBJVAR_X = 0xE4, /* 228 ## */
|
2022-02-12 15:05:31 +00:00
|
|
|
HCL_CODE_CLASS_CMSTORE = 0xE5, /* 229 */
|
2024-07-19 11:50:28 +00:00
|
|
|
HCL_CODE_CLASS_IMSTORE = 0xE6, /* 230 */
|
|
|
|
HCL_CODE_CLASS_CIMSTORE = 0xE7, /* 231 */
|
2021-01-24 15:45:28 +00:00
|
|
|
|
2020-09-22 09:19:53 +00:00
|
|
|
HCL_CODE_STORE_INTO_OBJVAR_X = 0xE8, /* 232 ## */
|
2021-01-24 15:45:28 +00:00
|
|
|
HCL_CODE_MAKE_ARRAY = 0xE9, /* 233 ## */
|
|
|
|
HCL_CODE_MAKE_BYTEARRAY = 0xEA, /* 234 ## */
|
|
|
|
HCL_CODE_MAKE_DIC = 0xEB, /* 235 ## */
|
2021-03-28 03:44:27 +00:00
|
|
|
|
2020-09-22 09:19:53 +00:00
|
|
|
HCL_CODE_POP_INTO_OBJVAR_X = 0xEC, /* 236 ## */
|
2021-01-24 15:45:28 +00:00
|
|
|
HCL_CODE_POP_INTO_ARRAY = 0xED, /* 237 ## */
|
|
|
|
HCL_CODE_POP_INTO_BYTEARRAY = 0xEE, /* 238 ## */
|
|
|
|
HCL_CODE_POP_INTO_DIC = 0xEF, /* 239 */
|
2018-02-07 13:55:22 +00:00
|
|
|
|
2022-01-23 16:46:13 +00:00
|
|
|
HCL_CODE_SEND_X = 0xF0, /* 240 ## */
|
2022-02-21 16:07:55 +00:00
|
|
|
HCL_CODE_SEND_R = 0xF1, /* 241 ## ## - [NOTE] ((code >> 2) & 1) must be 0 */
|
2022-01-23 16:46:13 +00:00
|
|
|
|
|
|
|
HCL_CODE_MAKE_CONS = 0xF2, /* 242 */
|
|
|
|
HCL_CODE_POP_INTO_CONS = 0xF3, /* 243 */
|
|
|
|
|
|
|
|
HCL_CODE_SEND_TO_SUPER_X = 0xF4, /* 244 ## */
|
2022-02-21 16:07:55 +00:00
|
|
|
HCL_CODE_SEND_TO_SUPER_R = 0xF5, /* 245 ## ## - [NOTE] ((code >> 2) & 1) must be 0 */
|
2021-01-24 15:45:28 +00:00
|
|
|
|
2022-01-23 16:46:13 +00:00
|
|
|
HCL_CODE_POP_INTO_CONS_END = 0xF6, /* 246 */
|
|
|
|
HCL_CODE_POP_INTO_CONS_CDR = 0xF7, /* 247 */
|
2018-02-06 13:52:58 +00:00
|
|
|
/* -------------------------------------- */
|
2016-09-28 14:40:37 +00:00
|
|
|
|
2022-01-23 16:46:13 +00:00
|
|
|
HCL_CODE_DUP_STACKTOP = 0xF8, /* 248 */
|
|
|
|
HCL_CODE_POP_STACKTOP = 0xF9, /* 249 */
|
|
|
|
HCL_CODE_RETURN_STACKTOP = 0xFA, /* 250 */
|
|
|
|
HCL_CODE_RETURN_RECEIVER = 0xFB, /* 251 */
|
|
|
|
HCL_CODE_RETURN_FROM_BLOCK = 0xFC, /* 252, return the stack top from a block */
|
2020-10-04 18:21:05 +00:00
|
|
|
|
2022-01-23 16:46:13 +00:00
|
|
|
HCL_CODE_MAKE_FUNCTION = 0xFD, /* 253 */
|
2024-05-31 06:16:31 +00:00
|
|
|
HCL_CODE_MAKE_BLOCK = 0xFE, /* 254 */
|
2018-02-06 13:52:58 +00:00
|
|
|
HCL_CODE_NOOP = 0xFF /* 255 */
|
2016-09-28 14:40:37 +00:00
|
|
|
};
|
|
|
|
|
2018-02-13 16:10:41 +00:00
|
|
|
typedef hcl_ooi_t (*hcl_outbfmt_t) (
|
|
|
|
hcl_t* hcl,
|
2018-04-26 04:39:20 +00:00
|
|
|
hcl_bitmask_t mask,
|
2018-02-13 16:10:41 +00:00
|
|
|
const hcl_bch_t* fmt,
|
|
|
|
...
|
|
|
|
);
|
|
|
|
|
2021-03-28 03:44:27 +00:00
|
|
|
/* i don't want an error raised inside the callback to override
|
2018-02-22 04:35:55 +00:00
|
|
|
* the existing error number and message. */
|
2023-12-06 02:09:15 +00:00
|
|
|
#define HCL_VMPRIM_LOG_WRITE(hcl,mask,ptr,len) do { \
|
2018-02-22 04:35:55 +00:00
|
|
|
int shuterr = (hcl)->shuterr; \
|
|
|
|
(hcl)->shuterr = 1; \
|
|
|
|
(hcl)->vmprim.log_write (hcl, mask, ptr, len); \
|
|
|
|
(hcl)->shuterr = shuterr; \
|
|
|
|
} while(0)
|
|
|
|
|
2023-12-06 02:09:15 +00:00
|
|
|
|
|
|
|
#define HCL_CHAR_TO_NUM(c,base) \
|
|
|
|
((c >= '0' && c <= '9')? ((c - '0' < base)? (c - '0'): base): \
|
|
|
|
(c >= 'A' && c <= 'Z')? ((c - 'A' + 10 < base)? (c - 'A' + 10): base): \
|
|
|
|
(c >= 'a' && c <= 'z')? ((c - 'a' + 10 < base)? (c - 'a' + 10): base): base)
|
|
|
|
|
2024-09-28 02:57:56 +00:00
|
|
|
|
|
|
|
/* receiver check failure leads to hard failure.
|
|
|
|
* RATIONAL: the primitive handler should be used by relevant classes and
|
|
|
|
* objects only. if the receiver check fails, you must review
|
|
|
|
* your class library */
|
|
|
|
#define HCL_PF_CHECK_RCV(hcl,cond) do { \
|
|
|
|
if (!(cond)) { hcl_seterrnum((hcl), HCL_EMSGRCV); return HCL_PF_HARD_FAILURE; } \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
/* argument check failure causes the wrapping method to return an error.
|
|
|
|
* RATIONAL: Being a typeless language, it's hard to control the kinds of
|
|
|
|
* arguments.
|
|
|
|
*/
|
|
|
|
#define HCL_PF_CHECK_ARGS(hcl,nargs,cond) do { \
|
|
|
|
if (!(cond)) { hcl_seterrnum (hcl, HCL_EINVAL); return HCL_PF_FAILURE; } \
|
|
|
|
} while(0)
|
|
|
|
|
2016-09-28 14:40:37 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* ========================================================================= */
|
|
|
|
/* heap.c */
|
|
|
|
/* ========================================================================= */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The hcl_makeheap() function creates a new heap of the \a size bytes.
|
|
|
|
*
|
|
|
|
* \return heap pointer on success and #HCL_NULL on failure.
|
|
|
|
*/
|
|
|
|
hcl_heap_t* hcl_makeheap (
|
2021-03-28 03:44:27 +00:00
|
|
|
hcl_t* hcl,
|
2016-09-28 14:40:37 +00:00
|
|
|
hcl_oow_t size
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The hcl_killheap() function destroys the heap pointed to by \a heap.
|
|
|
|
*/
|
|
|
|
void hcl_killheap (
|
2021-03-28 03:44:27 +00:00
|
|
|
hcl_t* hcl,
|
2016-09-28 14:40:37 +00:00
|
|
|
hcl_heap_t* heap
|
|
|
|
);
|
|
|
|
|
2021-03-28 03:44:27 +00:00
|
|
|
/**
|
2020-12-31 17:48:47 +00:00
|
|
|
* The hcl_allocheapmem() function allocates \a size bytes from the given heap
|
|
|
|
* and clears it with zeros.
|
2016-09-28 14:40:37 +00:00
|
|
|
*/
|
2020-12-31 17:48:47 +00:00
|
|
|
void* hcl_callocheapmem (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_heap_t* heap,
|
|
|
|
hcl_oow_t size
|
|
|
|
);
|
|
|
|
|
2021-01-17 17:45:39 +00:00
|
|
|
void* hcl_callocheapmem_noseterr (
|
2020-12-31 17:48:47 +00:00
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_heap_t* heap,
|
|
|
|
hcl_oow_t size
|
|
|
|
);
|
|
|
|
|
|
|
|
void hcl_freeheapmem (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_heap_t* heap,
|
|
|
|
void* ptr
|
2016-09-28 14:40:37 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
/* ========================================================================= */
|
|
|
|
/* obj.c */
|
|
|
|
/* ========================================================================= */
|
|
|
|
void* hcl_allocbytes (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oow_t size
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The hcl_allocoopobj() function allocates a raw object composed of \a size
|
|
|
|
* pointer fields excluding the header.
|
|
|
|
*/
|
|
|
|
hcl_oop_t hcl_allocoopobj (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oow_t size
|
|
|
|
);
|
|
|
|
|
|
|
|
hcl_oop_t hcl_allocoopobjwithtrailer (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oow_t size,
|
|
|
|
const hcl_oob_t* tptr,
|
|
|
|
hcl_oow_t tlen
|
|
|
|
);
|
|
|
|
|
|
|
|
hcl_oop_t hcl_alloccharobj (
|
|
|
|
hcl_t* hcl,
|
|
|
|
const hcl_ooch_t* ptr,
|
|
|
|
hcl_oow_t len
|
|
|
|
);
|
|
|
|
|
|
|
|
hcl_oop_t hcl_allocbyteobj (
|
2016-10-04 17:56:28 +00:00
|
|
|
hcl_t* hcl,
|
|
|
|
const hcl_oob_t* ptr,
|
|
|
|
hcl_oow_t len
|
2016-09-28 14:40:37 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
hcl_oop_t hcl_allochalfwordobj (
|
|
|
|
hcl_t* hcl,
|
|
|
|
const hcl_oohw_t* ptr,
|
|
|
|
hcl_oow_t len
|
|
|
|
);
|
|
|
|
|
|
|
|
hcl_oop_t hcl_allocwordobj (
|
|
|
|
hcl_t* hcl,
|
|
|
|
const hcl_oow_t* ptr,
|
|
|
|
hcl_oow_t len
|
|
|
|
);
|
|
|
|
|
2024-05-15 13:59:34 +00:00
|
|
|
hcl_oop_t hcl_instantiatewithtrailer (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_class_t _class,
|
|
|
|
hcl_oow_t vlen,
|
|
|
|
const hcl_oob_t* trptr,
|
|
|
|
hcl_oow_t trlen
|
|
|
|
);
|
|
|
|
|
2016-09-28 14:40:37 +00:00
|
|
|
/* ========================================================================= */
|
|
|
|
/* sym.c */
|
|
|
|
/* ========================================================================= */
|
|
|
|
hcl_oop_t hcl_makesymbol (
|
|
|
|
hcl_t* hcl,
|
|
|
|
const hcl_ooch_t* ptr,
|
|
|
|
hcl_oow_t len
|
|
|
|
);
|
|
|
|
|
2024-04-06 07:21:31 +00:00
|
|
|
hcl_oop_t hcl_makesymbolwithbcstr (
|
|
|
|
hcl_t* hcl,
|
|
|
|
const hcl_bch_t* ptr
|
|
|
|
);
|
|
|
|
|
|
|
|
hcl_oop_t hcl_makesymbolwithucstr (
|
|
|
|
hcl_t* hcl,
|
|
|
|
const hcl_uch_t* ptr
|
|
|
|
);
|
|
|
|
|
2016-09-28 14:40:37 +00:00
|
|
|
hcl_oop_t hcl_findsymbol (
|
|
|
|
hcl_t* hcl,
|
|
|
|
const hcl_ooch_t* ptr,
|
|
|
|
hcl_oow_t len
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2024-07-19 11:50:28 +00:00
|
|
|
/* ========================================================================= */
|
|
|
|
/* dic.c */
|
|
|
|
/* ========================================================================= */
|
|
|
|
hcl_oop_cons_t hcl_putatdic_method (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_dic_t dic,
|
|
|
|
hcl_oop_t key,
|
|
|
|
hcl_oop_t value,
|
|
|
|
int mtype /* 1 for class method, 2 for instance method */
|
|
|
|
);
|
|
|
|
|
2016-09-28 14:40:37 +00:00
|
|
|
/* ========================================================================= */
|
2020-12-31 17:48:47 +00:00
|
|
|
/* gc.c */
|
|
|
|
/* ========================================================================= */
|
|
|
|
|
|
|
|
hcl_oow_t hcl_getobjpayloadbytes (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t oop
|
|
|
|
);
|
|
|
|
|
|
|
|
void hcl_gc_ms_sweep_lazy (
|
2021-01-17 17:45:39 +00:00
|
|
|
hcl_t* hcl,
|
2020-12-31 17:48:47 +00:00
|
|
|
hcl_oow_t allocsize
|
|
|
|
);
|
|
|
|
|
|
|
|
/* ========================================================================= */
|
2016-09-28 14:40:37 +00:00
|
|
|
/* utf8.c */
|
|
|
|
/* ========================================================================= */
|
2018-04-06 16:33:17 +00:00
|
|
|
hcl_oow_t hcl_uc_to_utf8 (
|
2016-09-28 14:40:37 +00:00
|
|
|
hcl_uch_t uc,
|
|
|
|
hcl_bch_t* utf8,
|
|
|
|
hcl_oow_t size
|
|
|
|
);
|
|
|
|
|
2018-04-06 16:33:17 +00:00
|
|
|
hcl_oow_t hcl_utf8_to_uc (
|
2016-09-28 14:40:37 +00:00
|
|
|
const hcl_bch_t* utf8,
|
|
|
|
hcl_oow_t size,
|
|
|
|
hcl_uch_t* uc
|
|
|
|
);
|
|
|
|
|
|
|
|
int hcl_ucstoutf8 (
|
|
|
|
const hcl_uch_t* ucs,
|
|
|
|
hcl_oow_t* ucslen,
|
|
|
|
hcl_bch_t* bcs,
|
|
|
|
hcl_oow_t* bcslen
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
2018-04-06 16:33:17 +00:00
|
|
|
* The hcl_utf8_to_ucs() function converts a UTF8 string to a uncide string.
|
2016-09-28 14:40:37 +00:00
|
|
|
*
|
|
|
|
* It never returns -2 if \a ucs is #HCL_NULL.
|
|
|
|
*
|
|
|
|
* \code
|
|
|
|
* const hcl_bch_t* bcs = "test string";
|
|
|
|
* hcl_uch_t ucs[100];
|
|
|
|
* hcl_oow_t ucslen = HCL_COUNTOF(buf), n;
|
|
|
|
* hcl_oow_t bcslen = 11;
|
|
|
|
* int n;
|
2018-04-06 16:33:17 +00:00
|
|
|
* n = hcl_utf8_to_ucs (bcs, &bcslen, ucs, &ucslen);
|
2016-09-28 14:40:37 +00:00
|
|
|
* if (n <= -1) { invalid/incomplenete sequence or buffer to small }
|
|
|
|
* \endcode
|
|
|
|
*
|
|
|
|
* For a null-terminated string, you can specify ~(hcl_oow_t)0 in
|
|
|
|
* \a bcslen. The destination buffer \a ucs also must be large enough to
|
|
|
|
* store a terminating null. Otherwise, -2 is returned.
|
2021-03-28 03:44:27 +00:00
|
|
|
*
|
2016-09-28 14:40:37 +00:00
|
|
|
* The resulting \a ucslen can still be greater than 0 even if the return
|
|
|
|
* value is negative. The value indiates the number of characters converted
|
|
|
|
* before the error has occurred.
|
|
|
|
*
|
|
|
|
* \return 0 on success.
|
|
|
|
* -1 if \a bcs contains an illegal character.
|
|
|
|
* -2 if the wide-character string buffer is too small.
|
|
|
|
* -3 if \a bcs is not a complete sequence.
|
|
|
|
*/
|
2018-04-06 16:33:17 +00:00
|
|
|
int hcl_utf8_to_ucs (
|
2016-09-28 14:40:37 +00:00
|
|
|
const hcl_bch_t* bcs,
|
|
|
|
hcl_oow_t* bcslen,
|
|
|
|
hcl_uch_t* ucs,
|
|
|
|
hcl_oow_t* ucslen
|
|
|
|
);
|
|
|
|
|
|
|
|
/* ========================================================================= */
|
2018-03-28 16:40:42 +00:00
|
|
|
/* bigint.c */
|
2016-09-28 14:40:37 +00:00
|
|
|
/* ========================================================================= */
|
2019-05-04 17:56:45 +00:00
|
|
|
static HCL_INLINE int hcl_isbigint (hcl_t* hcl, hcl_oop_t x)
|
|
|
|
{
|
|
|
|
return HCL_IS_BIGINT(hcl, x);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HCL_INLINE int hcl_isint (hcl_t* hcl, hcl_oop_t x)
|
|
|
|
{
|
|
|
|
return HCL_OOP_IS_SMOOI(x) || HCL_IS_BIGINT(hcl, x);
|
|
|
|
}
|
2016-09-28 14:40:37 +00:00
|
|
|
|
|
|
|
hcl_oop_t hcl_addints (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x,
|
|
|
|
hcl_oop_t y
|
|
|
|
);
|
|
|
|
|
|
|
|
hcl_oop_t hcl_subints (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x,
|
|
|
|
hcl_oop_t y
|
|
|
|
);
|
|
|
|
|
|
|
|
hcl_oop_t hcl_mulints (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x,
|
|
|
|
hcl_oop_t y
|
|
|
|
);
|
|
|
|
|
|
|
|
hcl_oop_t hcl_divints (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x,
|
|
|
|
hcl_oop_t y,
|
2021-01-10 16:04:36 +00:00
|
|
|
int modulo,
|
2016-09-28 14:40:37 +00:00
|
|
|
hcl_oop_t* rem
|
|
|
|
);
|
|
|
|
|
|
|
|
hcl_oop_t hcl_negateint (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x
|
|
|
|
);
|
|
|
|
|
|
|
|
hcl_oop_t hcl_bitatint (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x,
|
|
|
|
hcl_oop_t y
|
|
|
|
);
|
|
|
|
|
|
|
|
hcl_oop_t hcl_bitandints (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x,
|
|
|
|
hcl_oop_t y
|
|
|
|
);
|
|
|
|
|
|
|
|
hcl_oop_t hcl_bitorints (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x,
|
|
|
|
hcl_oop_t y
|
|
|
|
);
|
|
|
|
|
|
|
|
hcl_oop_t hcl_bitxorints (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x,
|
|
|
|
hcl_oop_t y
|
|
|
|
);
|
|
|
|
|
|
|
|
hcl_oop_t hcl_bitinvint (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x
|
|
|
|
);
|
|
|
|
|
|
|
|
hcl_oop_t hcl_bitshiftint (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x,
|
|
|
|
hcl_oop_t y
|
|
|
|
);
|
|
|
|
|
|
|
|
hcl_oop_t hcl_eqints (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x,
|
|
|
|
hcl_oop_t y
|
|
|
|
);
|
|
|
|
|
|
|
|
hcl_oop_t hcl_neints (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x,
|
|
|
|
hcl_oop_t y
|
|
|
|
);
|
|
|
|
|
|
|
|
hcl_oop_t hcl_gtints (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x,
|
|
|
|
hcl_oop_t y
|
|
|
|
);
|
|
|
|
|
|
|
|
hcl_oop_t hcl_geints (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x,
|
|
|
|
hcl_oop_t y
|
|
|
|
);
|
|
|
|
|
|
|
|
hcl_oop_t hcl_ltints (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x,
|
|
|
|
hcl_oop_t y
|
|
|
|
);
|
|
|
|
|
|
|
|
hcl_oop_t hcl_leints (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x,
|
|
|
|
hcl_oop_t y
|
|
|
|
);
|
|
|
|
|
2018-04-03 14:02:40 +00:00
|
|
|
hcl_oop_t hcl_sqrtint (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x
|
|
|
|
);
|
|
|
|
|
2018-04-07 02:28:38 +00:00
|
|
|
hcl_oop_t hcl_absint (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x
|
|
|
|
);
|
|
|
|
|
2016-09-28 14:40:37 +00:00
|
|
|
hcl_oop_t hcl_strtoint (
|
|
|
|
hcl_t* hcl,
|
|
|
|
const hcl_ooch_t* str,
|
|
|
|
hcl_oow_t len,
|
2018-02-13 16:10:41 +00:00
|
|
|
int radix
|
2016-09-28 14:40:37 +00:00
|
|
|
);
|
|
|
|
|
2019-04-16 15:46:00 +00:00
|
|
|
|
|
|
|
#define HCL_INTTOSTR_RADIXMASK (0xFF)
|
|
|
|
#define HCL_INTTOSTR_LOWERCASE (1 << 8)
|
|
|
|
#define HCL_INTTOSTR_NONEWOBJ (1 << 9)
|
2018-02-15 08:05:48 +00:00
|
|
|
/**
|
|
|
|
* The hcl_inttostr() function converts an integer object to a string object
|
2019-04-16 15:46:00 +00:00
|
|
|
* printed in the given radix. If HCL_INTTOSTR_NONEWOBJ is set in flags_radix,
|
2021-03-28 03:44:27 +00:00
|
|
|
* it returns hcl->_nil but keeps the result in the buffer pointed to by
|
2019-04-16 15:46:00 +00:00
|
|
|
* hcl->inttostr.xbuf.ptr with the length stored in hcl->inttostr.xbuf.len.
|
|
|
|
* If the function fails, it returns #HCL_NULL.
|
2018-02-15 08:05:48 +00:00
|
|
|
*/
|
2016-09-28 14:40:37 +00:00
|
|
|
hcl_oop_t hcl_inttostr (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t num,
|
2019-04-16 15:46:00 +00:00
|
|
|
int flagged_radix /* radix between 2 and 36 inclusive, optionally bitwise ORed of HCL_INTTOSTR_XXX bits */
|
2016-09-28 14:40:37 +00:00
|
|
|
);
|
|
|
|
|
2018-03-28 16:40:42 +00:00
|
|
|
/* ========================================================================= */
|
|
|
|
/* number.c */
|
|
|
|
/* ========================================================================= */
|
|
|
|
hcl_oop_t hcl_addnums (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x,
|
|
|
|
hcl_oop_t y
|
|
|
|
);
|
|
|
|
|
|
|
|
hcl_oop_t hcl_subnums (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x,
|
|
|
|
hcl_oop_t y
|
|
|
|
);
|
2018-03-30 15:43:09 +00:00
|
|
|
|
|
|
|
hcl_oop_t hcl_mulnums (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x,
|
|
|
|
hcl_oop_t y
|
|
|
|
);
|
|
|
|
|
2018-04-02 12:52:10 +00:00
|
|
|
hcl_oop_t hcl_mltnums (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x,
|
|
|
|
hcl_oop_t y
|
|
|
|
);
|
|
|
|
|
2018-03-30 15:43:09 +00:00
|
|
|
hcl_oop_t hcl_divnums (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x,
|
|
|
|
hcl_oop_t y
|
|
|
|
);
|
|
|
|
|
2018-04-01 17:09:07 +00:00
|
|
|
hcl_oop_t hcl_truncfpdecval (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t iv, /* integer */
|
|
|
|
hcl_ooi_t cs, /* current scale */
|
|
|
|
hcl_ooi_t ns /* new scale */
|
|
|
|
);
|
|
|
|
|
2018-04-02 12:28:09 +00:00
|
|
|
hcl_oop_t hcl_gtnums (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x,
|
|
|
|
hcl_oop_t y
|
|
|
|
);
|
|
|
|
|
|
|
|
hcl_oop_t hcl_genums (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x,
|
|
|
|
hcl_oop_t y
|
|
|
|
);
|
|
|
|
|
|
|
|
hcl_oop_t hcl_ltnums (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x,
|
|
|
|
hcl_oop_t y
|
|
|
|
);
|
|
|
|
|
|
|
|
hcl_oop_t hcl_lenums (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x,
|
|
|
|
hcl_oop_t y
|
|
|
|
);
|
|
|
|
|
|
|
|
hcl_oop_t hcl_eqnums (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x,
|
|
|
|
hcl_oop_t y
|
|
|
|
);
|
|
|
|
|
|
|
|
hcl_oop_t hcl_nenums (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x,
|
|
|
|
hcl_oop_t y
|
|
|
|
);
|
2018-04-03 14:02:40 +00:00
|
|
|
|
|
|
|
hcl_oop_t hcl_sqrtnum (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x
|
|
|
|
);
|
|
|
|
|
2018-04-07 02:28:38 +00:00
|
|
|
hcl_oop_t hcl_absnum (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oop_t x
|
2016-09-28 14:40:37 +00:00
|
|
|
);
|
|
|
|
|
2018-02-09 04:24:50 +00:00
|
|
|
/* ========================================================================= */
|
|
|
|
/* hcl.c */
|
|
|
|
/* ========================================================================= */
|
|
|
|
|
|
|
|
hcl_mod_data_t* hcl_openmod (
|
|
|
|
hcl_t* hcl,
|
|
|
|
const hcl_ooch_t* name,
|
2018-02-12 16:51:38 +00:00
|
|
|
hcl_oow_t namelen
|
2018-02-09 04:24:50 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
void hcl_closemod (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_mod_data_t* mdp
|
|
|
|
);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The hcl_querymod() function finds a primitive function in modules
|
|
|
|
* with a full primitive identifier.
|
|
|
|
*/
|
|
|
|
hcl_pfbase_t* hcl_querymod (
|
|
|
|
hcl_t* hcl,
|
|
|
|
const hcl_ooch_t* pfid,
|
2018-02-28 04:52:01 +00:00
|
|
|
hcl_oow_t pfidlen,
|
|
|
|
hcl_mod_t** mod
|
2018-02-09 04:24:50 +00:00
|
|
|
);
|
|
|
|
|
2018-02-05 15:59:32 +00:00
|
|
|
/* ========================================================================= */
|
2020-10-08 09:25:54 +00:00
|
|
|
/* fmt.c */
|
2018-02-05 15:59:32 +00:00
|
|
|
/* ========================================================================= */
|
2024-05-14 11:52:25 +00:00
|
|
|
int hcl_fmt_object (
|
|
|
|
hcl_t* hcl,
|
2019-05-31 10:54:13 +00:00
|
|
|
hcl_fmtout_t* fmtout,
|
|
|
|
hcl_oop_t oop
|
2018-02-05 15:59:32 +00:00
|
|
|
);
|
|
|
|
|
2019-05-31 10:54:13 +00:00
|
|
|
int hcl_prfmtcallstack (
|
2018-03-01 09:46:02 +00:00
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_ooi_t nargs
|
|
|
|
);
|
|
|
|
|
2019-05-31 10:54:13 +00:00
|
|
|
int hcl_logfmtcallstack (
|
2018-02-28 15:57:19 +00:00
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_ooi_t nargs
|
|
|
|
);
|
2018-02-05 15:59:32 +00:00
|
|
|
|
2019-05-31 10:54:13 +00:00
|
|
|
int hcl_strfmtcallstack (
|
2018-03-05 03:35:44 +00:00
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_ooi_t nargs
|
|
|
|
);
|
|
|
|
|
2024-05-15 13:59:34 +00:00
|
|
|
int hcl_scfmtcallstack (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_ooi_t nargs
|
|
|
|
);
|
|
|
|
|
2020-10-08 09:25:54 +00:00
|
|
|
/* ========================================================================= */
|
|
|
|
/* comp.c */
|
|
|
|
/* ========================================================================= */
|
|
|
|
int hcl_emitbyteinstruction (
|
|
|
|
hcl_t* hcl,
|
|
|
|
hcl_oob_t bc
|
|
|
|
);
|
|
|
|
|
2024-07-15 09:52:57 +00:00
|
|
|
int hcl_copy_string_to (
|
|
|
|
hcl_t* hcl,
|
|
|
|
const hcl_oocs_t* src,
|
|
|
|
hcl_oocs_t* dst,
|
|
|
|
hcl_oow_t* dstcapa,
|
|
|
|
int append,
|
|
|
|
hcl_ooch_t delim_char
|
|
|
|
);
|
|
|
|
|
2021-01-09 16:53:35 +00:00
|
|
|
/* ========================================================================= */
|
|
|
|
/* cnode.c */
|
|
|
|
/* ========================================================================= */
|
2024-08-20 16:00:29 +00:00
|
|
|
hcl_cnode_t* hcl_makecnode (hcl_t* hcl, hcl_cnode_type_t type, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
2023-11-27 16:44:13 +00:00
|
|
|
hcl_cnode_t* hcl_makecnodenil (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
2024-01-07 15:38:42 +00:00
|
|
|
hcl_cnode_t* hcl_makecnodetrue (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
|
|
|
hcl_cnode_t* hcl_makecnodefalse (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
|
|
|
hcl_cnode_t* hcl_makecnodeself (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
|
|
|
hcl_cnode_t* hcl_makecnodesuper (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
|
|
|
hcl_cnode_t* hcl_makecnodeellipsis (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
|
|
|
hcl_cnode_t* hcl_makecnodetrpcolons (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
2024-02-03 16:57:53 +00:00
|
|
|
hcl_cnode_t* hcl_makecnodedblcolons (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
2024-05-26 14:18:26 +00:00
|
|
|
hcl_cnode_t* hcl_makecnodecolon (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
2024-02-03 09:59:17 +00:00
|
|
|
hcl_cnode_t* hcl_makecnodecolongt (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
|
|
|
hcl_cnode_t* hcl_makecnodecolonlt (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
2024-01-25 14:48:06 +00:00
|
|
|
hcl_cnode_t* hcl_makecnodecharlit (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok, hcl_ooch_t v);
|
|
|
|
hcl_cnode_t* hcl_makecnodebchrlit (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok, hcl_oob_t v);
|
2024-01-07 15:38:42 +00:00
|
|
|
hcl_cnode_t* hcl_makecnodesymbol (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
|
|
|
hcl_cnode_t* hcl_makecnodedsymbol (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok, int is_cla);
|
|
|
|
hcl_cnode_t* hcl_makecnodestrlit (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
2024-01-25 14:48:06 +00:00
|
|
|
hcl_cnode_t* hcl_makecnodebstrlit (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
2024-09-04 16:12:20 +00:00
|
|
|
hcl_cnode_t* hcl_makecnodesymlit (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
2024-01-07 15:38:42 +00:00
|
|
|
hcl_cnode_t* hcl_makecnodenumlit (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
|
|
|
hcl_cnode_t* hcl_makecnoderadnumlit (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
|
|
|
hcl_cnode_t* hcl_makecnodefpdeclit (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
|
|
|
hcl_cnode_t* hcl_makecnodesmptrlit (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok, hcl_oow_t v);
|
|
|
|
hcl_cnode_t* hcl_makecnodeerrlit (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok, hcl_ooi_t v);
|
2023-11-27 16:44:13 +00:00
|
|
|
hcl_cnode_t* hcl_makecnodecons (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok, hcl_cnode_t* car, hcl_cnode_t* cdr);
|
|
|
|
hcl_cnode_t* hcl_makecnodeelist (hcl_t* hcl, int flags, const hcl_loc_t* loc, hcl_concode_t type);
|
|
|
|
hcl_cnode_t* hcl_makecnodeshell (hcl_t* hcl, int flags, const hcl_loc_t* loc, hcl_cnode_t* obj);
|
2021-01-13 09:54:44 +00:00
|
|
|
void hcl_freesinglecnode (hcl_t* hcl, hcl_cnode_t* c);
|
2021-01-19 14:07:42 +00:00
|
|
|
hcl_oow_t hcl_countcnodecons (hcl_t* hcl, hcl_cnode_t* cons);
|
2023-11-12 12:54:17 +00:00
|
|
|
void hcl_dumpcnode (hcl_t* hcl, hcl_cnode_t* c, int newline);
|
2021-01-09 16:53:35 +00:00
|
|
|
|
2021-02-01 13:20:46 +00:00
|
|
|
|
2024-07-14 16:02:07 +00:00
|
|
|
/* ========================================================================= */
|
|
|
|
/* read.c */
|
|
|
|
/* ========================================================================= */
|
|
|
|
int hcl_is_binop_char (hcl_ooci_t c);
|
|
|
|
|
2021-02-01 13:20:46 +00:00
|
|
|
/* ========================================================================= */
|
|
|
|
/* exec.c */
|
|
|
|
/* ========================================================================= */
|
2024-08-07 16:52:50 +00:00
|
|
|
int hcl_class_responds_to (hcl_t* hcl, hcl_oop_t rcv, hcl_oop_t msg);
|
|
|
|
int hcl_inst_responds_to (hcl_t* hcl, hcl_oop_t rcv, hcl_oop_t msg);
|
|
|
|
|
2021-05-15 11:19:52 +00:00
|
|
|
hcl_pfrc_t hcl_pf_process_current (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs);
|
2021-02-01 13:20:46 +00:00
|
|
|
hcl_pfrc_t hcl_pf_process_fork (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs);
|
|
|
|
hcl_pfrc_t hcl_pf_process_resume (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs);
|
|
|
|
hcl_pfrc_t hcl_pf_process_suspend (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs);
|
2021-05-15 11:19:52 +00:00
|
|
|
hcl_pfrc_t hcl_pf_process_terminate (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs);
|
|
|
|
hcl_pfrc_t hcl_pf_process_terminate_all (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs);
|
2021-02-01 13:20:46 +00:00
|
|
|
hcl_pfrc_t hcl_pf_process_yield (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs);
|
2021-02-03 14:50:51 +00:00
|
|
|
|
2021-02-05 15:22:39 +00:00
|
|
|
hcl_pfrc_t hcl_pf_semaphore_new (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs);
|
2021-02-03 14:50:51 +00:00
|
|
|
hcl_pfrc_t hcl_pf_semaphore_wait (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs);
|
2021-02-05 15:22:39 +00:00
|
|
|
hcl_pfrc_t hcl_pf_semaphore_signal (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs);
|
2021-02-03 14:50:51 +00:00
|
|
|
hcl_pfrc_t hcl_pf_semaphore_signal_timed (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs);
|
|
|
|
hcl_pfrc_t hcl_pf_semaphore_signal_on_input (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs);
|
|
|
|
hcl_pfrc_t hcl_pf_semaphore_signal_on_output (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs);
|
2021-02-07 17:57:35 +00:00
|
|
|
/*hcl_pfrc_t hcl_pf_semaphore_signal_on_gcfin (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs);*/
|
2021-02-03 14:50:51 +00:00
|
|
|
hcl_pfrc_t hcl_pf_semaphore_unsignal (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs);
|
|
|
|
|
2021-02-05 15:22:39 +00:00
|
|
|
hcl_pfrc_t hcl_pf_semaphore_group_new (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs);
|
2021-02-03 14:50:51 +00:00
|
|
|
hcl_pfrc_t hcl_pf_semaphore_group_add_semaphore (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs);
|
|
|
|
hcl_pfrc_t hcl_pf_semaphore_group_remove_semaphore (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs);
|
|
|
|
hcl_pfrc_t hcl_pf_semaphore_group_wait (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs);
|
2021-02-01 13:20:46 +00:00
|
|
|
|
2024-02-19 11:48:14 +00:00
|
|
|
/* ========================================================================= */
|
|
|
|
/* std.c */
|
|
|
|
/* ========================================================================= */
|
|
|
|
hcl_errnum_t hcl_syserrstrb (hcl_t* hcl, int syserr_type, int syserr_code, hcl_bch_t* buf, hcl_oow_t len);
|
2023-12-27 00:09:40 +00:00
|
|
|
|
2016-09-28 14:40:37 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|