2#include "unordered_dense.h"
38#define NATIVE_CC LLVMCallConv::LLVMWin64CallConv
40#define NATIVE_CC LLVMCallConv::LLVMX8664SysVCallConv
59 return ankerl::unordered_dense::detail::wyhash::hash(sv.data(), sv.size());
62 return ankerl::unordered_dense::detail::wyhash::hash(str.get(), std::string_view{ str.get() }.size());
72 bool operator()(std::unique_ptr<
char[]>
const& l, std::unique_ptr<
char[]>
const& r)
const noexcept {
73 return std::string_view{ l.get() } == std::string_view{ r.get() };
75 bool operator()(std::unique_ptr<
char[]>
const& l, std::string_view r)
const noexcept {
76 return std::string_view{ l.get() } == r;
78 bool operator()(std::string_view r, std::unique_ptr<
char[]>
const& l)
const noexcept {
79 return std::string_view{ l.get() } == r;
81 bool operator()(std::unique_ptr<
char[]>
const& l, std::string
const& r)
const noexcept {
82 return std::string_view{ l.get() } == r;
84 bool operator()(std::string
const& r, std::unique_ptr<
char[]>
const& l)
const noexcept {
85 return std::string_view{ l.get() } == r;
91#define LLVMValueRef void*
92#define LLVMBasicBlockRef void*
93#define LLVMTypeRef void*
139 virtual std::unique_ptr< state_stack>
copy()
const = 0;
140 virtual void resize(
size_t main_sz,
size_t return_sz) = 0;
197 virtual void resize(
size_t main_sz,
size_t return_sz)
override {
205 virtual int64_t
main_data(
size_t index)
const override {
292 virtual std::unique_ptr<state_stack>
copy()
const override {
293 auto temp_new = std::make_unique<llvm_stack>(*
this);
314 virtual void resize(
size_t main_sz,
size_t return_sz)
override {
320 virtual int64_t
main_data(
size_t index)
const override {
397 virtual std::unique_ptr<state_stack>
copy()
const override {
398 auto temp_new = std::make_unique<type_stack>(*
this);
428using word_types = std::variant<interpreted_word_instance, compiled_word_instance>;
504 ankerl::unordered_dense::map<std::string, int32_t>
words;
505 ankerl::unordered_dense::map<std::string, int32_t>
types;
582 type_array.push_back(
type{
nullptr,
nullptr,
nullptr, 0, 0, 0, 0 });
584 type_array.push_back(
type{
nullptr,
nullptr,
nullptr, 0, 0, 0, 0 });
586 type_array.push_back(
type{
nullptr,
nullptr,
nullptr, 0, 0, 0, 0 });
588 type_array.push_back(
type{
nullptr,
nullptr,
nullptr, 0, 0, 0, 0 });
590 type_array.push_back(
type{
nullptr,
nullptr,
nullptr, 0, 0, 0, 0 });
592 type_array.push_back(
type{
nullptr,
nullptr,
nullptr, 0, 0, 0, 0 });
594 type_array.push_back(
type{
nullptr,
nullptr,
nullptr, 0, 0, 0, 0 });
596 type_array.push_back(
type{
nullptr,
nullptr,
nullptr, 0, 0, 0, 0 });
598 type_array.push_back(
type{
nullptr,
nullptr,
nullptr, 0, 0, 0, 0 });
600 type_array.push_back(
type{
nullptr,
nullptr,
nullptr, 0, 0, 0, 0 });
602 type_array.push_back(
type{
nullptr,
nullptr,
nullptr, 0, 0, 0, 0 });
604 type_array.push_back(
type{
nullptr,
nullptr,
nullptr, 0, 0, 0, 0 });
606 type_array.push_back(
type{
nullptr,
nullptr,
nullptr, 0, 0, 0, 0 });
608 type_array.push_back(
type{
nullptr,
nullptr,
nullptr, 1, 0, 0, 0 });
609 types.insert_or_assign(std::string(
"opaque_ptr"),
fif_nil);
610 type_array.push_back(
type{
nullptr,
nullptr,
nullptr, 0, 0, 0, 0 });
612 type_array.push_back(
type{
nullptr,
nullptr,
nullptr, 0, 0, 0, 0 });
699 std::unique_ptr<opaque_compiler_data>
data;
758 char* llvm_target_triple =
nullptr;
759 char* llvm_target_cpu =
nullptr;
760 char* llvm_target_cpu_features =
nullptr;
768 std::function<void(std::string_view)>
report_error = [](std::string_view) { std::abort(); };
781 if(llvm_target_machine)
794 return std::string_view{ it->get() };
796 std::unique_ptr<char[]> temp = std::unique_ptr<char[]>(
new char[data.length() + 1 ]);
797 memcpy(temp.get(), data.data(), data.length());
798 temp.get()[data.length()] = 0;
799 auto data_ptr = temp.get();
801 return std::string_view{ data_ptr };
807 ankerl::unordered_dense::map<std::string, std::unique_ptr<var_data>>
global_vars;
808 ankerl::unordered_dense::map<std::string, std::unique_ptr<let_data>>
global_lets;
819 return it->second.get();
825 if(it->second->type ==
type)
826 return it->second.get();
830 auto added =
global_vars.insert_or_assign(name, std::make_unique<var_data>());
831 added.first->second->type =
type;
832 added.first->second->data = 0;
837 return added.first->second.get();
841 return it->second.get();
849 auto added =
global_lets.insert_or_assign(name, std::make_unique<let_data>());
850 added.first->second->type =
type;
851 added.first->second->data = data;
852 added.first->second->expression = expression;
854 return it->second.get();
867 LLVMInitializeNativeTarget();
868 LLVMInitializeNativeAsmPrinter();
875 llvm_target_machine =
LLVMCreateTargetMachine(llvm_target, llvm_target_triple, llvm_target_cpu, llvm_target_cpu_features, LLVMCodeGenOptLevel::LLVMCodeGenLevelAggressive, LLVMRelocMode::LLVMRelocDefault, LLVMCodeModel::LLVMCodeModelJITDefault);
881 dict.ready_llvm_types(llvm_context);
884 compiler_stack.push_back(std::make_unique<compiler_globals_layer>(
nullptr, *
this));
912 virtual void resize(
size_t main_sz,
size_t return_sz)
override {
921 virtual int64_t
main_data(
size_t index)
const override {
1011 virtual std::unique_ptr<state_stack>
copy()
const override {
1012 auto temp_new = std::make_unique< interpreter_stack>(*
this);
1013 temp_new->min_main_depth =
main_types.size();
1024 return "@unknown (" + std::to_string(w) +
")";
1028 e->
report_error(
"attempted to perform an illegal operation under interpretation");
1047 while(start < end) {
1048 if(!isdigit(*start))
1065 auto const decimal = std::find(start, end,
'.');
1066 if(decimal == end) {
1068 }
else if(decimal == start) {
1075inline bool is_fp(
char const* start,
char const* end) {
1085 static double const e[] = {
1086 1e+0, 1e+1, 1e+2, 1e+3, 1e+4, 1e+5, 1e+6, 1e+7, 1e+8, 1e+9, 1e+10, 1e+11, 1e+12, 1e+13, 1e+14, 1e+15, 1e+16, 1e+17, 1e+18,
1087 1e+19, 1e+20, 1e+21, 1e+22, 1e+23, 1e+24, 1e+25, 1e+26, 1e+27, 1e+28, 1e+29, 1e+30, 1e+31, 1e+32, 1e+33, 1e+34, 1e+35,
1088 1e+36, 1e+37, 1e+38, 1e+39, 1e+40, 1e+41, 1e+42, 1e+43, 1e+44, 1e+45, 1e+46, 1e+47, 1e+48, 1e+49, 1e+50, 1e+51, 1e+52,
1089 1e+53, 1e+54, 1e+55, 1e+56, 1e+57, 1e+58, 1e+59, 1e+60, 1e+61, 1e+62, 1e+63, 1e+64, 1e+65, 1e+66, 1e+67, 1e+68, 1e+69,
1090 1e+70, 1e+71, 1e+72, 1e+73, 1e+74, 1e+75, 1e+76, 1e+77, 1e+78, 1e+79, 1e+80, 1e+81, 1e+82, 1e+83, 1e+84, 1e+85, 1e+86,
1091 1e+87, 1e+88, 1e+89, 1e+90, 1e+91, 1e+92, 1e+93, 1e+94, 1e+95, 1e+96, 1e+97, 1e+98, 1e+99, 1e+100, 1e+101, 1e+102, 1e+103,
1092 1e+104, 1e+105, 1e+106, 1e+107, 1e+108, 1e+109, 1e+110, 1e+111, 1e+112, 1e+113, 1e+114, 1e+115, 1e+116, 1e+117, 1e+118,
1093 1e+119, 1e+120, 1e+121, 1e+122, 1e+123, 1e+124, 1e+125, 1e+126, 1e+127, 1e+128, 1e+129, 1e+130, 1e+131, 1e+132, 1e+133,
1094 1e+134, 1e+135, 1e+136, 1e+137, 1e+138, 1e+139, 1e+140, 1e+141, 1e+142, 1e+143, 1e+144, 1e+145, 1e+146, 1e+147, 1e+148,
1095 1e+149, 1e+150, 1e+151, 1e+152, 1e+153, 1e+154, 1e+155, 1e+156, 1e+157, 1e+158, 1e+159, 1e+160, 1e+161, 1e+162, 1e+163,
1096 1e+164, 1e+165, 1e+166, 1e+167, 1e+168, 1e+169, 1e+170, 1e+171, 1e+172, 1e+173, 1e+174, 1e+175, 1e+176, 1e+177, 1e+178,
1097 1e+179, 1e+180, 1e+181, 1e+182, 1e+183, 1e+184, 1e+185, 1e+186, 1e+187, 1e+188, 1e+189, 1e+190, 1e+191, 1e+192, 1e+193,
1098 1e+194, 1e+195, 1e+196, 1e+197, 1e+198, 1e+199, 1e+200, 1e+201, 1e+202, 1e+203, 1e+204, 1e+205, 1e+206, 1e+207, 1e+208,
1099 1e+209, 1e+210, 1e+211, 1e+212, 1e+213, 1e+214, 1e+215, 1e+216, 1e+217, 1e+218, 1e+219, 1e+220, 1e+221, 1e+222, 1e+223,
1100 1e+224, 1e+225, 1e+226, 1e+227, 1e+228, 1e+229, 1e+230, 1e+231, 1e+232, 1e+233, 1e+234, 1e+235, 1e+236, 1e+237, 1e+238,
1101 1e+239, 1e+240, 1e+241, 1e+242, 1e+243, 1e+244, 1e+245, 1e+246, 1e+247, 1e+248, 1e+249, 1e+250, 1e+251, 1e+252, 1e+253,
1102 1e+254, 1e+255, 1e+256, 1e+257, 1e+258, 1e+259, 1e+260, 1e+261, 1e+262, 1e+263, 1e+264, 1e+265, 1e+266, 1e+267, 1e+268,
1103 1e+269, 1e+270, 1e+271, 1e+272, 1e+273, 1e+274, 1e+275, 1e+276, 1e+277, 1e+278, 1e+279, 1e+280, 1e+281, 1e+282, 1e+283,
1104 1e+284, 1e+285, 1e+286, 1e+287, 1e+288, 1e+289, 1e+290, 1e+291, 1e+292, 1e+293, 1e+294, 1e+295, 1e+296, 1e+297, 1e+298,
1105 1e+299, 1e+300, 1e+301, 1e+302, 1e+303, 1e+304, 1e+305, 1e+306, 1e+307, 1e+308 };
1113 int32_t magnitude = 0;
1114 int64_t accumulated = 0;
1115 bool after_decimal =
false;
1122 bool is_negative =
false;
1126 }
else if(*start ==
'+') {
1130 for(; start < end; ++start) {
1131 if(*start >=
'0' && *start <=
'9') {
1132 accumulated = accumulated * 10 + (*start -
'0');
1133 magnitude += int32_t(after_decimal);
1134 }
else if(*start ==
'.') {
1135 after_decimal =
true;
1142 float_out = float(
double(accumulated) /
pow_10(magnitude));
1144 float_out = float(accumulated);
1147 float_out = -float(
double(accumulated) /
pow_10(magnitude));
1149 float_out = -float(accumulated);
1156 auto result = std::from_chars(content.data(), content.data() + content.length(), rvalue);
1157 if(result.ec == std::errc::invalid_argument) {
1163 float rvalue = 0.0f;
1164 if(!
float_from_chars(content.data(), content.data() + content.length(), rvalue)) {
1179 std::vector<LLVMValueRef> zvals;
1180 for(int32_t j = 1; j < e->
dict.
type_array[t].decomposed_types_count; ++j) {
1204 auto child_index = e->
dict.
type_array[t].decomposed_types_start + 1 + 0;
1207 return e->
dict.
type_array[child_type].interpreter_zero(child_type, e);
1212 auto mem = (
char*)malloc(bytes);
1213 memset(mem, 0, bytes);
1214 return (int64_t)mem;
1219 if(desc.size() == 0)
1221 if(desc.size() == 1)
1223 if(desc[1] != std::numeric_limits<int32_t>::max())
1226 while(i < desc.size() && desc[i] != -1) {
1229 if(i < desc.size() && desc[i] == -1)
1240 std::vector<int32_t> type_subs_out;
1241 while(match_pos < desc.size()) {
1242 if(mem_count > final_subtype_list.size()) {
1243 env.
report_error(
"attempted to instantiate a struct template with the wrong number of members");
1248 auto mr =
fill_in_variable_types(final_subtype_list[mem_count], desc.subspan(match_pos), type_subs_out, env);
1249 if(!mr.match_result) {
1250 env.
report_error(
"attempted to instantiate a struct template with types that do not match its definition");
1258 if(mem_count < final_subtype_list.size()) {
1259 env.
report_error(
"attempted to instantiate a struct template with the wrong number of members");
1265 if(env.
dict.
type_array[i].decomposed_types_count == int32_t(final_subtype_list.size() + 1)) {
1269 for(
uint32_t j = 0; match && j < final_subtype_list.size(); ++j) {
1283 std::vector<LLVMTypeRef> ctypes;
1284 for(
uint32_t j = 0; j < final_subtype_list.size(); ++j) {
1285 ctypes.push_back(env.
dict.
type_array[final_subtype_list[j]].llvm_type);
1287 for(int32_t j = 0; j < env.
dict.
type_array[template_base].non_member_types; ++j)
1290 if(ctypes.size() != 1) {
1291 std::string autoname =
"struct#" + std::to_string(env.
dict.
type_array.size());
1310 if(ctypes.size() == 1)
1323 std::vector<int32_t> final_subtype_list;
1324 final_subtype_list.push_back(template_base);
1329 while(match_pos < desc.size()) {
1331 match_pos += mresult.end_match_pos;
1332 final_subtype_list.push_back(mresult.type);
1336 if(env.
dict.
type_array[i].decomposed_types_count == int32_t(final_subtype_list.size())) {
1340 for(
uint32_t j = 0; j < final_subtype_list.size(); ++j) {
1355 std::vector<LLVMTypeRef> ctypes;
1356 for(
uint32_t j = 1; j < final_subtype_list.size(); ++j) {
1357 ctypes.push_back(env.
dict.
type_array[final_subtype_list[j]].llvm_type);
1359 for(int32_t j = 0; j < env.
dict.
type_array[template_base].non_member_types; ++j)
1362 if(ctypes.size() != 1) {
1363 std::string autoname =
"struct#" + std::to_string(env.
dict.
type_array.size());
1383 if(ctypes.size() == 1)
1392inline int32_t
make_struct_type(std::string_view name, std::span<int32_t const> subtypes, std::vector<std::string_view>
const& member_names,
environment& env, int32_t template_types, int32_t extra_count) {
1396 env.
dict.
types.insert_or_assign(std::string(name), new_type);
1398 if(template_types == 0 && extra_count == 0) {
1399 std::vector<LLVMTypeRef> ctypes;
1400 for(
uint32_t j = 0; j < subtypes.size(); ++j) {
1403 if(ctypes.size() != 1) {
1404 std::string autoname =
"struct#" + std::to_string(env.
dict.
type_array.size());
1428 env.
dict.
type_array.back().decomposed_types_count =
uint32_t(subtypes.size() + (template_types + extra_count == 0 ? 1 : extra_count));
1431 auto add_child_types = [&]() {
1432 if(template_types + extra_count > 0) {
1435 for(int32_t e = 0; e < extra_count; ++e) {
1443 if(template_types + extra_count > 0)
1448 if(subtypes.size() == 1)
1452 env.
dict.
type_array.back().type_slots = template_types + extra_count;
1453 if(template_types + extra_count == 0)
1456 for(int32_t e = 0; e < extra_count; ++e) {
1473 auto bury_word = [&](std::string
const& name, int32_t id) {
1474 int32_t start_word = 0;
1475 int32_t preceding_word = -1;
1477 start_word = it->second;
1479 env.
dict.
words.insert_or_assign(name,
id);
1483 preceding_word = start_word;
1486 if(preceding_word == -1) {
1487 env.
dict.
words.insert_or_assign(name,
id);
1489 assert(
id != start_word);
1493 assert(
id != start_word);
1499 env.
dict.
word_array.back().source = std::string(
"struct-map2 copy");
1501 env.
dict.
word_array.back().stack_types_count = end_two - start_types;
1507 env.
dict.
word_array.back().source = std::string(
"struct-map2 dup");
1509 env.
dict.
word_array.back().stack_types_count = end_two - start_types;
1515 env.
dict.
word_array.back().source = std::string(
"struct-map1 init");
1517 env.
dict.
word_array.back().stack_types_count = end_one - start_types;
1523 env.
dict.
word_array.back().source = std::string(
"struct-map0 drop");
1525 env.
dict.
word_array.back().stack_types_count = end_zero - start_types;
1531 auto desc = subtypes;
1532 while(desc.size() > 0) {
1545 env.
dict.
word_array.back().source = std::string(
"forth.extract ") + std::to_string(index);
1547 env.
dict.
word_array.back().stack_types_count = end_types_i - start_types_i;
1550 bury_word(std::string(
".") + std::string{ member_names[index] }, int32_t(env.
dict.
word_array.size() - 1));
1564 env.
dict.
word_array.back().source = std::string(
"forth.extract-copy ") + std::to_string(index);
1566 env.
dict.
word_array.back().stack_types_count = end_types_i - start_types_i;
1569 bury_word(std::string(
".") + std::string{ member_names[index] } +
"@", int32_t(env.
dict.
word_array.size() - 1));
1583 env.
dict.
word_array.back().source = std::string(
"forth.insert ") + std::to_string(index);
1585 env.
dict.
word_array.back().stack_types_count = end_types_i - start_types_i;
1588 bury_word(std::string(
".") + std::string{ member_names[index] } +
"!", int32_t(env.
dict.
word_array.size() - 1));
1606 env.
dict.
word_array.back().source = std::string(
"forth.gep ") + std::to_string(index);
1608 env.
dict.
word_array.back().stack_types_count = end_types_i - start_types_i;
1611 bury_word(std::string(
".") + std::string{ member_names[index] }, int32_t(env.
dict.
word_array.size() - 1));
1615 desc = desc.subspan(next);
1623 if(
text.starts_with(
"ptr(nil)")) {
1626 for(; mt_end <
text.size(); ++mt_end) {
1627 if(
text[mt_end] ==
'(' ||
text[mt_end] ==
')' ||
text[mt_end] ==
',')
1631 if(
text.size() > 0 &&
text[0] ==
'$') {
1634 if(type_subs && v >= 0 &&
size_t(v) < type_subs->size()) {
1635 return type_match{ (*type_subs)[v], mt_end };
1640 if(
text.substr(0, mt_end) ==
"struct") {
1644 if(mt_end >=
text.size() ||
text[mt_end] ==
',' ||
text[mt_end] ==
')') {
1649 std::vector<int32_t> subtypes;
1650 while(mt_end <
text.size() &&
text[mt_end] !=
')') {
1652 subtypes.push_back(sub_match.type);
1653 mt_end += sub_match.end_match_pos;
1654 if(mt_end <
text.size() &&
text[mt_end] ==
',')
1657 if(mt_end <
text.size() &&
text[mt_end] ==
')')
1660 if(env.
dict.
type_array[it->second].type_slots != int32_t(subtypes.size())) {
1661 env.
report_error(
"attempted to instantiate a type with the wrong number of parameters");
1664 }
else if(env.
dict.
type_array[it->second].is_struct_template()) {
1668 if(env.
dict.
type_array[i].decomposed_types_count == int32_t(1 + subtypes.size())) {
1672 for(
uint32_t j = 0; j < subtypes.size(); ++j) {
1696 for(
auto t : subtypes) {
1721 if(
text.starts_with(
"ptr(nil)")) {
1726 for(; mt_end <
text.size(); ++mt_end) {
1727 if(
text[mt_end] ==
'(' ||
text[mt_end] ==
')' ||
text[mt_end] ==
',')
1731 if(
text.size() > 0 &&
text[0] ==
'$') {
1742 if(mt_end >=
text.size() ||
text[mt_end] ==
',' ||
text[mt_end] ==
')') {
1748 r.
type_array.push_back(std::numeric_limits<int32_t>::max());
1750 std::vector<type_span_gen_result> sub_matches;
1751 while(mt_end <
text.size() &&
text[mt_end] !=
')') {
1754 sub_matches.push_back(std::move(sub_match));
1755 mt_end += sub_match.end_match_pos;
1756 if(mt_end <
text.size() &&
text[mt_end] ==
',')
1760 for(
auto v : desc) {
1762 auto index = -(v + 2);
1763 if(
size_t(index) < sub_matches.size()) {
1764 r.
type_array.insert(r.
type_array.end(), sub_matches[index].type_array.begin(), sub_matches[index].type_array.end());
1774 while(mt_end <
text.size() &&
text[mt_end] !=
')') {
1776 r.
type_array.insert(r.
type_array.end(), sub_match.type_array.begin(), sub_match.type_array.end());
1778 mt_end += sub_match.end_match_pos;
1779 if(mt_end <
text.size() &&
text[mt_end] ==
',')
1784 if(mt_end <
text.size() &&
text[mt_end] ==
')')
1789 std::vector<int32_t> type_subs;
1799 auto make_sub = [&](int32_t type_in) {
1801 auto slot = -(type_in + 2);
1802 if(slot < int32_t(type_subs.size()))
1803 return type_subs[slot];
1809 if(tlist.size() == 0) {
1812 if(tlist.size() == 1) {
1815 if(tlist[1] != std::numeric_limits<int32_t>::max()) {
1818 int32_t base_type = tlist[0];
1823 std::vector<int32_t> subtypes;
1824 while(mt_end < tlist.size() && tlist[mt_end] != -1) {
1826 subtypes.push_back(sub_match.type);
1827 mt_end += sub_match.end_match_pos;
1829 if(mt_end < tlist.size() && tlist[mt_end] == -1)
1833 if(base_type ==
fif_ptr && !subtypes.empty() && subtypes[0] ==
fif_nil) {
1839 if(env.
dict.
type_array[i].decomposed_types_count == int32_t(1 + subtypes.size())) {
1843 for(
uint32_t j = 0; j < subtypes.size(); ++j) {
1868 for(
auto t : subtypes) {
1877 if(match_span.size() == 0)
1880 auto match_to_slot = [&](int32_t matching_type, int32_t matching_against) {
1881 if(matching_type < -1) {
1882 auto slot = -(matching_type + 2);
1883 if(slot >= int32_t(type_subs.size())) {
1884 type_subs.resize(
size_t(slot + 1), -2);
1885 type_subs[slot] = matching_against;
1887 }
else if(type_subs[slot] == -2 || type_subs[slot] == matching_against) {
1888 type_subs[slot] = matching_against;
1894 return matching_type == matching_against;
1898 if(match_span.size() == 1) {
1902 if(match_span[1] != std::numeric_limits<int32_t>::max()) {
1908 std::span<const int32_t> destructured_source{ };
1909 if(source_type >= 0) {
1911 destructured_source = std::span<const int32_t>(env.
dict.
all_stack_types.data() + t.decomposed_types_start,
size_t(t.decomposed_types_count));
1914 bool result = destructured_source.size() > 0 ? match_to_slot(match_span[0], destructured_source[0]) :
false;
1916 while(sub_offset < match_span.size() && match_span[sub_offset] != -1) {
1917 auto dmatch = dest_offset < destructured_source.size() ? destructured_source[dest_offset] : -1;
1919 sub_offset += sub_result.match_end;
1920 result &= sub_result.match_result;
1923 if(dest_offset < destructured_source.size())
1925 if(sub_offset < match_span.size() && match_span[sub_offset] == -1)
1932 int32_t match_position = 0;
1935 auto const ssize = int32_t(ts.
main_size());
1936 int32_t consumed_stack_cells = 0;
1937 while(match_position < int32_t(desc.size()) && desc[match_position] != -1) {
1938 if(consumed_stack_cells >= ssize)
1941 if(!match_result.match_result)
1943 match_position += match_result.match_end;
1944 ++consumed_stack_cells;
1950 int32_t first_output_stack = match_position;
1952 while(match_position < int32_t(desc.size()) && desc[match_position] != -1) {
1961 int32_t consumed_rstack_cells = 0;
1962 while(match_position < int32_t(desc.size()) && desc[match_position] != -1) {
1963 if(consumed_rstack_cells >= rsize)
1966 if(!match_result.match_result)
1968 match_position += match_result.match_end;
1969 ++consumed_rstack_cells;
1976 while(match_position < int32_t(desc.size()) && desc[match_position] != -1) {
1978 match_position += result.end_match_pos;
1987 int32_t match_position = 0;
1990 std::vector<int32_t> type_subs;
1992 auto const ssize = int32_t(ts.
main_size());
1993 int32_t consumed_stack_cells = 0;
1994 while(match_position < int32_t(desc.size()) && desc[match_position] != -1) {
1995 if(consumed_stack_cells >= ssize)
1998 if(!match_result.match_result)
2000 match_position += match_result.match_end;
2001 ++consumed_stack_cells;
2007 int32_t first_output_stack = match_position;
2009 while(match_position < int32_t(desc.size()) && desc[match_position] != -1) {
2018 int32_t consumed_rstack_cells = 0;
2019 while(match_position < int32_t(desc.size()) && desc[match_position] != -1) {
2020 if(consumed_rstack_cells >= rsize)
2023 if(!match_result.match_result)
2025 match_position += match_result.match_end;
2026 ++consumed_rstack_cells;
2032 ts.
resize(ssize - consumed_stack_cells, rsize - consumed_rstack_cells);
2035 while(first_output_stack < int32_t(desc.size()) && desc[first_output_stack] != -1) {
2036 auto result =
resolve_span_type(desc.subspan(first_output_stack), type_subs, env);
2037 first_output_stack += result.end_match_pos;
2044 while(match_position < int32_t(desc.size()) && desc[match_position] != -1) {
2047 match_position += result.end_match_pos;
2058 int32_t count_desc = 0;
2059 int32_t desc_offset = 0;
2060 if(std::holds_alternative<interpreted_word_instance>(env.
dict.
all_instances[alternative])) {
2061 count_desc = std::get<interpreted_word_instance>(env.
dict.
all_instances[alternative]).stack_types_count;
2062 desc_offset = std::get<interpreted_word_instance>(env.
dict.
all_instances[alternative]).stack_types_start;
2063 }
else if(std::holds_alternative<compiled_word_instance>(env.
dict.
all_instances[alternative])) {
2064 count_desc = std::get<compiled_word_instance>(env.
dict.
all_instances[alternative]).stack_types_count;
2065 desc_offset = std::get<compiled_word_instance>(env.
dict.
all_instances[alternative]).stack_types_start;
2068 std::span<const int> desc = std::span<const int>(env.
dict.
all_stack_types.data() + desc_offset,
size_t(count_desc));
2070 int32_t match_position = 0;
2073 int32_t consumed_stack_cells = 0;
2074 while(match_position < int32_t(desc.size()) && desc[match_position] != -1) {
2076 ++consumed_stack_cells;
2082 int32_t first_output_stack = match_position;
2084 while(match_position < int32_t(desc.size()) && desc[match_position] != -1) {
2093 int32_t consumed_rstack_cells = 0;
2094 while(match_position < int32_t(desc.size()) && desc[match_position] != -1) {
2096 ++consumed_rstack_cells;
2111 std::vector<int32_t> type_subs;
2113 if(std::holds_alternative<interpreted_word_instance>(all_instances[w.
instances[i]])) {
2120 }
else if(std::holds_alternative<compiled_word_instance>(all_instances[w.
instances[i]])) {
2133 uint32_t first_non_space = read_position;
2134 while(first_non_space < source.length() && (source[first_non_space] ==
' ' || source[first_non_space] ==
'\t'))
2137 auto word_end = first_non_space;
2138 while(word_end < source.length() && source[word_end] !=
' ' && source[word_end] !=
'\t')
2141 read_position = word_end;
2143 return source.substr(first_non_space, word_end - first_non_space);
2150 memcpy(&fn, ptr, 8);
2151 ptr = fn(ss, ptr, &env);
2153 assert(_CrtCheckMemory());
2163 memcpy(&fn, ptr, 8);
2164 ptr = fn(ss, ptr, &env);
2166 assert(_CrtCheckMemory());
2173 memcpy(&data, p + 2, 4);
2179 memcpy(&data, p + 2, 4);
2185 memcpy(&data, p + 2, 4);
2193 auto compile_bytes = e->
compiler_stack.back()->bytecode_compilation_progress();
2197 memcpy(&imm_bytes, &imm, 8);
2198 compile_bytes->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
2199 compile_bytes->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
2200 compile_bytes->push_back(value);
2212 memcpy(&data, p + 2, 4);
2220 auto compile_bytes = e->
compiler_stack.back()->bytecode_compilation_progress();
2224 memcpy(&imm_bytes, &imm, 8);
2225 compile_bytes->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
2226 compile_bytes->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
2227 compile_bytes->push_back(value);
2241 auto compile_bytes = e->
compiler_stack.back()->bytecode_compilation_progress();
2245 memcpy(&imm_bytes, &imm, 8);
2246 compile_bytes->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
2247 compile_bytes->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
2248 compile_bytes->push_back(int32_t(value));
2264 memcpy(&v4, &value, 4);
2265 memcpy(&v8, &value, 4);
2267 auto compile_bytes = e->
compiler_stack.back()->bytecode_compilation_progress();
2271 memcpy(&imm_bytes, &imm, 8);
2272 compile_bytes->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
2273 compile_bytes->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
2274 compile_bytes->push_back(v4);
2297 std::vector<LLVMTypeRef> parameter_group;
2298 std::vector<LLVMTypeRef> returns_group;
2304 int32_t match_position = 0;
2308 while(match_position < int32_t(desc.size()) && desc[match_position] != -1) {
2309 parameter_group.push_back(env.
dict.
type_array[desc[match_position]].llvm_type);
2317 int32_t first_output_stack = match_position;
2319 while(match_position < int32_t(desc.size()) && desc[match_position] != -1) {
2320 returns_group.push_back(env.
dict.
type_array[desc[match_position]].llvm_type);
2328 while(match_position < int32_t(
desc.size()) && desc[match_position] != -1) {
2329 parameter_group.push_back(env.
dict.
type_array[desc[match_position]].llvm_type);
2338 while(match_position < int32_t(
desc.size()) && desc[match_position] != -1) {
2339 returns_group.push_back(env.
dict.
type_array[desc[match_position]].llvm_type);
2345 if(returns_group.size() == 0) {
2347 }
else if(returns_group.size() == 1) {
2348 ret_type = returns_group[0];
2355inline void llvm_make_function_parameters(environment& env,
LLVMValueRef fn, state_stack& ws, std::span<int32_t const> desc) {
2361 int32_t match_position = 0;
2364 int32_t consumed_stack_cells = 0;
2365 while(match_position < int32_t(
desc.size()) && desc[match_position] != -1) {
2368 ++consumed_stack_cells;
2374 int32_t first_output_stack = match_position;
2376 while(match_position < int32_t(
desc.size()) && desc[match_position] != -1) {
2383 int32_t consumed_rstack_cells = 0;
2384 while(match_position < int32_t(
desc.size()) && desc[match_position] != -1) {
2385 ws.set_return_ex_back(consumed_rstack_cells,
LLVMGetParam(fn,
uint32_t(consumed_stack_cells + consumed_stack_cells)));
2387 ++consumed_rstack_cells;
2394 while(match_position < int32_t(
desc.size()) && desc[match_position] != -1) {
2400struct brief_fn_return {
2402 int32_t num_stack_values;
2403 int32_t num_rstack_values;
2404 bool is_struct_type;
2407inline brief_fn_return llvm_function_return_type_from_desc(environment& env, std::span<int32_t const> desc) {
2408 std::vector<LLVMTypeRef> returns_group;
2414 int32_t match_position = 0;
2418 while(match_position < int32_t(
desc.size()) && desc[match_position] != -1) {
2427 int32_t first_output_stack = match_position;
2428 int32_t output_stack_types = 0;
2429 while(match_position < int32_t(
desc.size()) && desc[match_position] != -1) {
2430 returns_group.push_back(env.dict.type_array[desc[match_position]].llvm_type);
2432 ++output_stack_types;
2438 while(match_position < int32_t(
desc.size()) && desc[match_position] != -1) {
2447 int32_t ret_added = 0;
2448 while(match_position < int32_t(
desc.size()) && desc[match_position] != -1) {
2449 returns_group.push_back(env.dict.type_array[desc[match_position]].llvm_type);
2455 if(returns_group.size() == 0) {
2457 }
else if(returns_group.size() == 1) {
2458 ret_type = returns_group[0];
2462 return brief_fn_return{ ret_type , output_stack_types, ret_added, returns_group.size() > 1};
2465inline void llvm_make_function_return(environment& env, std::span<int32_t const> desc) {
2466 auto rsummary = llvm_function_return_type_from_desc( env, desc);
2468 if(rsummary.composite_type ==
nullptr) {
2472 if(rsummary.is_struct_type ==
false) {
2473 if(rsummary.num_stack_values == 0) {
2474 LLVMBuildRet(env.llvm_builder, env.compiler_stack.back()->working_state()->return_ex_back(0));
2476 }
else if(rsummary.num_rstack_values == 0) {
2477 LLVMBuildRet(env.llvm_builder, env.compiler_stack.back()->working_state()->main_ex_back(0));
2487 for(int32_t i = rsummary.num_stack_values - 1; i >= 0; --i) {
2488 rstruct =
LLVMBuildInsertValue(env.llvm_builder, rstruct, env.compiler_stack.back()->working_state()->main_ex_back(i), insert_index,
"");
2491 for(int32_t i = rsummary.num_rstack_values - 1; i >= 0; --i) {
2492 rstruct =
LLVMBuildInsertValue(env.llvm_builder, rstruct, env.compiler_stack.back()->working_state()->return_ex_back(i), insert_index,
"");
2499inline void llvm_make_function_call(environment& env,
LLVMValueRef fn, std::span<int32_t const> desc) {
2500 std::vector<LLVMValueRef> params;
2503 int32_t match_position = 0;
2507 while(match_position < int32_t(
desc.size()) && desc[match_position] != -1) {
2508 params.push_back(env.compiler_stack.back()->working_state()->main_ex_back(0));
2509 env.compiler_stack.back()->working_state()->pop_main();
2517 int32_t first_output_stack = match_position;
2519 while(match_position < int32_t(
desc.size()) && desc[match_position] != -1) {
2528 while(match_position < int32_t(
desc.size()) && desc[match_position] != -1) {
2529 params.push_back(env.compiler_stack.back()->working_state()->return_ex_back(0));
2530 env.compiler_stack.back()->working_state()->pop_return();
2537 auto retvalue =
LLVMBuildCall2(env.llvm_builder, llvm_function_type_from_desc(env, desc), fn, params.data(),
uint32_t(params.size()),
"");
2539 auto rsummary = llvm_function_return_type_from_desc(env, desc);
2541 if(rsummary.composite_type ==
nullptr) {
2547 int32_t match_position = 0;
2551 while(match_position < int32_t(
desc.size()) && desc[match_position] != -1) {
2560 int32_t first_output_stack = match_position;
2562 while(match_position < int32_t(
desc.size()) && desc[match_position] != -1) {
2563 if(rsummary.is_struct_type ==
false) {
2564 env.compiler_stack.back()->working_state()->push_back_main(desc[match_position], 0, retvalue);
2566 env.compiler_stack.back()->working_state()->push_back_main(desc[match_position], 0,
LLVMBuildExtractValue(env.llvm_builder, retvalue, extract_index,
""));
2576 while(match_position < int32_t(
desc.size()) && desc[match_position] != -1) {
2586 while(match_position < int32_t(
desc.size()) && desc[match_position] != -1) {
2587 if(rsummary.is_struct_type ==
false) {
2588 env.compiler_stack.back()->working_state()->push_back_return(desc[match_position], 0, retvalue);
2590 env.compiler_stack.back()->working_state()->push_back_return(desc[match_position], 0,
LLVMBuildExtractValue(env.llvm_builder, retvalue, extract_index,
""));
2600inline std::vector<int32_t>
expand_stack_description(state_stack& initial_stack_state, std::span<const int32_t> desc, int32_t stack_consumed, int32_t rstack_consumed);
2605 ankerl::unordered_dense::map<std::string, std::unique_ptr<var_data>>
vars;
2606 ankerl::unordered_dense::map<std::string, std::unique_ptr<let_data>>
lets;
2614 if(
auto it =
vars.find(name); it !=
vars.end()) {
2615 return it->second.get();
2620 if(
auto it =
lets.find(name); it !=
lets.end()) {
2623 if(
auto it =
vars.find(name); it !=
vars.end()) {
2627 auto added =
vars.insert_or_assign(name, std::make_unique<var_data>());
2628 added.first->second->type =
type;
2629 added.first->second->data = 0;
2633 return added.first->second.get();
2636 if(
auto it =
lets.find(name); it !=
lets.end()) {
2637 return it->second.get();
2642 if(
auto it =
lets.find(name); it !=
lets.end()) {
2645 if(
auto it =
vars.find(name); it !=
vars.end()) {
2648 auto added =
lets.insert_or_assign(name, std::make_unique<let_data>());
2649 added.first->second->type =
type;
2650 added.first->second->data = data;
2651 added.first->second->expression = expression;
2652 if(
auto it =
lets.find(name); it !=
lets.end()) {
2653 return it->second.get();
2660 for(
auto& l :
vars) {
2665 void* iresult =
nullptr;
2667 ws->push_back_main(l.second->type, l.second->data, iresult);
2671 for(
auto& l :
lets) {
2673 ws->push_back_main(l.second->type, l.second->data, l.second->expression);
2700 env.
report_error(
"attempted to compile a function for an anonymous word");
2720 auto fn_type = llvm_function_type_from_desc(
env, fn_desc);
2764 virtual ankerl::unordered_dense::map<uint64_t, typecheck_3_record>*
typecheck_record()
override {
2778 assert(stack_added >= 0);
2779 assert(rstack_added >= 0);
2780 assert(stack_consumed >= 0);
2781 assert(rstack_consumed >= 0);
2791 for(int32_t i = 0; i < stack_consumed; ++i) {
2795 int32_t skipped = 0;
2796 if(stack_added > 0) {
2798 for(int32_t i = 1; i <= stack_added; ++i) {
2804 if(rstack_consumed > 0) {
2805 for(; skipped > 0; --skipped)
2808 for(int32_t i = 0; i < rstack_consumed; ++i) {
2814 if(rstack_added > 0) {
2815 for(; skipped > 0; --skipped)
2818 for(int32_t i = 1; i <= rstack_added; ++i) {
2823 temp.typechecking_level = 1;
2835 env.
report_error(
"tried to level 2 typecheck a word without an instance");
2843 if(!
compare_stack_description(existing_description, std::span<const int32_t>(revised_description.data(), revised_description.size()))) {
2863 memcpy(&imm_bytes, &imm, 8);
2865 compiled_bytes.push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
2884 llvm_make_function_return(
env, existing_description);
2891 char* message =
nullptr;
2927 int32_t* jump_target =
nullptr;
2928 memcpy(&jump_target, p + 2, 8);
2936 auto instance = *(p + 2);
2985 virtual ankerl::unordered_dense::map<uint64_t, typecheck_3_record>*
typecheck_record()
override {
3015 auto m = std::make_unique<mode_switch_scope>(env.
compiler_stack.back().get(), env, new_mode);
3020 env.
report_error(
"attempt to switch mode back revealed an unbalanced compiler stack");
3031 ankerl::unordered_dense::map<std::string, std::unique_ptr<var_data>>
global_vars;
3032 ankerl::unordered_dense::map<std::string, std::unique_ptr<let_data>>
global_lets;
3036 return it->second.get();
3047 auto added =
global_vars.insert_or_assign(name, std::make_unique<var_data>());
3048 added.first->second->type =
type;
3049 added.first->second->data = 0;
3050 added.first->second->alloc =
nullptr;
3051 return added.first->second.get();
3055 return it->second.get();
3066 auto added =
global_lets.insert_or_assign(name, std::make_unique<let_data>());
3067 added.first->second->type =
type;
3068 added.first->second->data = data;
3069 added.first->second->expression = expression;
3071 return it->second.get();
3093 ankerl::unordered_dense::map<uint64_t, typecheck_3_record>
tr;
3101 virtual ankerl::unordered_dense::map<uint64_t, typecheck_3_record>*
typecheck_record()
override {
3111 int32_t match_position = 0;
3114 std::vector<int32_t> result;
3116 int32_t consumed_stack_cells = 0;
3117 while(match_position < int32_t(desc.size()) && desc[match_position] != -1) {
3119 result.insert(result.end(), desc.data() + match_position, desc.data() + match_position + match_size);
3120 match_position += match_size;
3121 ++consumed_stack_cells;
3123 if(consumed_stack_cells < stack_consumed) {
3124 for(int32_t i = consumed_stack_cells; i < stack_consumed; ++i) {
3129 if(consumed_stack_cells < stack_consumed || (match_position < int32_t(desc.size()) && desc[match_position] == -1)) {
3130 result.push_back(-1);
3134 if(consumed_stack_cells < stack_consumed) {
3135 for(int32_t i = stack_consumed - 1; i >= consumed_stack_cells; --i) {
3140 int32_t first_output_stack = match_position;
3142 while(match_position < int32_t(desc.size()) && desc[match_position] != -1) {
3144 result.insert(result.end(), desc.data() + match_position, desc.data() + match_position + match_size);
3145 match_position += match_size;
3149 if(rstack_consumed > 0 || (match_position < int32_t(desc.size()) && desc[match_position] == -1)) {
3150 result.push_back(-1);
3155 int32_t consumed_rstack_cells = 0;
3156 while(match_position < int32_t(desc.size()) && desc[match_position] != -1) {
3158 result.insert(result.end(), desc.data() + match_position, desc.data() + match_position + match_size);
3159 match_position += match_size;
3160 ++consumed_rstack_cells;
3162 if(consumed_rstack_cells < rstack_consumed) {
3163 for(int32_t i = consumed_rstack_cells; i < rstack_consumed; ++i) {
3168 if(consumed_rstack_cells < rstack_consumed || (match_position < int32_t(desc.size()) && desc[match_position] == -1)) {
3169 result.push_back(-1);
3173 if(consumed_rstack_cells < rstack_consumed) {
3174 for(int32_t i = rstack_consumed - 1; i >= consumed_rstack_cells; --i) {
3180 int32_t ret_added = 0;
3181 while(match_position < int32_t(desc.size()) && desc[match_position] != -1) {
3183 result.insert(result.end(), desc.data() + match_position, desc.data() + match_position + match_size);
3184 match_position += match_size;
3191 if(a.size() != b.size())
3193 for(
auto i = a.size(); i-- > 0; ) {
3204 for(
size_t i = a.
main_size(); i-- > 0; ) {
3219 return p + *(p + 2);
3227 return p + *(p + 2);
3232 return p + *(p + 2);
3253 env.
report_error(
"attempted to start an if without a boolean value on the stack");
3281 memcpy(&imm_bytes, &imm, 8);
3282 bcode->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
3283 bcode->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
3285 bcode->push_back(0);
3289 memcpy(&imm2_bytes, &imm2, 8);
3290 bcode->push_back(int32_t(imm2_bytes & 0xFFFFFFFF));
3291 bcode->push_back(int32_t((imm2_bytes >> 32) & 0xFFFFFFFF));
3335 memcpy(&imm2_bytes, &imm2, 8);
3336 bcode->push_back(int32_t(imm2_bytes & 0xFFFFFFFF));
3337 bcode->push_back(int32_t((imm2_bytes >> 32) & 0xFFFFFFFF));
3341 memcpy(&imm_bytes, &imm, 8);
3342 bcode->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
3343 bcode->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
3345 bcode->push_back(0);
3350 memcpy(&imm2_bytes, &imm2, 8);
3351 bcode->push_back(int32_t(imm2_bytes & 0xFFFFFFFF));
3352 bcode->push_back(int32_t((imm2_bytes >> 32) & 0xFFFFFFFF));
3380 bool final_types_match =
true;
3390 if(!final_types_match) {
3395 env.
report_error(
"inconsistent stack types over a conditional branch");
3418 memcpy(&imm2_bytes, &imm2, 8);
3419 bcode->push_back(int32_t(imm2_bytes & 0xFFFFFFFF));
3420 bcode->push_back(int32_t((imm2_bytes >> 32) & 0xFFFFFFFF));
3432 auto current_block = *pb;
3605 memcpy(&imm2_bytes, &imm2, 8);
3606 bcode->push_back(int32_t(imm2_bytes & 0xFFFFFFFF));
3607 bcode->push_back(int32_t((imm2_bytes >> 32) & 0xFFFFFFFF));
3639 env.
report_error(
"while loop conditional expression did not produce a boolean");
3662 memcpy(&imm2_bytes, &imm2, 8);
3663 bcode->push_back(int32_t(imm2_bytes & 0xFFFFFFFF));
3664 bcode->push_back(int32_t((imm2_bytes >> 32) & 0xFFFFFFFF));
3669 memcpy(&imm_bytes, &imm, 8);
3670 bcode->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
3671 bcode->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
3673 bcode->push_back(0);
3679 memcpy(&imm2_bytes, &imm2, 8);
3680 bcode->push_back(int32_t(imm2_bytes & 0xFFFFFFFF));
3681 bcode->push_back(int32_t((imm2_bytes >> 32) & 0xFFFFFFFF));
3735 env.
report_error(
"while loop terminated with an appropriate conditional");
3745 memcpy(&imm2_bytes, &imm2, 8);
3746 bcode->push_back(int32_t(imm2_bytes & 0xFFFFFFFF));
3747 bcode->push_back(int32_t((imm2_bytes >> 32) & 0xFFFFFFFF));
3752 memcpy(&imm_bytes, &imm, 8);
3753 bcode->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
3754 bcode->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
3756 bcode->push_back(int32_t(int64_t(
loop_entry_point) - int64_t(bcode->size() - 2)));
3760 if(!final_types_match) {
3772 memcpy(&imm2_bytes, &imm2, 8);
3773 bcode->push_back(int32_t(imm2_bytes & 0xFFFFFFFF));
3774 bcode->push_back(int32_t((imm2_bytes >> 32) & 0xFFFFFFFF));
3779 memcpy(&imm_bytes, &imm, 8);
3780 bcode->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
3781 bcode->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
3782 bcode->push_back(int32_t(int64_t(
loop_entry_point) - int64_t(bcode->size() - 2)));
3806 if(!final_types_match) {
3813 auto in_block = *pb;
3908 if(!final_types_match) {
3961 memcpy(&imm2_bytes, &imm2, 8);
3962 bcode->push_back(int32_t(imm2_bytes & 0xFFFFFFFF));
3963 bcode->push_back(int32_t((imm2_bytes >> 32) & 0xFFFFFFFF));
4010 env.
report_error(
"do loop not terminated with an appropriate conditional");
4019 memcpy(&imm2_bytes, &imm2, 8);
4020 bcode->push_back(int32_t(imm2_bytes & 0xFFFFFFFF));
4021 bcode->push_back(int32_t((imm2_bytes >> 32) & 0xFFFFFFFF));
4026 memcpy(&imm_bytes, &imm, 8);
4027 bcode->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
4028 bcode->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
4030 bcode->push_back(int32_t(int64_t(
loop_entry_point) - int64_t(bcode->size() - 2)));
4033 if(!final_types_match) {
4051 if(!final_types_match) {
4058 auto in_block = *pb;
4150 if(!final_types_match) {
4182 if((byte1 & 0x80) == 0) {
4184 }
else if((byte1 & 0xE0) == 0xC0) {
4186 }
else if((byte1 & 0xF0) == 0xE0) {
4188 }
else if((byte1 & 0xF8) == 0xF0) {
4195 return ((b & 0x80) == 0) ? 1 : ((b & 0xE0) == 0xC0) ? 2
4196 : ((b & 0xF0) == 0xE0) ? 3 : ((b & 0xF8) == 0xF0) ? 4
4200 return (c == 0x3000 || c == 0x205F || c == 0x202F || c == 0x2029 || c == 0x2028 || c == 0x00A0
4201 || c == 0x0085 || c <= 0x0020 || (0x2000 <= c && c <= 0x200A));
4204 return c == 0x2029 || c == 0x2028 || c ==
uint32_t(
'\n') || c ==
uint32_t(
'\r');
4213 if(source.length() < 2)
4215 if(source[0] !=
'<')
4217 int32_t eq_count = 0;
4219 while(pos < source.length()) {
4220 if(source[pos] ==
'<') {
4222 }
else if(source[pos] ==
'=') {
4232 if(source.length() < 2)
4234 if(source[0] !=
'>')
4236 int32_t eq_count = 0;
4238 while(pos < source.length()) {
4239 if(source[pos] ==
'>') {
4240 return eq_count == eq_count_in;
4241 }
else if(source[pos] ==
'=') {
4254 size_t first_non_space = 0;
4255 while(first_non_space < source.length()) {
4256 auto codepoint =
codepoint_from_utf8(source.data() + first_non_space, source.data() + source.length());
4258 first_non_space +=
size_from_utf8(source.data() + first_non_space);
4264 auto str_start = first_non_space + sm.eq_match + 2;
4265 auto str_pos = str_start;
4266 while(str_pos < source.length()) {
4268 auto result = source.substr(str_start, str_pos - str_start);
4269 source = source.substr(str_pos + sm.eq_match + 2);
4278 source = std::string_view{ };
4282 auto word_end = first_non_space;
4283 while(word_end < source.length()) {
4284 auto codepoint =
codepoint_from_utf8(source.data() + word_end, source.data() + source.length());
4291 auto result = source.substr(first_non_space, word_end - first_non_space);
4292 source = source.substr(word_end);
4298inline void execute_fif_word(parse_result word, environment& env,
bool ignore_specialization);
4310 word.content = std::string_view{ };
4327 while(word_index != -1) {
4328 specialize_t_subs.clear();
4329 bool specialization_matches = [&]() {
4334 if(specialization_matches && (ignore_specializations ==
false || env.
dict.
word_array[word_index].treat_as_base || env.
dict.
word_array[word_index].specialization_of == -1)) {
4336 int32_t w = word_index;
4352 auto fnscope = std::make_unique<function_scope>(env.
compiler_stack.back().get(), env, current_type_state, w, -1);
4353 fnscope->type_subs = specialize_t_subs;
4378 auto fnscope = std::make_unique<function_scope>(env.
compiler_stack.back().get(), env, current_type_state, w, -1);
4379 fnscope->type_subs = specialize_t_subs;
4417 auto fnscope = std::make_unique<function_scope>(env.
compiler_stack.back().get(), env, current_type_state, w, word_index);
4418 fnscope->type_subs = tsubs;
4445 auto fnscope = std::make_unique<function_scope>(env.
compiler_stack.back().get(), env, current_type_state, w, word_index);
4446 fnscope->type_subs = tsubs;
4464 if(
auto erb = record_holder->tr.find((
uint64_t(w) << 32) |
uint64_t(word_index)); erb != record_holder->tr.end()) {
4470 r.
stack_consumed = std::max(c.stack, erb->second.stack_consumed);
4473 record_holder->tr.insert_or_assign((
uint64_t(w) << 32) |
uint64_t(word_index), r);
4483 record_holder->tr.insert_or_assign((
uint64_t(w) << 32) |
uint64_t(word_index), r);
4489 auto min_stack_depth = int32_t(current_type_state.
main_size());
4490 auto min_rstack_depth = int32_t(current_type_state.
return_size());
4491 for(
auto& s : record_holder->tr) {
4492 min_stack_depth = std::min(min_stack_depth, s.second.stack_height_added_at - s.second.stack_consumed);
4493 min_rstack_depth = std::min(min_rstack_depth, s.second.rstack_height_added_at - s.second.rstack_consumed);
4497 auto revised_description =
expand_stack_description(current_type_state, existing_description, int32_t(current_type_state.
main_size()) - min_stack_depth, int32_t(current_type_state.
return_size()) - min_rstack_depth);
4499 if(!
compare_stack_description(existing_description, std::span<int32_t const>(revised_description.data(), revised_description.size()))) {
4512 if(!std::holds_alternative<interpreted_word_instance>(env.
dict.
all_instances[word_index]))
4524 if(!std::get<interpreted_word_instance>(env.
dict.
all_instances[word_index]).being_compiled) {
4526 auto fnscope = std::make_unique<function_scope>(env.
compiler_stack.back().get(), env, state, w, word_index);
4527 fnscope->type_subs = tsubs;
4538 if(!std::get<interpreted_word_instance>(env.
dict.
all_instances[word_index]).being_compiled) {
4545 auto fnscope = std::make_unique<function_scope>(env.
compiler_stack.back().get(), env, state, w, word_index);
4546 fnscope->type_subs = tsubs;
4581 memcpy(&name, p + 2, 8);
4589 memcpy(&
type, p + 4, 4);
4596 memcpy(&name, p + 2, 8);
4603 memcpy(&
type, p + 4, 4);
4610 memcpy(&name, p + 2, 8);
4617 memcpy(&
type, p + 4, 4);
4625 env.
report_error(
"tried to execute in a scope with no working state");
4635 auto content_string = std::string{
word.content };
4638 }
else if(
is_fp(
word.content.data(),
word.content.data() +
word.content.length())) {
4640 }
else if(
word.content ==
"true" ||
word.content ==
"false") {
4643 auto w = it->second;
4661 std::vector<int32_t> called_tsub_types;
4663 w = match.substitution_version;
4665 if(!match.matched) {
4669 env.
report_error(
"could not match word to stack types");
4679 if(std::holds_alternative<interpreted_word_instance>(*wi)) {
4683 }
else if(std::holds_alternative<compiled_word_instance>(*wi)) {
4698 if(std::holds_alternative<interpreted_word_instance>(*wi)) {
4700 apply_stack_description(std::span<int32_t const>(env.
dict.
all_stack_types.data() + std::get<interpreted_word_instance>(*wi).stack_types_start,
size_t(std::get<interpreted_word_instance>(*wi).stack_types_count)), *ws, env);
4702 }
else if(std::holds_alternative<compiled_word_instance>(*wi)) {
4705 apply_stack_description(std::span<int32_t const>(env.
dict.
all_stack_types.data() + std::get<compiled_word_instance>(*wi).stack_types_start,
size_t(std::get<compiled_word_instance>(*wi).stack_types_count)), *ws, env);
4716 if(std::holds_alternative<interpreted_word_instance>(*wi)) {
4719 if(std::get<interpreted_word_instance>(*wi).typechecking_level < 3) {
4725 auto existing_record = dep.find((
uint64_t(w) << 32) |
uint64_t(match.word_index));
4726 if(existing_record != dep.end()
4727 && existing_record->second.stack_height_added_at <= int32_t(ws->main_size())
4728 && existing_record->second.rstack_height_added_at <= int32_t(ws->return_size())) {
4736 env.
report_error(std::string(
"Word ") + std::to_string(w) +
" is undefined.");
4741 if(std::get<interpreted_word_instance>(*wi).typechecking_level < 2) {
4745 auto fnscope = std::make_unique<function_scope>(env.
compiler_stack.back().get(), env, *ws, w, match.word_index);
4746 fnscope->type_subs = called_tsub_types;
4762 std::get<interpreted_word_instance>(*wi).typechecking_level = 2;
4766 if(
auto erb = dep.find((
uint64_t(w) << 32) |
uint64_t(match.word_index)); erb != dep.end()) {
4772 r.
stack_consumed = std::max(c.stack, erb->second.stack_consumed);
4790 apply_stack_description(std::span<int32_t const>(env.
dict.
all_stack_types.data() + std::get<interpreted_word_instance>(*wi).stack_types_start,
size_t(std::get<interpreted_word_instance>(*wi).stack_types_count)), *ws, env);
4792 }
else if(std::holds_alternative<compiled_word_instance>(*wi)) {
4795 apply_stack_description(std::span<int32_t const>(env.
dict.
all_stack_types.data() + std::get<compiled_word_instance>(*wi).stack_types_start,
size_t(std::get<compiled_word_instance>(*wi).stack_types_count)), *ws, env);
4810 if(std::holds_alternative<interpreted_word_instance>(*wi)) {
4818 std::span<int32_t const> desc{ env.
dict.
all_stack_types.data() + std::get<interpreted_word_instance>(*wi).stack_types_start,
size_t(std::get<interpreted_word_instance>(*wi).stack_types_count) };
4819 llvm_make_function_call(env, std::get<interpreted_word_instance>(*wi).llvm_function, desc);
4822 auto cbytes = env.
compiler_stack.back()->bytecode_compilation_progress();
4824 if(std::get<interpreted_word_instance>(*wi).being_compiled) {
4827 memcpy(&imm_bytes, &imm, 8);
4828 cbytes->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
4829 cbytes->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
4830 cbytes->push_back(match.word_index);
4835 memcpy(&imm_bytes, &imm, 8);
4836 cbytes->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
4837 cbytes->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
4840 int32_t* bcode = std::get<interpreted_word_instance>(*wi).compiled_bytecode.data();
4842 memcpy(&imm_bytes, &bcode, 8);
4843 cbytes->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
4844 cbytes->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
4847 apply_stack_description(std::span<int32_t const>(env.
dict.
all_stack_types.data() + std::get<interpreted_word_instance>(*wi).stack_types_start,
size_t(std::get<interpreted_word_instance>(*wi).stack_types_count)), *ws, env);
4850 }
else if(std::holds_alternative<compiled_word_instance>(*wi)) {
4852 auto cbytes = env.
compiler_stack.back()->bytecode_compilation_progress();
4854 fif_call imm = std::get<compiled_word_instance>(*wi).implementation;
4856 memcpy(&imm_bytes, &imm, 8);
4857 cbytes->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
4858 cbytes->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
4860 apply_stack_description(std::span<int32_t const>(env.
dict.
all_stack_types.data() + std::get<compiled_word_instance>(*wi).stack_types_start,
size_t(std::get<compiled_word_instance>(*wi).stack_types_count)), *ws, env);
4863 std::get<compiled_word_instance>(*wi).implementation(*ws,
nullptr, &env);
4867 }
else if(
auto let = env.
compiler_stack.back()->get_let(content_string);
word.is_string ==
false && let) {
4869 ws->push_back_main(let->type, let->data, let->expression);
4871 ws->push_back_main(let->type, let->data, let->expression);
4873 ws->push_back_main(let->type, let->data, let->expression);
4876 auto cbytes = env.
compiler_stack.back()->bytecode_compilation_progress();
4880 memcpy(&imm_bytes, &imm, 8);
4881 cbytes->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
4882 cbytes->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
4885 char const* cptr = string_constant.data();
4888 memcpy(&let_addr, &cptr, 8);
4889 cbytes->push_back(int32_t(let_addr & 0xFFFFFFFF));
4890 cbytes->push_back(int32_t((let_addr >> 32) & 0xFFFFFFFF));
4892 cbytes->push_back(let->type);
4894 ws->push_back_main(let->type, 0, 0);
4896 }
else if(
auto var = env.
compiler_stack.back()->get_var(content_string);
word.is_string ==
false && var) {
4897 int32_t ptr_type[] = {
fif_ptr, std::numeric_limits<int32_t>::max(), var->type, -1 };
4898 std::vector<int32_t> subs;
4899 auto mem_type =
resolve_span_type(std::span<int32_t const>(ptr_type, ptr_type + 4), subs, env);
4902 ws->push_back_main(mem_type.type, 0, 0);
4904 ws->push_back_main(mem_type.type, 0, var->alloc);
4906 ws->push_back_main(mem_type.type, (int64_t)(var), 0);
4909 auto cbytes = env.
compiler_stack.back()->bytecode_compilation_progress();
4913 memcpy(&imm_bytes, &imm, 8);
4914 cbytes->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
4915 cbytes->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
4918 char const* cptr = string_constant.data();
4920 memcpy(&let_addr, &cptr, 8);
4921 cbytes->push_back(int32_t(let_addr & 0xFFFFFFFF));
4922 cbytes->push_back(int32_t((let_addr >> 32) & 0xFFFFFFFF));
4924 cbytes->push_back(mem_type.type);
4926 ws->push_back_main(mem_type.type, 0, 0);
4928 }
else if(
auto letb =
get_global_let(env, content_string);
word.is_string ==
false && letb) {
4930 }
else if(
auto varb =
get_global_var(env, content_string);
word.is_string ==
false && varb) {
4931 int32_t ptr_type[] = {
fif_ptr, std::numeric_limits<int32_t>::max(), varb->type, -1 };
4932 std::vector<int32_t> subs;
4933 auto mem_type =
resolve_span_type(std::span<int32_t const>(ptr_type, ptr_type + 4), subs, env);
4936 ws->push_back_main(mem_type.type, 0, 0);
4938 ws->push_back_main(mem_type.type, 0, varb->alloc);
4940 ws->push_back_main(mem_type.type, (int64_t)(varb), 0);
4943 auto cbytes = env.
compiler_stack.back()->bytecode_compilation_progress();
4947 memcpy(&imm_bytes, &imm, 8);
4948 cbytes->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
4949 cbytes->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
4952 char const* cptr = string_constant.data();
4954 memcpy(&let_addr, &cptr, 8);
4955 cbytes->push_back(int32_t(let_addr & 0xFFFFFFFF));
4956 cbytes->push_back(int32_t((let_addr >> 32) & 0xFFFFFFFF));
4958 cbytes->push_back(mem_type.type);
4960 ws->push_back_main(mem_type.type, 0, 0);
4965 env.
report_error(std::string(
"attempted to execute an unknown word: ") + std::string(
word.content));
4971inline void add_exportable_functions_to_globals(environment& env) {
4972 if(!env.exported_functions.empty()) {
4974 auto used_array =
LLVMAddGlobal(env.llvm_module, array_type,
"llvm.used");
4981inline LLVMValueRef make_exportable_function(std::string
const& export_name, std::string
const& word, std::vector<int32_t> param_stack, std::vector<int32_t> return_stack, environment& env) {
4983 env.compiler_stack.emplace_back(std::make_unique<outer_interpreter>(env));
4984 env.source_stack.push_back(std::string_view{ });
4985 outer_interpreter* o =
static_cast<outer_interpreter*
>(env.compiler_stack.back().get());
4987 static_cast<mode_switch_scope*
>(env.compiler_stack.back().get())->interpreted_link = o;
4990 if(
auto it = env.dict.words.find(word); it != env.dict.words.end()) {
4993 env.report_error(
"failed to export function (dictionary lookup failed)");
4998 ts.resize(param_stack.size(), return_stack.size());
4999 for(
auto i = param_stack.size(); i-- > 0; ) {
5000 ts.set_main_type(i, param_stack[i]);
5002 for(
auto i = return_stack.size(); i-- > 0; ) {
5003 ts.set_return_type(i, return_stack[i]);
5005 ts.min_main_depth = param_stack.size();
5006 ts.min_return_depth = param_stack.size();
5008 std::vector<int32_t> typevars;
5010 w = match.substitution_version;
5011 if(!match.matched) {
5012 env.report_error(
"failed to export function (typematch failed)");
5017 env.report_error(
"failed to export function (compilation failed)");
5021 if(!std::holds_alternative<interpreted_word_instance>(env.dict.all_instances[match.word_index])) {
5022 env.report_error(
"failed to export function (can't export built-in)");
5026 auto& wi = std::get<interpreted_word_instance>(env.dict.all_instances[match.word_index]);
5028 auto desc = std::span<int32_t const>(env.dict.all_stack_types.data() + wi.stack_types_start, wi.stack_types_count);
5029 auto fn_type = llvm_function_type_from_desc(env, desc);
5030 auto compiled_fn =
LLVMAddFunction(env.llvm_module, export_name.c_str(), fn_type);
5041 std::vector<LLVMValueRef> params;
5043 int32_t match_position = 0;
5046 int32_t consumed_stack_cells = 0;
5047 while(match_position < int32_t(
desc.size()) && desc[match_position] != -1) {
5050 ++consumed_stack_cells;
5056 int32_t first_output_stack = match_position;
5058 while(match_position < int32_t(
desc.size()) && desc[match_position] != -1) {
5066 int32_t consumed_rstack_cells = 0;
5067 while(match_position < int32_t(
desc.size()) && desc[match_position] != -1) {
5068 params.push_back(
LLVMGetParam(compiled_fn,
uint32_t(consumed_stack_cells + consumed_rstack_cells)));
5070 ++consumed_rstack_cells;
5073 auto retvalue =
LLVMBuildCall2(env.llvm_builder, llvm_function_type_from_desc(env, desc), wi.llvm_function, params.data(),
uint32_t(params.size()),
"");
5075 auto rsummary = llvm_function_return_type_from_desc(env, desc);
5078 if(rsummary.composite_type ==
nullptr) {
5083 if(
LLVMVerifyFunction(compiled_fn, LLVMVerifierFailureAction::LLVMPrintMessageAction))
5086 env.exported_functions.push_back(compiled_fn);
5089 env.compiler_stack.pop_back();
5090 env.source_stack.pop_back();
5098 env.
compiler_stack.emplace_back(std::make_unique<outer_interpreter>(env));
5103 m->interpreted_link = o;
5113 env.
compiler_stack.emplace_back(std::make_unique<outer_interpreter>(env));
5119 m->interpreted_link = o;
5154inline void add_import(std::string_view name,
void* ptr,
fif_call interpreter_implementation, std::vector<int32_t>
const& params, std::vector<int32_t>
const& returns,
environment& env) {
5157 std::vector<int32_t> itype_list;
5158 for(
auto j = params.size(); j-->0;) {
5159 itype_list.push_back(params[j]);
5161 auto pcount = itype_list.size();
5162 if(!returns.empty()) {
5163 itype_list.push_back(-1);
5164 for(
auto r : returns) {
5165 itype_list.push_back(r);
5171 int32_t count_types = int32_t(itype_list.size());
5173 auto nstr = std::string(name);
5174 int32_t old_word = -1;
5176 old_word = it->second;
5190 fif_call imm = interpreter_implementation;
5192 memcpy(&imm_bytes, &imm, 8);
5199 memcpy(&imm_bytes, &imm, 8);
5210 auto fn_desc = std::span<int32_t const>(itype_list.begin(), itype_list.end());
5211 auto fn_type = llvm_function_type_from_desc(env, fn_desc);
5221inline void perform_jit(environment& e) {
5224 char* out_message =
nullptr;
5225 auto result =
LLVMVerifyModule(e.llvm_module, LLVMVerifierFailureAction::LLVMPrintMessageAction, &out_message);
5227 e.report_error(out_message);
5234 e.llvm_builder =
nullptr;
5241 e.llvm_target_machine =
nullptr;
5247 e.report_error(msg);
5253 e.report_error(
"failed to create jit");
5262 e.llvm_module =
nullptr;
5267 e.report_error(
"failed to get main dylib");
5272 std::vector< LLVMOrcCSymbolMapPair> import_symbols;
5273 for(
auto& i : e.imported_functions) {
5277 sym.
Flags.
GenericFlags = LLVMJITSymbolGenericFlags::LLVMJITSymbolGenericFlagsCallable;
5282 if(import_symbols.size() > 0) {
5287 e.report_error(msg);
5296 e.report_error(msg);
5307 e->
report_error(
"attempted to compile a definition inside a definition");
5313 e->
report_error(
"attempted to compile a definition without a source");
5323 if(t.is_string ==
false && t.content ==
";") {
5324 auto string_end = t.content.data();
5326 auto nstr = std::string(name_token.content);
5329 e->
mode = fif_mode::error;
5341 e->
report_error(
"reached the end of a definition source without a ; terminator");
5350 e->
report_error(
"attempted to compile a definition inside a definition");
5356 e->
report_error(
"attempted to compile a definition without a source");
5363 std::vector<std::string_view> stack_types;
5366 if(next_token.content.length() == 0 || next_token.content ==
"s:") {
5369 stack_types.push_back(next_token.content);
5372 std::vector<int32_t> acc_types;
5373 while(!stack_types.empty()) {
5375 if(result.type_array.empty()) {
5376 e->
mode = fif_mode::error;
5380 acc_types.insert(acc_types.end(), result.type_array.begin(), result.type_array.end());
5381 stack_types.pop_back();
5385 int32_t count_types = int32_t(acc_types.size());
5390 if(t.is_string ==
false && t.content ==
";") {
5391 auto string_end = t.content.data();
5393 auto nstr = std::string(name_token.content);
5394 int32_t old_word = -1;
5396 old_word = it->second;
5410 e->
report_error(
"reached the end of a definition source without a ; terminator");
6069 auto& w = std::get< fif::compiled_word_instance>(env.
dict.
all_instances.back());
6070 w.implementation = fn;
6071 w.stack_types_count = int32_t(types.size());
6110 memcpy(&fa, &ia, 4);
6111 memcpy(&fb, &ib, 4);
6135 memcpy(&fa, &ia, 8);
6136 memcpy(&fb, &ib, 8);
6223 memcpy(&fa, &ia, 4);
6224 memcpy(&fb, &ib, 4);
6248 memcpy(&fa, &ia, 8);
6249 memcpy(&fb, &ib, 8);
6315 memcpy(&fa, &ia, 4);
6316 memcpy(&fb, &ib, 4);
6340 memcpy(&fa, &ia, 8);
6341 memcpy(&fb, &ib, 8);
6407 memcpy(&fa, &ia, 4);
6408 memcpy(&fb, &ib, 4);
6432 memcpy(&fa, &ia, 8);
6433 memcpy(&fb, &ib, 8);
6478 memcpy(&fa, &ia, 4);
6479 memcpy(&fb, &ib, 4);
6503 memcpy(&fa, &ia, 8);
6504 memcpy(&fb, &ib, 8);
6549 memcpy(&fa, &ia, 4);
6550 memcpy(&fb, &ib, 4);
6574 memcpy(&fa, &ia, 8);
6575 memcpy(&fb, &ib, 8);
6627 e->
report_error(
"cannot turn a word immediate in compiled code");
6628 e->
mode = fif_mode::error;
6634 e->
report_error(
"cannot mark a specialized word as immediate");
6635 e->
mode = fif_mode::error;
6660 std::vector<int32_t> subs;
6661 auto mem_type =
resolve_span_type(std::span<int32_t const>(ptr_type, ptr_type + 4), subs, *e);
6666 auto ptr = malloc(8);
6668 memcpy(ptr, &dat, 8);
6671 std::vector<int32_t> subs;
6672 auto mem_type =
resolve_span_type(std::span<int32_t const>(ptr_type, ptr_type + 4), subs, *e);
6677 std::vector<int32_t> subs;
6678 auto mem_type =
resolve_span_type(std::span<int32_t const>(ptr_type, ptr_type + 4), subs, *e);
6690 auto decomp = e->
dict.
type_array[ptr_type].decomposed_types_start;
6703 int64_t* ptr = (int64_t*)a;
6720 auto decomp = e->
dict.
type_array[ptr_type].decomposed_types_start;
6741 int64_t* ptr_val = (int64_t*)v;
6742 auto effective_type = pointer_contents;
6744 if(pointer_contents != -1 && e->
dict.
type_array[pointer_contents].refcounted_type()) {
6745 if(e->
dict.
type_array[pointer_contents].decomposed_types_count >= 2) {
6746 auto child_index = e->
dict.
type_array[pointer_contents].decomposed_types_start + 1;
6749 if(e->
dict.
type_array[pointer_contents].single_member_struct()) {
6750 effective_type = child_type;
6756 s.
push_back_main(pointer_contents, *(int32_t*)(ptr_val),
nullptr);
6757 else if(effective_type ==
fif_u32)
6759 else if(effective_type ==
fif_i16)
6760 s.
push_back_main(pointer_contents, *(int16_t*)(ptr_val),
nullptr);
6761 else if(effective_type ==
fif_u16)
6762 s.
push_back_main(pointer_contents, *(uint16_t*)(ptr_val),
nullptr);
6763 else if(effective_type ==
fif_i8)
6764 s.
push_back_main(pointer_contents, *(int8_t*)(ptr_val),
nullptr);
6789 auto decomp = e->
dict.
type_array[ptr_type].decomposed_types_start;
6801 int64_t* ptr_val = (int64_t*)v;
6802 auto effective_type = pointer_contents;
6804 if(pointer_contents != -1 && e->
dict.
type_array[pointer_contents].refcounted_type()) {
6805 if(e->
dict.
type_array[pointer_contents].decomposed_types_count >= 2) {
6806 auto child_index = e->
dict.
type_array[pointer_contents].decomposed_types_start + 1;
6809 if(e->
dict.
type_array[pointer_contents].single_member_struct()) {
6810 effective_type = child_type;
6816 s.
push_back_main(pointer_contents, *(int32_t*)(ptr_val),
nullptr);
6817 else if(effective_type ==
fif_u32)
6819 else if(effective_type ==
fif_i16)
6820 s.
push_back_main(pointer_contents, *(int16_t*)(ptr_val),
nullptr);
6821 else if(effective_type ==
fif_u16)
6822 s.
push_back_main(pointer_contents, *(uint16_t*)(ptr_val),
nullptr);
6823 else if(effective_type ==
fif_i8)
6824 s.
push_back_main(pointer_contents, *(int8_t*)(ptr_val),
nullptr);
6842 auto decomp = e->
dict.
type_array[ptr_type].decomposed_types_start;
6860 int64_t* ptr_val = (int64_t*)v;
6869 auto effective_type = pointer_contents;
6870 if(pointer_contents != -1 && e->
dict.
type_array[pointer_contents].refcounted_type()) {
6871 if(e->
dict.
type_array[pointer_contents].decomposed_types_count >= 2) {
6872 auto child_index = e->
dict.
type_array[pointer_contents].decomposed_types_start + 1;
6875 if(e->
dict.
type_array[pointer_contents].single_member_struct()) {
6876 effective_type = child_type;
6882 memcpy(ptr_val, &to_write, 4);
6884 memcpy(ptr_val, &to_write, 2);
6886 memcpy(ptr_val, &to_write, 1);
6888 memcpy(ptr_val, &to_write, 8);
6904 auto decomp = e->
dict.
type_array[ptr_type].decomposed_types_start;
6916 int64_t* ptr_val = (int64_t*)v;
6920 auto effective_type = pointer_contents;
6921 if(pointer_contents != -1 && e->
dict.
type_array[pointer_contents].refcounted_type()) {
6922 if(e->
dict.
type_array[pointer_contents].decomposed_types_count >= 2) {
6923 auto child_index = e->
dict.
type_array[pointer_contents].decomposed_types_start + 1;
6926 if(e->
dict.
type_array[pointer_contents].single_member_struct()) {
6927 effective_type = child_type;
6933 memcpy(ptr_val, &to_write, 4);
6935 memcpy(ptr_val, &to_write, 2);
6937 memcpy(ptr_val, &to_write, 1);
6939 memcpy(ptr_val, &to_write, 8);
6958 e->
report_error(
"pointer cast was unable to read the word describing the pointer type");
6959 e->
mode = fif_mode::error;
6963 bool bad_type = ptype.is_string;
6965 if(resolved_type == -1) {
6968 if(e->
dict.
type_array[resolved_type].decomposed_types_count == 0) {
6976 e->
report_error(
"pointer attempted to be cast to a non pointer type");
6977 e->
mode = fif_mode::error;
6987 auto compile_bytes = e->
compiler_stack.back()->bytecode_compilation_progress();
6991 memcpy(&imm_bytes, &imm, 8);
6992 compile_bytes->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
6993 compile_bytes->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
6994 compile_bytes->push_back(resolved_type);
7002 e->
report_error(
"sizeof was unable to read the word describing the type");
7003 e->
mode = fif_mode::error;
7007 bool bad_type = ptype.is_string;
7009 if(resolved_type == -1) {
7011 e->
mode = fif_mode::error;
7020 auto compile_bytes = e->
compiler_stack.back()->bytecode_compilation_progress();
7024 memcpy(&imm_bytes, &imm, 8);
7025 compile_bytes->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
7026 compile_bytes->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
7075 auto val = malloc(
size_t(bytes));
7076 memset(val, 0,
size_t(bytes));
7095 auto res =
LLVMBuildMemCpy(e->llvm_builder, dest_ptr, 1, source_ptr, 1, bytes);
7105 memcpy((
void*)dest_ptr, (
void*)source_ptr,
size_t(bytes));
7127 void* ptr = (
void*)a;
7137 char* string_ptr =
nullptr;
7138 memcpy(&string_ptr, p + 2, 8);
7142 e->
report_error(
"could not create a let with that name");
7143 e->
mode = fif_mode::error;
7152 e->
report_error(
"let was unable to read the declaration name");
7153 e->
mode = fif_mode::error;
7161 e->
report_error(
"could not create a let with that name");
7162 e->
mode = fif_mode::error;
7165 }
else if(e->
mode == fif_mode::compiling_llvm) {
7168 e->
report_error(
"could not create a let with that name");
7169 e->
mode = fif_mode::error;
7172 }
else if(e->
mode == fif_mode::compiling_bytecode) {
7175 e->
report_error(
"could not create a let with that name");
7176 e->
mode = fif_mode::error;
7179 auto compile_bytes = e->
compiler_stack.back()->bytecode_compilation_progress();
7183 memcpy(&imm_bytes, &imm, 8);
7184 compile_bytes->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
7185 compile_bytes->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
7188 char const* cptr = string_constant.data();
7190 memcpy(&let_addr, &cptr, 8);
7191 compile_bytes->push_back(int32_t(let_addr & 0xFFFFFFFF));
7192 compile_bytes->push_back(int32_t((let_addr >> 32) & 0xFFFFFFFF));
7203 char* string_ptr =
nullptr;
7204 memcpy(&string_ptr, p + 2, 8);
7208 e->
report_error(
"could not create a var with that name");
7209 e->
mode = fif_mode::error;
7219 e->
report_error(
"war was unable to read the declaration name");
7220 e->
mode = fif_mode::error;
7228 e->
report_error(
"could not create a var with that name");
7229 e->
mode = fif_mode::error;
7233 }
else if(e->
mode == fif_mode::compiling_llvm) {
7237 e->
report_error(
"could not create a var with that name");
7238 e->
mode = fif_mode::error;
7243 }
else if(e->
mode == fif_mode::compiling_bytecode) {
7246 e->
report_error(
"could not create a var with that name");
7247 e->
mode = fif_mode::error;
7250 auto compile_bytes = e->
compiler_stack.back()->bytecode_compilation_progress();
7254 memcpy(&imm_bytes, &imm, 8);
7255 compile_bytes->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
7256 compile_bytes->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
7259 char const* cptr = string_constant.data();
7261 memcpy(&let_addr, &cptr, 8);
7262 compile_bytes->push_back(int32_t(let_addr & 0xFFFFFFFF));
7263 compile_bytes->push_back(int32_t((let_addr >> 32) & 0xFFFFFFFF));
7275 e->
report_error(
"global was unable to read the declaration name");
7276 e->
mode = fif_mode::error;
7290 if(ptr->get_type() == control_structure::globals) {
7295 e->
mode = fif_mode::error;
7305 e->
mode = fif_mode::error;
7310 int32_t index_value = *(p + 2);
7312 assert(1 + index_value < e->dict.type_array[stype].decomposed_types_count);
7313 auto child_index = e->
dict.
type_array[stype].decomposed_types_start + 1 + index_value;
7321 auto children = (int64_t*)(ptr);
7322 auto child_data = children[index_value];
7346 auto index_value = parse_int(index_str.content);
7349 if(stype == -1 || e->
dict.
type_array[stype].refcounted_type() ==
false) {
7350 e->
report_error(
"attempted to use a structure operation on a non-structure type");
7351 e->
mode = fif_mode::error;
7355 assert(1 + index_value < e->dict.type_array[stype].decomposed_types_count);
7356 auto child_index = e->
dict.
type_array[stype].decomposed_types_start + 1 + index_value;
7389 auto children = (int64_t*)(ptr);
7390 auto child_data = children[index_value];
7412 }
else if(e->
mode == fif_mode::compiling_bytecode) {
7413 auto compile_bytes = e->
compiler_stack.back()->bytecode_compilation_progress();
7417 memcpy(&imm_bytes, &imm, 8);
7418 compile_bytes->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
7419 compile_bytes->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
7420 compile_bytes->push_back(index_value);
7428 int32_t index_value = *(p + 2);
7430 assert(1 + index_value < e->dict.type_array[stype].decomposed_types_count);
7431 auto child_index = e->
dict.
type_array[stype].decomposed_types_start + 1 + index_value;
7441 auto children = (int64_t*)(ptr);
7442 auto child_data = children[index_value];
7460 auto index_value = parse_int(index_str.content);
7463 if(stype == -1 || e->
dict.
type_array[stype].refcounted_type() ==
false) {
7464 e->
report_error(
"attempted to use a structure operation on a non-structure type");
7465 e->
mode = fif_mode::error;
7469 assert(1 + index_value < e->dict.type_array[stype].decomposed_types_count);
7470 auto child_index = e->
dict.
type_array[stype].decomposed_types_start + 1 + index_value;
7503 auto children = (int64_t*)(ptr);
7504 auto child_data = children[index_value];
7520 }
else if(e->
mode == fif_mode::compiling_bytecode) {
7521 auto compile_bytes = e->
compiler_stack.back()->bytecode_compilation_progress();
7525 memcpy(&imm_bytes, &imm, 8);
7526 compile_bytes->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
7527 compile_bytes->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
7528 compile_bytes->push_back(index_value);
7536 int32_t index_value = *(p + 2);
7538 assert(1 + index_value < e->dict.type_array[stype].decomposed_types_count);
7539 auto child_index = e->
dict.
type_array[stype].decomposed_types_start + 1 + index_value;
7549 auto children = (int64_t*)(ptr);
7566 auto index_value = parse_int(index_str.content);
7569 if(stype == -1 || e->
dict.
type_array[stype].refcounted_type() ==
false) {
7570 e->
report_error(
"attempted to use a structure operation on a non-structure type");
7571 e->
mode = fif_mode::error;
7575 assert(1 + index_value < e->dict.type_array[stype].decomposed_types_count);
7576 auto child_index = e->
dict.
type_array[stype].decomposed_types_start + 1 + index_value;
7609 auto children = (int64_t*)(ptr);
7625 }
else if(e->
mode == fif_mode::compiling_bytecode) {
7626 auto compile_bytes = e->
compiler_stack.back()->bytecode_compilation_progress();
7630 memcpy(&imm_bytes, &imm, 8);
7631 compile_bytes->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
7632 compile_bytes->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
7633 compile_bytes->push_back(index_value);
7643 int32_t index_value = *(p + 2);
7646 if(ptr_type == -1) {
7647 e->
report_error(
"attempted to use a pointer operation on a non-pointer type");
7648 e->
mode = fif_mode::error;
7651 auto decomp = e->
dict.
type_array[ptr_type].decomposed_types_start;
7653 e->
report_error(
"attempted to use a struct-pointer operation on a non-struct-pointer type");
7654 e->
mode = fif_mode::error;
7659 assert(1 + index_value < e->dict.type_array[stype].decomposed_types_count);
7660 auto child_index = e->
dict.
type_array[stype].decomposed_types_start + 1 + index_value;
7664 int32_t type_storage[] = {
fif_ptr, std::numeric_limits<int32_t>::max(), child_type, -1 };
7665 std::vector<int32_t> subs;
7666 auto child_ptr_type =
resolve_span_type(std::span<int32_t const>(type_storage, type_storage + 4), subs, *e);
7672 auto children = (int64_t*)(ptr);
7673 auto child_ptr = children + index_value;
7675 int32_t type_storage[] = {
fif_ptr, std::numeric_limits<int32_t>::max(), child_type, -1 };
7676 std::vector<int32_t> subs;
7677 auto child_ptr_type =
resolve_span_type(std::span<int32_t const>(type_storage, type_storage + 4), subs, *e);
7687 auto index_value = parse_int(index_str.content);
7690 if(ptr_type == -1) {
7691 e->
report_error(
"attempted to use a pointer operation on a non-pointer type");
7692 e->
mode = fif_mode::error;
7696 auto decomp = e->
dict.
type_array[ptr_type].decomposed_types_start;
7699 e->
report_error(
"attempted to use a struct-pointer operation on a non-struct-pointer type");
7700 e->
mode = fif_mode::error;
7706 if(stype == -1 || e->
dict.
type_array[stype].refcounted_type() ==
false) {
7707 e->
report_error(
"attempted to use a structure operation on a non-structure type");
7708 e->
mode = fif_mode::error;
7712 assert(1 + index_value < e->dict.type_array[stype].decomposed_types_count);
7713 auto child_index = e->
dict.
type_array[stype].decomposed_types_start + 1 + index_value;
7716 int32_t type_storage[] = {
fif_ptr, std::numeric_limits<int32_t>::max(), child_type, -1 };
7717 std::vector<int32_t> subs;
7718 auto child_ptr_type =
resolve_span_type(std::span<int32_t const>(type_storage, type_storage + 4), subs, *e);
7738 auto children = (int64_t*)(ptr);
7739 auto child_ptr = children + index_value;
7747 }
else if(e->
mode == fif_mode::compiling_bytecode) {
7748 auto compile_bytes = e->
compiler_stack.back()->bytecode_compilation_progress();
7752 memcpy(&imm_bytes, &imm, 8);
7753 compile_bytes->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
7754 compile_bytes->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
7755 compile_bytes->push_back(index_value);
7770 auto child_index = e->
dict.
type_array[stype].decomposed_types_start + 1;
7779 auto children = (int64_t*)(ptr);
7781 for(int32_t i = 0; i < children_count; ++i) {
7782 auto child_index = e->
dict.
type_array[stype].decomposed_types_start + 1 + i;
7803 auto child_index = e->
dict.
type_array[stype].decomposed_types_start + 1;
7812 for(int32_t i = 0; i < children_count; ++i) {
7813 auto child_index = e->
dict.
type_array[stype].decomposed_types_start + 1 + i;
7824 auto child_index = e->
dict.
type_array[stype].decomposed_types_start + 1;
7832 auto children = (int64_t*)(ptr);
7834 for(int32_t i = 0; i < children_count; ++i) {
7835 auto child_index = e->
dict.
type_array[stype].decomposed_types_start + 1 + i;
7845 }
else if(e->
mode == fif_mode::compiling_bytecode) {
7846 auto compile_bytes = e->
compiler_stack.back()->bytecode_compilation_progress();
7851 memcpy(&imm_bytes, &imm, 8);
7852 compile_bytes->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
7853 compile_bytes->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
7858 memcpy(&imm_bytes, &str_const, 8);
7859 compile_bytes->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
7860 compile_bytes->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
7875 auto child_index = e->
dict.
type_array[stype].decomposed_types_start + 1 + 0;
7883 auto children = (int64_t*)(ptr);
7885 for(int32_t i = 0; i < children_count; ++i) {
7886 auto child_index = e->
dict.
type_array[stype].decomposed_types_start + 1 + i;
7907 assert(children_count == 1);
7908 auto child_index = e->
dict.
type_array[stype].decomposed_types_start + 1 + 0;
7916 for(int32_t i = 0; i < children_count; ++i) {
7917 auto child_index = e->
dict.
type_array[stype].decomposed_types_start + 1 + i;
7930 auto child_index = e->
dict.
type_array[stype].decomposed_types_start + 1 + 0;
7937 auto children = (int64_t*)(ptr);
7939 for(int32_t i = 0; i < children_count; ++i) {
7940 auto child_index = e->
dict.
type_array[stype].decomposed_types_start + 1 + i;
7953 }
else if(e->
mode == fif_mode::compiling_bytecode) {
7954 auto compile_bytes = e->
compiler_stack.back()->bytecode_compilation_progress();
7959 memcpy(&imm_bytes, &imm, 8);
7960 compile_bytes->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
7961 compile_bytes->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
7966 memcpy(&imm_bytes, &str_const, 8);
7967 compile_bytes->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
7968 compile_bytes->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
7983 auto child_index = e->
dict.
type_array[stype].decomposed_types_start + 1 + 0;
7992 auto new_ptr = e->
dict.
type_array[stype].interpreter_zero(stype, e);
7994 auto children = (int64_t*)(ptr);
7995 auto new_children = (int64_t*)(new_ptr);
7997 for(int32_t i = 0; i < children_count; ++i) {
7998 auto child_index = e->
dict.
type_array[stype].decomposed_types_start + 1 + i;
8024 auto child_index = e->
dict.
type_array[stype].decomposed_types_start + 1 + 0;
8032 auto new_struct_expr = e->
dict.
type_array[stype].zero_constant(e->llvm_context, stype, e);
8034 for(int32_t i = 0; i < children_count; ++i) {
8035 auto child_index = e->
dict.
type_array[stype].decomposed_types_start + 1 + i;
8050 auto child_index = e->
dict.
type_array[stype].decomposed_types_start + 1 + 0;
8058 auto new_ptr = e->
dict.
type_array[stype].interpreter_zero(stype, e);
8060 auto children = (int64_t*)(ptr);
8061 auto new_children = (int64_t*)(new_ptr);
8063 for(int32_t i = 0; i < children_count; ++i) {
8064 auto child_index = e->
dict.
type_array[stype].decomposed_types_start + 1 + i;
8083 }
else if(e->
mode == fif_mode::compiling_bytecode) {
8084 auto compile_bytes = e->
compiler_stack.back()->bytecode_compilation_progress();
8089 memcpy(&imm_bytes, &imm, 8);
8090 compile_bytes->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
8091 compile_bytes->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
8096 memcpy(&imm_bytes, &str_const, 8);
8097 compile_bytes->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
8098 compile_bytes->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
8108 auto type = *(p + 2);
8115 env->
report_error(
"make was unable to read the word describing the type");
8116 env->
mode = fif_mode::error;
8126 if(resolved_type == -1) {
8127 env->
report_error(
"make was unable to resolve the type");
8128 env->
mode = fif_mode::error;
8137 auto compile_bytes = env->
compiler_stack.back()->bytecode_compilation_progress();
8138 if(compile_bytes && env->
mode == fif_mode::compiling_bytecode) {
8141 memcpy(&imm_bytes, &imm, 8);
8142 compile_bytes->push_back(int32_t(imm_bytes & 0xFFFFFFFF));
8143 compile_bytes->push_back(int32_t((imm_bytes >> 32) & 0xFFFFFFFF));
8144 compile_bytes->push_back(resolved_type);
8147 if(env->
mode == fif_mode::compiling_llvm) {
8150 val = env->
dict.
type_array[resolved_type].zero_constant(env->llvm_context, resolved_type, env);
8152 env->
report_error(
"attempted to compile a type without an llvm representation");
8153 env->
mode = fif_mode::error;
8159 if(env->
mode == fif_mode::interpreting) {
8161 data = env->
dict.
type_array[resolved_type].interpreter_zero(resolved_type, env);
8173 e->
report_error(
"attempted to define a struct inside a definition");
8179 e->
report_error(
"attempted to define a struct without a source");
8187 e->
report_error(
"attempted to redefine an existing type");
8192 std::vector<int32_t> stack_types;
8193 std::vector<std::string_view> names;
8194 int32_t max_variable = -1;
8195 bool read_extra_count =
false;
8199 if(next_token.content.length() == 0 || next_token.content ==
";") {
8202 if(next_token.content ==
"$") {
8203 read_extra_count =
true;
8208 if(result.type_array.empty()) {
8209 e->
mode = fif_mode::error;
8213 stack_types.insert(stack_types.end(), result.type_array.begin(), result.type_array.end());
8214 max_variable = std::max(max_variable, result.max_variable);
8217 if(nnext_token.content.length() == 0 || nnext_token.content ==
";") {
8218 e->
report_error(
"struct contained a type without a matching name");
8222 names.push_back(nnext_token.content);
8225 int32_t extra_count = 0;
8226 if(read_extra_count) {
8229 if(next_next_token.content !=
";") {
8230 e->
report_error(
"struct definition ended incorrectly");
8234 extra_count = parse_int(next_token.content);
8237 make_struct_type(name_token.content, std::span<int32_t const>{stack_types.begin(), stack_types.end()}, names, *e, max_variable + 1, extra_count);
8245 e->
report_error(
"attempted to define an export inside a definition");
8251 e->
report_error(
"attempted to define an export without a source");
8258 std::vector<int32_t> stack_types;
8259 std::vector<std::string_view> names;
8260 int32_t max_variable = -1;
8261 bool read_extra_count =
false;
8265 if(next_token.content.length() == 0 || next_token.content ==
";") {
8268 names.push_back(next_token.content);
8271 auto fn_to_export = names.back();
8274 for(
auto tyn : names) {
8277 e->
mode = fif_mode::error;
8281 stack_types.push_back(result);
8284 make_exportable_function(std::string(name_token.content), std::string(fn_to_export), stack_types, { }, *e);
8290 env->
report_error(
"make was unable to read name of word");
8291 env->
mode = fif_mode::error;
8312 if(
token.content ==
"))" &&
token.is_string ==
false)
8314 if(
token.content ==
"((" &&
token.is_string ==
false)
8316 if(
token.content ==
"" &&
token.is_string ==
false)
8328 while(source.length() > 0 && source[0] !=
'\n' && source[0] !=
'\r')
8329 source = source.substr(1);
8839 memcpy(&fin, &v, 8);
8840 float fout = float(fin);
8842 memcpy(&iout, &fout, 4);
8861 memcpy(&fin, &v, 4);
8862 double fout = double(fin);
8864 memcpy(&iout, &fout, 8);
8883 memcpy(&fin, &v, 4);
8884 int64_t iout = int8_t(fin);
8902 float fout = float(v);
8904 memcpy(&iout, &fout, 4);
8922 float fout = float(v);
8924 memcpy(&iout, &fout, 4);
8942 double fout = double(v);
8944 memcpy(&iout, &fout, 8);
8962 double fout = double(v);
8964 memcpy(&iout, &fout, 8);
8983 memcpy(&fin, &v, 4);
8984 int64_t iout = int16_t(fin);
9003 memcpy(&fin, &v, 4);
9004 int64_t iout = int32_t(fin);
9023 memcpy(&fin, &v, 4);
9024 int64_t iout = int64_t(fin);
9043 memcpy(&fin, &v, 4);
9044 int64_t iout = int64_t(
uint8_t(fin));
9063 memcpy(&fin, &v, 4);
9064 int64_t iout = int64_t(uint16_t(fin));
9083 memcpy(&fin, &v, 4);
9084 int64_t iout = int64_t(
uint32_t(fin));
9103 memcpy(&fin, &v, 4);
9104 int64_t iout = int64_t(
uint64_t(fin));
9124 memcpy(&fin, &v, 8);
9125 int64_t iout = int8_t(fin);
9144 memcpy(&fin, &v, 8);
9145 int64_t iout = int16_t(fin);
9164 memcpy(&fin, &v, 8);
9165 int64_t iout = int32_t(fin);
9184 memcpy(&fin, &v, 8);
9185 int64_t iout = int64_t(fin);
9204 memcpy(&fin, &v, 8);
9205 int64_t iout = int64_t(
uint8_t(fin));
9224 memcpy(&fin, &v, 8);
9225 int64_t iout = int64_t(uint16_t(fin));
9244 memcpy(&fin, &v, 8);
9245 int64_t iout = int64_t(
uint32_t(fin));
9264 memcpy(&fin, &v, 8);
9265 int64_t iout = int64_t(
uint64_t(fin));
9857 auto preinterpreted =
9858 ": over >r dup r> swap ; "
9859 ": nip >r drop r> ; "
9860 ": tuck swap over ; "
9861 ": 2dup >r dup r> dup >r swap r> ; "
9863 " buf-alloc swap >r >r dup r> r> buf-copy swap buf-free "
9865 ":struct dy-array-block ptr(nil) memory i32 size i32 capacity i32 refcount ; "
9866 ":struct dy-array ptr(dy-array-block) ptr $ 1 ; "
9867 ":s init dy-array($0) s: "
9868 " sizeof dy-array-block buf-alloc ptr-cast ptr(dy-array-block) swap .ptr! "
9870 ":s dup dy-array($0) s: "
9871 " use-base dup .ptr@ "
9872 " .refcount dup @ 1 + swap ! "
9874 ":s drop dy-array($0) s: .ptr@ "
9875 " .refcount dup @ -1 + "
9880 " .ptr@ dup .size let sz .memory let mem "
9885 " sz @ sizeof $0 * mem @ buf-add ptr-cast ptr($0) @@ "
9889 " .ptr@ ptr-cast ptr(nil) buf-free "
9893 ":s push dy-array($0) $0 s: "
9896 " dup dup .size let sz .capacity let cap .memory let mem"
9897 " sz @ sizeof $0 * cap @ >= if "
9899 " cap @ sizeof $0 * "
9900 " cap @ 1 + 2 * sizeof $0 * "
9905 " sz @ sizeof $0 * mem @ buf-add ptr-cast ptr($0) val swap !! "
9908 ":s pop dy-array($0) s: "
9910 " dup .size let sz .memory let mem"
9913 " sz @ sizeof $0 * mem @ buf-add ptr-cast ptr($0) @@ "
9918 ":s empty? dy-array($0) s: "
9919 " .ptr@ .size @ <= 0 "
9921 ":s index-into dy-array($0) i32 s:"
9922 " let index .ptr@ .memory @ sizeof $0 index * swap buf-add ptr-cast ptr($0) "
9924 ":s size dy-array($0) s:"
var_data * get_global_var(std::string const &name)
let_data * get_global_let(std::string const &name)
compiler_globals_layer(opaque_compiler_data *p, environment &env)
ankerl::unordered_dense::map< std::string, std::unique_ptr< let_data > > global_lets
var_data * create_global_var(std::string const &name, int32_t type)
virtual control_structure get_type() override
ankerl::unordered_dense::map< std::string, std::unique_ptr< var_data > > global_vars
let_data * create_global_let(std::string const &name, int32_t type, int64_t data, LLVMValueRef expression)
std::unique_ptr< opaque_compiler_data > data
LLVMBasicBlockRef true_block
conditional_scope(opaque_compiler_data *p, environment &e, state_stack &entry_state)
size_t bytecode_second_branch_point
std::unique_ptr< state_stack > first_branch_state
size_t bytecode_first_branch_point
bool typechecking_failed_on_first_branch
LLVMBasicBlockRef parent_block
std::unique_ptr< state_stack > iworking_state
virtual control_structure get_type() override
LLVMBasicBlockRef false_block
virtual state_stack * working_state() override
bool interpreter_skipped_second_branch
void commit_first_branch(environment &)
virtual void set_working_state(std::unique_ptr< state_stack > p) override
LLVMValueRef branch_condition
virtual bool finish(environment &) override
std::unique_ptr< state_stack > initial_state
bool interpreter_skipped_first_branch
bool initial_typechecking_failed
std::vector< word > word_array
std::vector< int32_t > all_compiled
ankerl::unordered_dense::map< std::string, int32_t > words
std::vector< word_types > all_instances
ankerl::unordered_dense::map< std::string, int32_t > types
std::vector< type > type_array
std::vector< int32_t > all_stack_types
virtual control_structure get_type() override
bool initial_typechecking_failed
virtual state_stack * working_state() override
std::vector< LLVMValueRef > phinodes
virtual void set_working_state(std::unique_ptr< state_stack > p) override
std::unique_ptr< state_stack > initial_state
size_t end_of_loop_branch
std::unique_ptr< state_stack > iworking_state
do_loop_scope(opaque_compiler_data *p, environment &e, state_stack &entry_state)
void at_until(environment &)
LLVMBasicBlockRef pre_block
virtual bool finish(environment &) override
std::string_view entry_source
LLVMBasicBlockRef body_block
std::vector< std::unique_ptr< opaque_compiler_data > > compiler_stack
std::vector< LLVMValueRef > exported_functions
std::function< void(std::string_view)> report_error
std::vector< std::string_view > source_stack
std::string_view get_string_constant(std::string_view data)
ankerl::unordered_dense::set< std::unique_ptr< char[]>, indirect_string_hash, indirect_string_eq > string_constants
std::vector< import_item > imported_functions
virtual std::vector< int32_t > * type_substitutions() override
virtual bool finish(environment &) override
std::vector< int32_t > compiled_bytes
std::unique_ptr< state_stack > iworking_state
virtual LLVMBasicBlockRef * llvm_block() override
function_scope(opaque_compiler_data *p, environment &e, state_stack &entry_state, int32_t for_word, int32_t for_instance)
virtual state_stack * working_state() override
virtual std::vector< int32_t > * bytecode_compilation_progress() override
LLVMBasicBlockRef current_block
virtual int32_t instance_id() override
virtual int32_t word_id() override
virtual void set_working_state(std::unique_ptr< state_stack > p) override
virtual ankerl::unordered_dense::map< uint64_t, typecheck_3_record > * typecheck_record() override
virtual LLVMValueRef llvm_function() override
virtual control_structure get_type() override
std::vector< int32_t > type_subs
std::unique_ptr< state_stack > initial_state
virtual int64_t main_data_back(size_t index) const override
virtual void set_return_ex(size_t index, LLVMValueRef value) override
virtual void set_return_ex_back(size_t index, LLVMValueRef value) override
virtual void pop_main() override
virtual void set_main_data(size_t index, int64_t value) override
std::vector< int64_t > return_datas
virtual void resize(size_t main_sz, size_t return_sz) override
virtual void set_return_data(size_t index, int64_t value) override
virtual void pop_return() override
virtual LLVMValueRef main_ex(size_t index) const override
virtual void copy_into(state_stack const &other) override
std::vector< int64_t > main_datas
virtual void push_back_main(int32_t type, int64_t data, LLVMValueRef expr) override
virtual LLVMValueRef main_ex_back(size_t index) const override
virtual void set_main_ex_back(size_t index, LLVMValueRef value) override
virtual void set_main_data_back(size_t index, int64_t value) override
virtual LLVMValueRef return_ex_back(size_t index) const override
virtual stack_type get_type() const override
virtual void push_back_return(int32_t type, int64_t data, LLVMValueRef expr) override
virtual int64_t return_data_back(size_t index) const override
virtual LLVMValueRef return_ex(size_t index) const override
virtual void set_return_data_back(size_t index, int64_t value) override
virtual void move_into(state_stack &&other) override
virtual std::unique_ptr< state_stack > copy() const override
virtual void set_main_ex(size_t index, LLVMValueRef value) override
virtual int64_t return_data(size_t index) const override
virtual int64_t main_data(size_t index) const override
virtual int64_t return_data_back(size_t index) const override
virtual void resize(size_t main_sz, size_t return_sz) override
virtual void set_main_ex_back(size_t index, LLVMValueRef value) override
std::vector< LLVMValueRef > main_exs
virtual std::unique_ptr< state_stack > copy() const override
virtual void pop_return() override
virtual void push_back_return(int32_t type, int64_t data, LLVMValueRef expr) override
virtual LLVMValueRef return_ex_back(size_t index) const override
virtual stack_type get_type() const override
virtual void set_return_ex_back(size_t index, LLVMValueRef value) override
virtual void move_into(state_stack &&other) override
virtual LLVMValueRef main_ex_back(size_t index) const override
virtual LLVMValueRef return_ex(size_t index) const override
virtual void copy_into(state_stack const &other) override
std::vector< LLVMValueRef > return_exs
virtual int64_t main_data(size_t index) const override
virtual void set_return_ex(size_t index, LLVMValueRef value) override
virtual void push_back_main(int32_t type, int64_t data, LLVMValueRef expr) override
virtual void set_return_data(size_t index, int64_t value) override
virtual void set_main_ex(size_t index, LLVMValueRef value) override
virtual int64_t main_data_back(size_t index) const override
virtual int64_t return_data(size_t index) const override
virtual void set_main_data_back(size_t index, int64_t value) override
virtual LLVMValueRef main_ex(size_t index) const override
virtual void pop_main() override
virtual void set_main_data(size_t index, int64_t value) override
virtual void set_return_data_back(size_t index, int64_t value) override
virtual var_data * create_var(std::string const &name, int32_t type) override
ankerl::unordered_dense::map< std::string, std::unique_ptr< var_data > > vars
virtual let_data * get_let(std::string const &name) override
virtual let_data * create_let(std::string const &name, int32_t type, int64_t data, LLVMValueRef expression) override
ankerl::unordered_dense::map< std::string, std::unique_ptr< let_data > > lets
virtual var_data * get_var(std::string const &name) override
locals_holder(opaque_compiler_data *p, environment &env)
virtual bool finish(environment &env) override
virtual var_data * get_var(std::string const &name) override
virtual ankerl::unordered_dense::map< uint64_t, typecheck_3_record > * typecheck_record() override
opaque_compiler_data * interpreted_link
virtual state_stack * working_state() override
virtual void set_working_state(std::unique_ptr< state_stack > p) override
mode_switch_scope(opaque_compiler_data *p, environment &env, fif_mode running_mode)
virtual var_data * create_var(std::string const &name, int32_t type) override
virtual control_structure get_type() override
virtual let_data * create_let(std::string const &name, int32_t type, int64_t data, LLVMValueRef expression) override
virtual let_data * get_let(std::string const &name) override
opaque_compiler_data(opaque_compiler_data *parent)
virtual LLVMBasicBlockRef * llvm_block()
virtual state_stack * working_state()
virtual control_structure get_type()
virtual void set_working_state(std::unique_ptr< state_stack > p)
virtual std::vector< int32_t > * bytecode_compilation_progress()
virtual ankerl::unordered_dense::map< uint64_t, typecheck_3_record > * typecheck_record()
virtual int32_t word_id()
virtual let_data * create_let(std::string const &name, int32_t type, int64_t data, LLVMValueRef expression)
virtual let_data * get_let(std::string const &name)
virtual bool finish(environment &env)
virtual int32_t instance_id()
virtual LLVMValueRef llvm_function()
virtual ~opaque_compiler_data()=default
virtual var_data * create_var(std::string const &name, int32_t type)
virtual std::vector< int32_t > * type_substitutions()
opaque_compiler_data * parent
virtual var_data * get_var(std::string const &name)
virtual let_data * get_let(std::string const &name) override
ankerl::unordered_dense::map< std::string, std::unique_ptr< let_data > > global_lets
virtual var_data * create_var(std::string const &name, int32_t type) override
virtual let_data * create_let(std::string const &name, int32_t type, int64_t data, LLVMValueRef expression) override
virtual bool finish(environment &env) override
virtual var_data * get_var(std::string const &name) override
std::unique_ptr< state_stack > interpreter_state
virtual state_stack * working_state() override
outer_interpreter(environment &env)
virtual void set_working_state(std::unique_ptr< state_stack > p) override
ankerl::unordered_dense::map< std::string, std::unique_ptr< var_data > > global_vars
virtual control_structure get_type() override
runtime_function_scope(opaque_compiler_data *p, environment &e)
virtual bool finish(environment &) override
virtual control_structure get_type() override
virtual void copy_into(state_stack const &other)=0
virtual stack_type get_type() const =0
virtual void set_return_ex_back(size_t index, LLVMValueRef value)=0
void set_main_type(size_t index, int32_t type)
virtual LLVMValueRef return_ex(size_t index) const =0
void set_return_type_back(size_t index, int32_t type)
void mark_used_from_return(size_t count)
virtual void set_return_data_back(size_t index, int64_t value)=0
virtual LLVMValueRef return_ex_back(size_t index) const =0
virtual void set_main_data(size_t index, int64_t value)=0
virtual void resize(size_t main_sz, size_t return_sz)=0
virtual void set_main_data_back(size_t index, int64_t value)=0
virtual std::unique_ptr< state_stack > copy() const =0
virtual LLVMValueRef main_ex_back(size_t index) const =0
int32_t main_type_back(size_t index) const
std::vector< int32_t > main_types
virtual ~state_stack()=default
virtual int64_t main_data_back(size_t index) const =0
virtual int64_t main_data(size_t index) const =0
virtual int64_t return_data(size_t index) const =0
virtual void set_main_ex_back(size_t index, LLVMValueRef value)=0
virtual void push_back_return(int32_t type, int64_t data, LLVMValueRef expr)=0
virtual void pop_main()=0
void set_main_type_back(size_t index, int32_t type)
virtual int64_t return_data_back(size_t index) const =0
int32_t return_type_back(size_t index) const
virtual void push_back_main(int32_t type, int64_t data, LLVMValueRef expr)=0
size_t return_size() const
virtual void set_main_ex(size_t index, LLVMValueRef value)=0
virtual void set_return_ex(size_t index, LLVMValueRef value)=0
int32_t return_type(size_t index) const
void set_return_type(size_t index, int32_t type)
virtual void pop_return()=0
virtual LLVMValueRef main_ex(size_t index) const =0
void mark_used_from_main(size_t count)
virtual void move_into(state_stack &&other)=0
virtual void set_return_data(size_t index, int64_t value)=0
int32_t main_type(size_t index) const
state_stack(state_stack &&)=default
state_stack(const state_stack &)=default
std::vector< int32_t > return_types
virtual int64_t return_data_back(size_t index) const override
virtual int64_t main_data_back(size_t index) const override
virtual void set_return_data(size_t index, int64_t value) override
virtual void move_into(state_stack &&other) override
virtual stack_type get_type() const override
virtual void pop_return() override
virtual void set_return_ex_back(size_t index, LLVMValueRef value) override
virtual std::unique_ptr< state_stack > copy() const override
virtual void set_main_data_back(size_t index, int64_t value) override
virtual void push_back_return(int32_t type, int64_t data, LLVMValueRef expr) override
virtual LLVMValueRef main_ex(size_t index) const override
virtual void pop_main() override
virtual LLVMValueRef main_ex_back(size_t index) const override
virtual LLVMValueRef return_ex(size_t index) const override
virtual void set_return_data_back(size_t index, int64_t value) override
virtual LLVMValueRef return_ex_back(size_t index) const override
virtual void push_back_main(int32_t type, int64_t data, LLVMValueRef expr) override
virtual void resize(size_t main_sz, size_t return_sz) override
virtual void copy_into(state_stack const &other) override
virtual void set_main_ex(size_t index, LLVMValueRef value) override
virtual void set_main_data(size_t index, int64_t value) override
virtual int64_t return_data(size_t index) const override
virtual void set_return_ex(size_t index, LLVMValueRef value) override
virtual int64_t main_data(size_t index) const override
virtual void set_main_ex_back(size_t index, LLVMValueRef value) override
virtual bool finish(environment &env) override
typecheck3_record_holder(opaque_compiler_data *p, environment &env)
virtual ankerl::unordered_dense::map< uint64_t, typecheck_3_record > * typecheck_record() override
virtual control_structure get_type() override
ankerl::unordered_dense::map< uint64_t, typecheck_3_record > tr
LLVMBasicBlockRef body_block
LLVMBasicBlockRef pre_block
std::unique_ptr< state_stack > loop_entry_copy
LLVMBasicBlockRef entry_block
virtual bool finish(environment &) override
while_loop_scope(opaque_compiler_data *p, environment &e, state_stack &entry_state)
size_t end_of_loop_branch
virtual void set_working_state(std::unique_ptr< state_stack > p) override
std::string_view entry_source
virtual control_structure get_type() override
std::vector< LLVMValueRef > phinodes
std::unique_ptr< state_stack > iworking_state
LLVMValueRef conditional_expr
void end_condition(environment &)
bool initial_typechecking_failed
std::unique_ptr< state_stack > initial_state
virtual state_stack * working_state() override
bool intepreter_skip_body
#define assert(condition)
LLVMBool LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action, char **OutMessage)
LLVMBool LLVMVerifyFunction(LLVMValueRef Fn, LLVMVerifierFailureAction Action)
void LLVMDisposeMessage(char *Message)
LLVMValueRef LLVMBuildLoad2(LLVMBuilderRef, LLVMTypeRef Ty, LLVMValueRef PointerVal, const char *Name)
LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name)
LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal, unsigned Index, const char *Name)
LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name)
LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If, LLVMValueRef Then, LLVMValueRef Else, const char *Name)
LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name)
LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal, LLVMValueRef EltVal, unsigned Index, const char *Name)
LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
LLVMValueRef LLVMBuildMemSet(LLVMBuilderRef B, LLVMValueRef Ptr, LLVMValueRef Val, LLVMValueRef Len, unsigned Align)
LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest)
LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
void LLVMDisposeBuilder(LLVMBuilderRef Builder)
LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C)
LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
LLVMValueRef LLVMBuildCall2(LLVMBuilderRef, LLVMTypeRef, LLVMValueRef Fn, LLVMValueRef *Args, unsigned NumArgs, const char *Name)
LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
LLVMValueRef LLVMBuildStructGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer, unsigned Idx, const char *Name)
LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr)
LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty, LLVMValueRef Val, const char *Name)
LLVMValueRef LLVMBuildInBoundsGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer, LLVMValueRef *Indices, unsigned NumIndices, const char *Name)
LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If, LLVMBasicBlockRef Then, LLVMBasicBlockRef Else)
LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
LLVMValueRef LLVMBuildMemCpy(LLVMBuilderRef B, LLVMValueRef Dst, unsigned DstAlign, LLVMValueRef Src, unsigned SrcAlign, LLVMValueRef Size)
LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal)
LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name)
LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef)
LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V)
void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block)
LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name, LLVMTypeRef FunctionTy)
void LLVMDisposeModule(LLVMModuleRef M)
LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID, LLVMContextRef C)
void LLVMSetTarget(LLVMModuleRef M, const char *Triple)
char * LLVMPrintModuleToString(LLVMModuleRef M)
void LLVMPassBuilderOptionsSetMergeFunctions(LLVMPassBuilderOptionsRef Options, LLVMBool MergeFunctions)
LLVMPassBuilderOptionsRef LLVMCreatePassBuilderOptions(void)
void LLVMDisposePassBuilderOptions(LLVMPassBuilderOptionsRef Options)
void LLVMPassBuilderOptionsSetSLPVectorization(LLVMPassBuilderOptionsRef Options, LLVMBool SLPVectorization)
void LLVMPassBuilderOptionsSetLoopVectorization(LLVMPassBuilderOptionsRef Options, LLVMBool LoopVectorization)
void LLVMPassBuilderOptionsSetLoopUnrolling(LLVMPassBuilderOptionsRef Options, LLVMBool LoopUnrolling)
typedefLLVM_C_EXTERN_C_BEGIN struct LLVMOpaquePassBuilderOptions * LLVMPassBuilderOptionsRef
void LLVMPassBuilderOptionsSetForgetAllSCEVInLoopUnroll(LLVMPassBuilderOptionsRef Options, LLVMBool ForgetAllSCEVInLoopUnroll)
void LLVMPassBuilderOptionsSetLoopInterleaving(LLVMPassBuilderOptionsRef Options, LLVMBool LoopInterleaving)
LLVMErrorRef LLVMRunPasses(LLVMModuleRef M, const char *Passes, LLVMTargetMachineRef TM, LLVMPassBuilderOptionsRef Options)
LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C)
LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C)
LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType, LLVMTypeRef *ParamTypes, unsigned ParamCount, LLVMBool IsVarArg)
LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C)
LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C)
LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C)
LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C)
LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C)
LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C)
LLVMTypeRef LLVMPointerTypeInContext(LLVMContextRef C, unsigned AddressSpace)
LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount)
void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes, unsigned ElementCount, LLVMBool Packed)
LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name)
LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes, unsigned ElementCount, LLVMBool Packed)
void LLVMAppendExistingBasicBlock(LLVMValueRef Fn, LLVMBasicBlockRef BB)
LLVMBasicBlockRef LLVMCreateBasicBlockInContext(LLVMContextRef C, const char *Name)
LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C, LLVMValueRef Fn, const char *Name)
LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, LLVMValueRef *ConstantVals, unsigned Length)
LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy, LLVMValueRef *ConstantVals, unsigned Count)
LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty)
LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage)
void LLVMSetSection(LLVMValueRef Global, const char *Section)
LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty)
LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N, LLVMBool SignExtend)
LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N)
void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC)
LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index)
void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC)
void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues, LLVMBasicBlockRef *IncomingBlocks, unsigned Count)
char * LLVMGetErrorMessage(LLVMErrorRef Err)
void LLVMDisposeErrorMessage(char *ErrMsg)
struct LLVMOpaqueError * LLVMErrorRef
struct LLVMOrcOpaqueLLJIT * LLVMOrcLLJITRef
void LLVMOrcLLJITBuilderSetJITTargetMachineBuilder(LLVMOrcLLJITBuilderRef Builder, LLVMOrcJITTargetMachineBuilderRef JTMB)
LLVMErrorRef LLVMOrcDisposeLLJIT(LLVMOrcLLJITRef J)
LLVMErrorRef LLVMOrcLLJITAddLLVMIRModule(LLVMOrcLLJITRef J, LLVMOrcJITDylibRef JD, LLVMOrcThreadSafeModuleRef TSM)
LLVMOrcSymbolStringPoolEntryRef LLVMOrcLLJITMangleAndIntern(LLVMOrcLLJITRef J, const char *UnmangledName)
LLVMOrcJITDylibRef LLVMOrcLLJITGetMainJITDylib(LLVMOrcLLJITRef J)
LLVMOrcIRTransformLayerRef LLVMOrcLLJITGetIRTransformLayer(LLVMOrcLLJITRef J)
LLVMOrcLLJITBuilderRef LLVMOrcCreateLLJITBuilder(void)
LLVMOrcExecutionSessionRef LLVMOrcLLJITGetExecutionSession(LLVMOrcLLJITRef J)
LLVMErrorRef LLVMOrcCreateLLJIT(LLVMOrcLLJITRef *Result, LLVMOrcLLJITBuilderRef Builder)
LLVMErrorRef LLVMOrcThreadSafeModuleWithModuleDo(LLVMOrcThreadSafeModuleRef TSM, LLVMOrcGenericIRModuleOperationFunction F, void *Ctx)
LLVMOrcMaterializationUnitRef LLVMOrcAbsoluteSymbols(LLVMOrcCSymbolMapPairs Syms, size_t NumPairs)
LLVMOrcThreadSafeModuleRef LLVMOrcCreateNewThreadSafeModule(LLVMModuleRef M, LLVMOrcThreadSafeContextRef TSCtx)
struct LLVMOrcOpaqueMaterializationResponsibility * LLVMOrcMaterializationResponsibilityRef
struct LLVMOrcOpaqueThreadSafeModule * LLVMOrcThreadSafeModuleRef
struct LLVMOrcOpaqueExecutionSession * LLVMOrcExecutionSessionRef
void LLVMOrcDisposeThreadSafeContext(LLVMOrcThreadSafeContextRef TSCtx)
uint64_t LLVMOrcExecutorAddress
LLVMOrcJITTargetMachineBuilderRef LLVMOrcJITTargetMachineBuilderCreateFromTargetMachine(LLVMTargetMachineRef TM)
LLVMErrorRef LLVMOrcJITDylibDefine(LLVMOrcJITDylibRef JD, LLVMOrcMaterializationUnitRef MU)
LLVMOrcThreadSafeContextRef LLVMOrcCreateNewThreadSafeContext(void)
struct LLVMOrcOpaqueIRTransformLayer * LLVMOrcIRTransformLayerRef
LLVMContextRef LLVMOrcThreadSafeContextGetContext(LLVMOrcThreadSafeContextRef TSCtx)
struct LLVMOrcOpaqueJITDylib * LLVMOrcJITDylibRef
struct LLVMOrcOpaqueThreadSafeContext * LLVMOrcThreadSafeContextRef
void LLVMOrcIRTransformLayerSetTransform(LLVMOrcIRTransformLayerRef IRTransformLayer, LLVMOrcIRTransformLayerTransformFunction TransformFunction, void *Ctx)
struct LLVMOpaqueValue * LLVMValueRef
struct LLVMOpaqueContext * LLVMContextRef
struct LLVMOpaqueBuilder * LLVMBuilderRef
struct LLVMOpaqueBasicBlock * LLVMBasicBlockRef
struct LLVMOpaqueType * LLVMTypeRef
struct LLVMOpaqueModule * LLVMModuleRef
void LLVMSetModuleDataLayout(LLVMModuleRef M, LLVMTargetDataRef DL)
char * LLVMGetHostCPUFeatures(void)
LLVMTargetRef LLVMGetFirstTarget(void)
struct LLVMTarget * LLVMTargetRef
char * LLVMGetHostCPUName(void)
void LLVMDisposeTargetData(LLVMTargetDataRef TD)
struct LLVMOpaqueTargetMachine * LLVMTargetMachineRef
char * LLVMGetDefaultTargetTriple(void)
LLVMTargetMachineRef LLVMCreateTargetMachine(LLVMTargetRef T, const char *Triple, const char *CPU, const char *Features, LLVMCodeGenOptLevel Level, LLVMRelocMode Reloc, LLVMCodeModel CodeModel)
LLVMTargetDataRef LLVMCreateTargetDataLayout(LLVMTargetMachineRef T)
struct LLVMOpaqueTargetData * LLVMTargetDataRef
void LLVMDisposeTargetMachine(LLVMTargetMachineRef T)
LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name)
void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal)
int32_t * forth_struct_map_two(fif::state_stack &s, int32_t *p, fif::environment *e)
constexpr int32_t fif_struct
int32_t * f32lt(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * fif_swap(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * enter_scope(state_stack &s, int32_t *p, environment *env)
int32_t * fif_end_do(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * fif_until(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * uile(fif::state_stack &s, int32_t *p, fif::environment *e)
int64_t(*)(int32_t t, environment *) interpreter_zero_expr
int32_t make_struct_type(std::string_view name, std::span< int32_t const > subtypes, std::vector< std::string_view > const &member_names, environment &env, int32_t template_types, int32_t extra_count)
int32_t * sext_i8(fif::state_stack &s, int32_t *p, fif::environment *e)
bool non_immediate_mode(fif_mode m)
int32_t * do_pointer_cast(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * illegal_interpretation(state_stack &s, int32_t *p, environment *e)
int32_t * nop1(fif::state_stack &s, int32_t *p, fif::environment *e)
void execute_fif_word(interpreted_word_instance &wi, state_stack &ss, environment &env)
int32_t * impl_heap_allot(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t *(*)(state_stack &, int32_t *, environment *) fif_call
constexpr size_t inlining_cells_limit
type_match internal_resolve_type(std::string_view text, environment &env, std::vector< int32_t > *type_subs)
void run_fif_interpreter(environment &env, std::string_view on_text)
int32_t * colon_specialization(fif::state_stack &, int32_t *p, fif::environment *e)
int32_t * immediate_i32(state_stack &s, int32_t *p, environment *)
int32_t * fif_if(fif::state_stack &s, int32_t *p, fif::environment *e)
constexpr int32_t fif_ptr
int32_t * f64_mod(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * ieq(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * do_fextract(fif::state_stack &s, int32_t *p, fif::environment *e)
constexpr int32_t fif_i32
int32_t * f64eq(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * fif_while(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * function_return(state_stack &s, int32_t *p, environment *)
constexpr int32_t fif_u16
bool is_fp(char const *start, char const *end)
float parse_float(std::string_view content)
int32_t * f32gt(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * ftrunc(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * drop(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f_select(fif::state_stack &s, int32_t *p, fif::environment *e)
type_match_result match_stack_description(std::span< int32_t const > desc, state_stack &ts, environment &env, std::vector< int32_t > &type_subs)
parse_result read_token(std::string_view &source, environment &env)
bool codepoint_is_space(uint32_t c) noexcept
int32_t * unconditional_jump(state_stack &s, int32_t *p, environment *env)
int32_t * f32ui16(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * simod(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * type_construction(state_stack &s, int32_t *p, environment *e)
int32_t * zext_ui8(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * colon_definition(fif::state_stack &, int32_t *p, fif::environment *e)
constexpr int32_t fif_u32
int32_t * f64le(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * iadd(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * create_var(fif::state_stack &s, int32_t *p, fif::environment *e)
stack_consumption get_stack_consumption(int32_t word, int32_t alternative, environment &env)
constexpr int32_t fif_bool
void add_precompiled(fif::environment &env, std::string name, fif::fif_call fn, std::vector< int32_t > types, bool immediate=false)
int32_t * ident8(fif::state_stack &s, int32_t *p, fif::environment *e)
bool stack_types_match(state_stack &a, state_stack &b)
int32_t * forth_gep(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f32_mul(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * ile(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * uimod(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * forth_extract_copy(fif::state_stack &s, int32_t *p, fif::environment *e)
int64_t(*)() interpreted_new
int32_t * r_at(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * do_fsmt(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * sext_i16(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * do_var_creation(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * imul(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * copy_buffer(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * zext_ui16(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * bit_lshr(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * sext_ui64(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f64ui16(fif::state_stack &s, int32_t *p, fif::environment *e)
void do_immediate_bool(state_stack &s, bool value, environment *e)
uint32_t codepoint_from_utf8(char const *start, char const *end)
int32_t * f64ne(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * call_function_indirect(state_stack &s, int32_t *p, environment *env)
int32_t * sif64(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * do_fsmo(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * impl_load_deallocated(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f64i8(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * create_let(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * sext_ui16(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * impl_index(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * zext_i32(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * fif_end_while(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * sext_ui32(fif::state_stack &s, int32_t *p, fif::environment *e)
bool typechecking_mode(fif_mode m)
int32_t struct_child_count(int32_t type, environment &env)
int32_t * f32ui64(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f64i16(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * fif_then(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f64i64(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * bit_xor(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f64_div(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * forth_extract(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * impl_uninit_store(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * conditional_jump(state_stack &s, int32_t *p, environment *env)
std::variant< interpreted_word_instance, compiled_word_instance > word_types
int32_t * zext_i8(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * impl_load(fif::state_stack &s, int32_t *p, fif::environment *e)
bool is_positive_integer(char const *start, char const *end)
void add_import(std::string_view name, void *ptr, fif_call interpreter_implementation, std::vector< int32_t > const ¶ms, std::vector< int32_t > const &returns, environment &env)
int32_t * uif64(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * trunc_i1(fif::state_stack &s, int32_t *p, fif::environment *e)
fif_mode fail_typechecking(fif_mode m)
int32_t * uif32(fif::state_stack &s, int32_t *p, fif::environment *e)
word_match_result match_word(word const &w, state_stack &ts, std::vector< word_types > const &all_instances, std::vector< int32_t > const &all_stack_types, environment &env)
variable_match_result fill_in_variable_types(int32_t source_type, std::span< int32_t const > match_span, std::vector< int32_t > &type_subs, environment &env)
int32_t * copy(fif::state_stack &s, int32_t *p, fif::environment *e)
var_data * get_global_var(environment &env, std::string const &name)
bool compile_word(int32_t w, int32_t word_index, state_stack &state, fif_mode compile_mode, environment &env, std::vector< int32_t > &tsubs)
int32_t * dup(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * create_global_impl(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f32ui8(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * forth_struct_map_zero(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * zext_ui64(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * uilt(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f32i16(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * zext_i64(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t interepreter_size(int32_t type, environment &env)
void switch_compiler_stack_mode(environment &env, fif_mode new_mode)
int32_t * fif_else(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f32ge(fif::state_stack &s, int32_t *p, fif::environment *e)
uint32_t next_encoded_stack_type(std::span< int32_t const > desc)
int32_t * do_use_base(state_stack &s, int32_t *p, environment *env)
void do_immediate_i32(state_stack &s, int32_t value, environment *e)
int32_t * immediate_f32(state_stack &s, int32_t *p, environment *)
int64_t interpreter_struct_zero_constant(int32_t t, environment *e)
int32_t * zext_ui32(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * close_bracket(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * immediate_global(state_stack &s, int32_t *p, environment *e)
type_match resolve_span_type(std::span< int32_t const > tlist, std::vector< int32_t > const &type_subs, environment &env)
let_data * get_global_let(environment &env, std::string const &name)
int32_t * idents32(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * impl_store(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * forth_struct_map_one(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * do_fextractc(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f64ge(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * trunc_i32(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * free_buffer(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t resolve_type(std::string_view text, environment &env, std::vector< int32_t > *type_subs)
int32_t * reverse_conditional_jump(state_stack &s, int32_t *p, environment *env)
int32_t * fif_loop(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * ident1(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * bit_shl(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * sext_i32(fif::state_stack &s, int32_t *p, fif::environment *e)
size_t size_from_utf8(char const *start)
constexpr int32_t fif_nil
int32_t * immediate_local(state_stack &s, int32_t *p, environment *e)
int32_t * allocate_buffer(fif::state_stack &s, int32_t *p, fif::environment *e)
void run_to_scope_end(environment &env)
int32_t * do_fsmz(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * bit_and(fif::state_stack &s, int32_t *p, fif::environment *e)
constexpr int32_t fif_type
int32_t * f32i8(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * sext_i64(fif::state_stack &s, int32_t *p, fif::environment *e)
void do_immediate_type(state_stack &s, int32_t value, environment *e)
int32_t * impl_heap_free(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * trunc_i8(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f32i32(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * bit_not(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * make_immediate(fif::state_stack &s, int32_t *p, fif::environment *e)
void restore_compiler_stack_mode(environment &env)
int32_t * sif32(fif::state_stack &s, int32_t *p, fif::environment *e)
std::string_view read_word(std::string_view source, uint32_t &read_position)
int32_t * call_function(state_stack &s, int32_t *p, environment *env)
int32_t * to_r(fif::state_stack &s, int32_t *p, fif::environment *e)
bool compare_stack_description(std::span< const int32_t > a, std::span< const int32_t > b)
int32_t * f32le(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * sidiv(fif::state_stack &s, int32_t *p, fif::environment *e)
string_start match_string_start(std::string_view source)
int32_t * f32eq(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * export_definition(fif::state_stack &, int32_t *p, fif::environment *e)
int32_t * f64i32(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f64_sub(fif::state_stack &s, int32_t *p, fif::environment *e)
bool is_integer(char const *start, char const *end)
int32_t * zext_i16(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * idents16(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f64ui8(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f32_mod(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * ident32(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * pointer_cast(fif::state_stack &s, int32_t *p, fif::environment *e)
std::string word_name_from_id(int32_t w, environment const &e)
int32_t * f64_add(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * immediate_type(state_stack &s, int32_t *p, environment *)
int32_t * f64gt(fif::state_stack &s, int32_t *p, fif::environment *e)
LLVMValueRef empty_type_fn(LLVMValueRef r, int32_t type, environment *)
int32_t instantiate_templated_struct(int32_t template_base, std::vector< int32_t > const &subtypes, environment &env)
std::vector< int32_t > expand_stack_description(state_stack &initial_stack_state, std::span< const int32_t > desc, int32_t stack_consumed, int32_t rstack_consumed)
bool is_positive_fp(char const *start, char const *end)
bool fully_typecheck_word(int32_t w, int32_t word_index, interpreted_word_instance &wi, state_stack ¤t_type_state, environment &env, std::vector< int32_t > &tsubs)
int32_t * ident16(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * uidiv(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * isub(fif::state_stack &s, int32_t *p, fif::environment *e)
bool typechecking_failed(fif_mode m)
bool codepoint_is_line_break(uint32_t c) noexcept
constexpr int32_t fif_f32
int32_t * leave_scope(state_stack &s, int32_t *p, environment *env)
int32_t * immediate_let(state_stack &s, int32_t *p, environment *e)
int32_t * ige(fif::state_stack &s, int32_t *p, fif::environment *e)
void do_immediate_f32(state_stack &s, float value, environment *e)
int32_t * long_comment(fif::state_stack &, int32_t *p, fif::environment *e)
int32_t * fif_do(fif::state_stack &s, int32_t *p, fif::environment *e)
constexpr int32_t fif_opaque_ptr
int32_t * f64ui64(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * do_fgep(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * do_finsert(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f32_add(fif::state_stack &s, int32_t *p, fif::environment *e)
constexpr int32_t fif_i16
int32_t parse_int(std::string_view content)
void initialize_standard_vocab(environment &fif_env)
int32_t * f64ui32(fif::state_stack &s, int32_t *p, fif::environment *e)
fif_mode reset_typechecking(fif_mode m)
int32_t * bit_or(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * trunc_ui32(fif::state_stack &s, int32_t *p, fif::environment *e)
bool float_from_chars(char const *start, char const *end, float &float_out)
int32_t * f32ui32(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * do_make(state_stack &s, int32_t *p, environment *env)
int32_t * open_bracket(fif::state_stack &s, int32_t *p, fif::environment *e)
type_span_gen_result internal_generate_type(std::string_view text, environment &env)
void run_to_function_end(environment &env)
int32_t * f32_sub(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * ilt(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * trunc_ui16(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * do_let_creation(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * forth_insert(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * uige(fif::state_stack &s, int32_t *p, fif::environment *e)
constexpr int32_t fif_u64
int32_t * fext(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * trunc_i16(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * sext_ui8(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * immediate_bool(state_stack &s, int32_t *p, environment *)
int32_t * struct_definition(fif::state_stack &, int32_t *p, fif::environment *e)
constexpr int32_t fif_i64
int32_t * f32i64(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f64_mul(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f64lt(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t instantiate_templated_struct_full(int32_t template_base, std::vector< int32_t > const &final_subtype_list, environment &env)
int32_t * impl_sizeof(fif::state_stack &s, int32_t *p, fif::environment *e)
bool match_string_end(std::string_view source, int32_t eq_count_in)
int32_t * trunc_ui8(fif::state_stack &s, int32_t *p, fif::environment *e)
void apply_stack_description(std::span< int32_t const > desc, state_stack &ts, environment &env)
int32_t * uigt(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * line_comment(fif::state_stack &, int32_t *p, fif::environment *e)
int32_t * ine(fif::state_stack &s, int32_t *p, fif::environment *e)
@ typechecking_lvl2_failed
@ typechecking_lvl1_failed
@ typechecking_lvl3_failed
int32_t * bit_ashr(fif::state_stack &s, int32_t *p, fif::environment *e)
word_match_result get_basic_type_match(int32_t word_index, state_stack ¤t_type_state, environment &env, std::vector< int32_t > &specialize_t_subs, bool ignore_specializations)
int32_t * from_r(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f32ne(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * f32_div(fif::state_stack &s, int32_t *p, fif::environment *e)
int32_t * igt(fif::state_stack &s, int32_t *p, fif::environment *e)
constexpr int32_t fif_f64
int32_t * idents8(fif::state_stack &s, int32_t *p, fif::environment *e)
LLVMOrcExecutorAddress Address
int32_t stack_types_count
int32_t stack_types_start
bool operator()(std::unique_ptr< char[]> const &l, std::unique_ptr< char[]> const &r) const noexcept
bool operator()(std::unique_ptr< char[]> const &l, std::string_view r) const noexcept
bool operator()(std::string const &r, std::unique_ptr< char[]> const &l) const noexcept
bool operator()(std::string_view r, std::unique_ptr< char[]> const &l) const noexcept
bool operator()(std::unique_ptr< char[]> const &l, std::string const &r) const noexcept
auto operator()(std::string_view sv) const noexcept -> uint64_t
auto operator()(std::unique_ptr< char[]> const &str) const noexcept -> uint64_t
bool llvm_compilation_finished
int32_t stack_types_count
int32_t stack_types_start
bool is_imported_function
int32_t typechecking_level
LLVMValueRef llvm_function
std::vector< int32_t > compiled_bytecode
int32_t ret_stack_consumed
std::vector< int32_t > type_array
int32_t decomposed_types_start
static constexpr uint32_t FLAG_REFCOUNTED
bool refcounted_type() const
interpreter_zero_expr interpreter_zero
static constexpr uint32_t FLAG_TEMPLATE
static constexpr uint32_t FLAG_SINGLE_MEMBER
bool is_struct_template() const
bool single_member_struct() const
int32_t decomposed_types_count
int32_t stack_height_added_at
int32_t rstack_height_added_at
int32_t substitution_version
int32_t ret_stack_consumed
std::vector< int32_t > instances
int32_t stack_types_start
int32_t stack_types_count
int32_t specialization_of