Native Functions
Last updated
Last updated
Defined in ./src/types/types.d.ts
, a C0Native object represents a native function in the C0 Virtual Machine that can be called during the runtime.
Specifically, the property of f
represents the code of native function that can be dynamically loaded during runtime.
The function header of f
is defined as
This means f
will take a bunch of react hooks to update the react state (e.g. printout value), a memory allocator (to allocate or extract value from heap memory), and several (1 to more) C0Value arguments.
In original C0VM, a bunch of native functions are implemented in C and connected to C0VM to support the system calls (e.g. receive user input, etc.).
The list of native functions is listed below:
- Currently Support
- Development in Progress, will be supported
- No Recent Plan for implementation
NATIVE_ARGS_FLAG
NATIVE_ARGS_INT
NATIVE_ARGS_PARSE
NATIVE_ARGS_STRING
NATIVE_EOF
NATIVE_FLUSH
NATIVE_PRINT
NATIVE_PRINTBOOL
NATIVE_PRINTCHAR
NATIVE_PRINTINT
NATIVE_PRINTLN
NATIVE_READLINE
There are no recent plans to implement native functions in this category (
NATIVE_INDEX = [12, 54]
)
We will not support this since there is no
double
type in C0/C1 language. (NATIVE_INDEX=[55, 62)
)
There are no recent plans to implement native functions in this category (
NATIVE_INDEX=[62, 67)
)
We will not support this since there is no
float
type in C0/C1 language. (NATIVE_INDEX=[67, 77)
)
NATIVE_PRINT_HEX
NATIVE_PRINT_INT
There are no recent plans to implement native functions in this category (
NATIVE_INDEX = [77, 85)
)
NATIVE_INT_TOKENS
NATIVE_NUM_TOKENS
NATIVE_PARSE_BOOL
NATIVE_PARSE_INT
NATIVE_PARSE_INTS
NATIVE_PARSE_TOKENS
NATIVE_CHAR_CHR
NATIVE_CHAR_ORD
NATIVE_STRING_CHARAT
NATIVE_STRING_COMPARE
NATIVE_STRING_EQUAL
NATIVE_STRING_FROM_CHARARRAY
NATIVE_STRING_FROMBOOL
NATIVE_STRING_FROMCHAR
NATIVE_STRING_FROMINT
NATIVE_STRING_JOIN
NATIVE_STRING_LENGTH
NATIVE_STRING_SUB
NATIVE_STRING_TERMINATED
NATIVE_STRING_TO_CHARARRAY
NATIVE_STRING_TOLOWER
(Always return true
since there's no file read in C0VM.ts)
(Always return true
since there's no "buffering" in React UI Update)