2 * Copyright (C) 2024 Mikulas Patocka
4 * This file is part of Ajla.
6 * Ajla is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, either version 3 of the License, or (at your option) any later
11 * Ajla is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along with
16 * Ajla. If not, see <https://www.gnu.org/licenses/>.
24 #define pcode_get_type name(pcode_get_type)
25 #define pcode_generate_blob_from_value name(pcode_generate_blob_from_value)
26 #define pcode_build_function_from_builtin name(pcode_build_function_from_builtin)
27 #define pcode_build_function_from_array name(pcode_build_function_from_array)
28 #define pcode_array_from_builtin name(pcode_array_from_builtin)
29 #define pcode_build_eval_function name(pcode_build_eval_function)
30 #define pcode_find_op_function name(pcode_find_op_function)
31 #define pcode_find_is_exception name(pcode_find_is_exception)
32 #define pcode_find_get_exception name(pcode_find_get_exception)
33 #define pcode_find_array_load_function name(pcode_find_array_load_function)
34 #define pcode_find_array_len_function name(pcode_find_array_len_function)
35 #define pcode_find_array_len_greater_than_function name(pcode_find_array_len_greater_than_function)
36 #define pcode_find_array_sub_function name(pcode_find_array_sub_function)
37 #define pcode_find_array_skip_function name(pcode_find_array_skip_function)
38 #define pcode_find_array_append_function name(pcode_find_array_append_function)
39 #define pcode_find_option_ord_function name(pcode_find_option_ord_function)
40 #define pcode_find_record_option_load_function name(pcode_find_record_option_load_function)
42 #define Op_IsBool(op) ((op) == Bin_Equal || (op) == Bin_NotEqual || (op) == Bin_Less || (op) == Bin_LessEqual || (op) == Bin_Bt || (op) == Un_IsException)
43 #define Op_IsInt(op) ((op) == Un_ConvertToInt || (op) == Un_ExceptionClass || (op) == Un_ExceptionType || (op) == Un_ExceptionAux)
44 #define Op_IsBinary(op) ((op) >= Bin_Add && (op) <= Bin_Bt)
45 #define Op_IsUnary(op) ((op) >= Un_Not && (op) <= Un_SystemProperty)
47 const struct type
*pcode_get_type(pcode_t q
);
48 bool pcode_generate_blob_from_value(pointer_t ptr
, pcode_t pcode_type
, pcode_t
**res_blob
, size_t *res_len
, ajla_error_t
*err
);
49 void *pcode_build_function_from_builtin(frame_s
*f
, const code_t
*ip
, union internal_arg arguments
[]);
50 void *pcode_build_function_from_array(frame_s
*fp
, const code_t
*ip
, union internal_arg arguments
[]);
51 void *pcode_array_from_builtin(frame_s
*fp
, const code_t
*ip
, union internal_arg arguments
[]);
52 pointer_t
pcode_build_eval_function(pcode_t src_type
, pcode_t dest_type
, pcode_t op
, pcode_t
*blob_1
, size_t blob_1_len
, pcode_t
*blob_2
, size_t blob_2_len
, ajla_error_t
*err
);
54 #define PCODE_FIND_OP_UNARY 0x1
55 #define PCODE_CONVERT_FROM_INT 0x2
56 void * attr_fastcall
pcode_find_op_function(const struct type
*type
, const struct type
*rtype
, code_t code
, unsigned flags
, frame_s
*fp
, const code_t
*ip
, pointer_t
**result
);
57 void * attr_fastcall
pcode_find_is_exception(frame_s
*fp
, const code_t
*ip
, pointer_t
**result
);
58 void * attr_fastcall
pcode_find_get_exception(unsigned mode
, frame_s
*fp
, const code_t
*ip
, pointer_t
**result
);
60 void * attr_fastcall
pcode_find_array_load_function(frame_s
*fp
, const code_t
*ip
, pointer_t
**result
);
61 void * attr_fastcall
pcode_find_array_len_function(frame_s
*fp
, const code_t
*ip
, pointer_t
**result
);
62 void * attr_fastcall
pcode_find_array_len_greater_than_function(frame_s
*fp
, const code_t
*ip
, pointer_t
**result
);
63 void * attr_fastcall
pcode_find_array_sub_function(frame_s
*fp
, const code_t
*ip
, pointer_t
**result
);
64 void * attr_fastcall
pcode_find_array_skip_function(frame_s
*fp
, const code_t
*ip
, pointer_t
**result
);
65 void * attr_fastcall
pcode_find_array_append_function(frame_s
*fp
, const code_t
*ip
, pointer_t
**result
);
66 void * attr_fastcall
pcode_find_option_ord_function(frame_s
*fp
, const code_t
*ip
, pointer_t
**result
);
68 #define PCODE_FUNCTION_RECORD_LOAD 0
69 #define PCODE_FUNCTION_OPTION_LOAD 1
70 #define PCODE_FUNCTION_OPTION_TEST 2
71 void * attr_fastcall
pcode_find_record_option_load_function(unsigned char tag
, frame_t slot
, frame_s
*fp
, const code_t
*ip
, pointer_t
**result
);