Fixed a lot of bugs
* Fixed ByRef variables of defined types causing crashes * Fixed ArrayDim causing crashes with members of types * Added parent references to number and string values for use with ByRef * Added TypeArrayDim * Added the ability to use custom types in embedded functions * Added the ability to create types in embedded_functions.bas * Added new output file for embedded (rcbasic_dev4.txt) that will output code to generate types * Added defined types to byref exceptions
This commit is contained in:
@@ -516,8 +516,12 @@ sub JoinMatrixRows(mA, mB, mC)
|
||||
sub JoinMatrixColumns(mA, mB, mC)
|
||||
|
||||
'v4.0
|
||||
function TypeArrayDim(Byref id$)
|
||||
function TypeArraySize(Byref id, array_dim)
|
||||
sub TypeArrayCopy(ByRef src, ByRef dst)
|
||||
sub TypeArrayFill(ByRef src, fdata)
|
||||
|
||||
'Empty Type is used mainly for built-in functions that need to have a user type specified to be able to compile properly
|
||||
type empty
|
||||
end type
|
||||
|
||||
function TypeArrayDim(Byref id as empty)
|
||||
function TypeArraySize(Byref id as empty, array_dim)
|
||||
sub TypeArrayCopy(ByRef src as empty, ByRef dst as empty)
|
||||
sub TypeArrayFill(ByRef src as empty, fdata as empty)
|
||||
|
||||
@@ -426,6 +426,82 @@ bool add_type_member(string member_name, int member_type, string member_utype_na
|
||||
return true;
|
||||
}
|
||||
|
||||
bool add_type_member_embedded(string member_name, int member_type, string member_utype_name, int member_dim_count, int dim1, int dim2, int dim3)
|
||||
{
|
||||
int m_utype_index = member_utype_name.compare("")!=0 ? getUType(member_utype_name) : -1;
|
||||
if(m_utype_index == current_type_index)
|
||||
{
|
||||
//cout << "you canno do is" << endl;
|
||||
rc_setError("Cannot create member of type from within itself");
|
||||
return false;
|
||||
}
|
||||
//cout << "utype index = " << current_type_index << endl;
|
||||
int utype_index = current_type_index;
|
||||
int utype_current_member = utype[utype_index].num_members;
|
||||
member_name = StringToLower(member_name);
|
||||
utype[utype_index].member_name.push_back(member_name);
|
||||
|
||||
string dim_mem_type = "";
|
||||
|
||||
switch(member_type)
|
||||
{
|
||||
case ID_TYPE_NUM:
|
||||
dim_mem_type = "!0 !" + rc_intToString(utype_current_member);
|
||||
utype[utype_index].member_type.push_back(ID_TYPE_USER_NUM);
|
||||
utype[utype_index].member_vec_pos.push_back(utype[utype_index].nidCount);
|
||||
utype[utype_index].nidCount++;
|
||||
break;
|
||||
case ID_TYPE_ARR_NUM:
|
||||
dim_mem_type = "!0 !" + rc_intToString(utype_current_member);
|
||||
utype[utype_index].member_type.push_back(ID_TYPE_USER_NUM_ARRAY);
|
||||
utype[utype_index].member_vec_pos.push_back(utype[utype_index].nidCount);
|
||||
utype[utype_index].nidCount++;
|
||||
break;
|
||||
case ID_TYPE_STR:
|
||||
dim_mem_type = "!1 !" + rc_intToString(utype_current_member);
|
||||
utype[utype_index].member_type.push_back(ID_TYPE_USER_STR);
|
||||
utype[utype_index].member_vec_pos.push_back(utype[utype_index].sidCount);
|
||||
utype[utype_index].sidCount++;
|
||||
break;
|
||||
case ID_TYPE_ARR_STR:
|
||||
dim_mem_type = "!1 !" + rc_intToString(utype_current_member);
|
||||
utype[utype_index].member_type.push_back(ID_TYPE_USER_STR_ARRAY);
|
||||
utype[utype_index].member_vec_pos.push_back(utype[utype_index].sidCount);
|
||||
utype[utype_index].sidCount++;
|
||||
break;
|
||||
case ID_TYPE_USER:
|
||||
dim_mem_type = "!2 !" + rc_intToString(utype_current_member);
|
||||
utype[utype_index].member_type.push_back(ID_TYPE_USER);
|
||||
utype[utype_index].member_vec_pos.push_back(utype[utype_index].uidCount);
|
||||
utype[utype_index].uidCount++;
|
||||
break;
|
||||
default:
|
||||
rc_setError("Invalid member type in type definition");
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
||||
utype[utype_index].member_dim_count.push_back(member_dim_count);
|
||||
utype[utype_index].member_utype_index.push_back(m_utype_index);
|
||||
|
||||
|
||||
vm_asm.push_back("dim_tfield !" + rc_intToString(utype_index) + " " + dim_mem_type + " !"
|
||||
+ rc_intToString(member_dim_count) + " "
|
||||
+ "n0 n1 n2");
|
||||
|
||||
//NOTE: user_array_dim is no longer used
|
||||
user_array_dim d;
|
||||
d.dim_size[0] = dim1;
|
||||
d.dim_size[1] = dim2;
|
||||
d.dim_size[2] = dim3;
|
||||
utype[utype_index].member_dim.push_back(d);
|
||||
//cout << member_name << " has " << member_dim_count << " dimensions" << endl;
|
||||
//utype[utype_index].member_dim[utype_current_member].dim_size[1] = dim2;
|
||||
//utype[utype_index].member_dim[utype_current_member].dim_size[2] = dim3;
|
||||
utype[utype_index].num_members++;
|
||||
return true;
|
||||
}
|
||||
|
||||
//return the index of the id name or -1 on failure
|
||||
int getIDInScope_ByIndex_TypeMatch(string id_name, string check_scope="")
|
||||
{
|
||||
@@ -961,7 +1037,7 @@ bool create_array(string name, int type, string utype_name, int dim_count, strin
|
||||
return true;
|
||||
}
|
||||
|
||||
bool embed_function(string name, int type)
|
||||
bool embed_function(string name, int type, int fn_utype=-1)
|
||||
{
|
||||
if(getIDInScope(name) >= 0)
|
||||
{
|
||||
@@ -979,6 +1055,7 @@ bool embed_function(string name, int type)
|
||||
break;
|
||||
case ID_TYPE_FN_NUM:
|
||||
case ID_TYPE_FN_STR:
|
||||
case ID_TYPE_FN_USER:
|
||||
current_block_state = BLOCK_STATE_FUNCTION;
|
||||
break;
|
||||
default:
|
||||
@@ -997,9 +1074,11 @@ bool embed_function(string name, int type)
|
||||
fn.name = name;
|
||||
fn.scope = "main";
|
||||
fn.type = type;
|
||||
fn.type_index = fn_utype;
|
||||
fn.isBuiltin = true;
|
||||
fn.vmFunctionIndex = current_vmFunction_index;
|
||||
current_vmFunction_index++;
|
||||
cout << "current_vmFunction = " << current_vmFunction_index << endl;
|
||||
|
||||
fn.num_args = 0; //function args default to 0; args are added with add_function_args
|
||||
current_fn_index = id.size();
|
||||
@@ -1007,7 +1086,7 @@ bool embed_function(string name, int type)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool add_embedded_arg(string arg_name, int arg_type)
|
||||
bool add_embedded_arg(string arg_name, int arg_type, int arg_utype=-1)
|
||||
{
|
||||
//fn_arg
|
||||
//fn_arg_type
|
||||
@@ -1015,6 +1094,11 @@ bool add_embedded_arg(string arg_name, int arg_type)
|
||||
int fn_index = current_fn_index;
|
||||
id[fn_index].fn_arg.push_back(arg_name);
|
||||
id[fn_index].fn_arg_type.push_back(arg_type);
|
||||
id[fn_index].fn_arg_utype.push_back(arg_utype);
|
||||
|
||||
string fn_arg_utype_name = "";
|
||||
if(arg_utype >= 0)
|
||||
fn_arg_utype_name = utype[arg_utype].name;
|
||||
|
||||
string fn_id = "";
|
||||
int fn_id_index = -1;
|
||||
@@ -1033,6 +1117,13 @@ bool add_embedded_arg(string arg_name, int arg_type)
|
||||
create_variable(fn_id, ID_TYPE_STR);
|
||||
fn_strCount++;
|
||||
}
|
||||
else if(arg_type == ID_TYPE_USER)
|
||||
{
|
||||
fn_id = "#fu" + rc_intToString(fn_usrCount);
|
||||
if(getIDInScope(fn_id) < 0)
|
||||
create_variable(fn_id, ID_TYPE_USER, fn_arg_utype_name);
|
||||
fn_usrCount++;
|
||||
}
|
||||
else if(arg_type == ID_TYPE_BYREF_NUM)
|
||||
{
|
||||
fn_id = "#fn" + rc_intToString(fn_numCount);
|
||||
@@ -1047,6 +1138,13 @@ bool add_embedded_arg(string arg_name, int arg_type)
|
||||
create_variable(fn_id, ID_TYPE_BYREF_STR);
|
||||
fn_strCount++;
|
||||
}
|
||||
else if(arg_type == ID_TYPE_BYREF_USER)
|
||||
{
|
||||
fn_id = "#fu" + rc_intToString(fn_usrCount);
|
||||
if(getIDInScope(fn_id) < 0)
|
||||
create_variable(fn_id, ID_TYPE_BYREF_USER, fn_arg_utype_name);
|
||||
fn_usrCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
rc_setError("Invalid type in function definition");
|
||||
@@ -1058,7 +1156,7 @@ bool add_embedded_arg(string arg_name, int arg_type)
|
||||
|
||||
isFunctionArg_flag = true;
|
||||
|
||||
create_variable(arg_name, arg_type, "", fn_arg_vec);
|
||||
create_variable(arg_name, arg_type, fn_arg_utype_name, fn_arg_vec);
|
||||
|
||||
id[fn_index].fn_reg.push_back( fn_id );
|
||||
id[fn_index].fn_arg_vec.push_back(fn_arg_vec);
|
||||
|
||||
@@ -36,7 +36,8 @@ vector<string> inc_files;
|
||||
|
||||
void rcbasic_init()
|
||||
{
|
||||
create_type("null");
|
||||
//init built-in types here
|
||||
init_embedded_types();
|
||||
|
||||
//init built-in functions here
|
||||
|
||||
@@ -46,7 +47,7 @@ void rcbasic_init()
|
||||
current_scope = "main";
|
||||
vm_asm.push_back(".code");
|
||||
|
||||
init_embedded();
|
||||
init_embedded_functions();
|
||||
|
||||
//cout << "numid_count = " << num_id_count << endl;
|
||||
//cout << "strid_count = " << str_id_count << endl << endl;
|
||||
@@ -61,7 +62,7 @@ void rcbasic_init()
|
||||
|
||||
void rcbasic_dev_init()
|
||||
{
|
||||
create_type("null");
|
||||
//create_type("empty");
|
||||
|
||||
//init built-in functions here
|
||||
|
||||
@@ -829,6 +830,7 @@ void rcbasic_export_dev()
|
||||
fstream f("rcbasic_dev.txt", fstream::out | fstream::trunc);
|
||||
fstream f2("rcbasic_dev2.txt", fstream::out | fstream::trunc);
|
||||
fstream f3("rcbasic_dev3.txt", fstream::out | fstream::trunc);
|
||||
fstream f4("rcbasic_dev4.txt", fstream::out | fstream::trunc);
|
||||
|
||||
if(!f.is_open())
|
||||
return;
|
||||
@@ -850,6 +852,11 @@ void rcbasic_export_dev()
|
||||
f2 << fn_line << endl;
|
||||
f3 << "case FN_" << id[i].name << ": //String Function" << endl << "break;" << endl;
|
||||
break;
|
||||
case ID_TYPE_FN_USER:
|
||||
output_line += "ID_TYPE_FN_STR);";
|
||||
f2 << fn_line << endl;
|
||||
f3 << "case FN_" << id[i].name << ": //UDT Function" << endl << "break;" << endl;
|
||||
break;
|
||||
case ID_TYPE_SUB:
|
||||
output_line += "ID_TYPE_SUB);";
|
||||
f2 << fn_line << endl;
|
||||
@@ -860,6 +867,7 @@ void rcbasic_export_dev()
|
||||
}
|
||||
f << output_line << endl;
|
||||
output_line = "";
|
||||
string fn_arg_utype = "";
|
||||
for(int n = 0; n < id[i].num_args; n++)
|
||||
{
|
||||
fn_line = "#define " + StringToUpper(id[i].name + "_" + id[i].fn_arg[n]) + " ";
|
||||
@@ -870,19 +878,33 @@ void rcbasic_export_dev()
|
||||
case ID_TYPE_NUM:
|
||||
output_line += "ID_TYPE_NUM);";
|
||||
//fn_line += "num_var[" + rc_intToString(id[i].fn_arg_vec[n]) + "].nid_value[0].value[0]";
|
||||
fn_line += "num_var[" + rc_intToString(id[i].fn_arg_vec[n]) + "].nid_value[0].value[ num_var[" + rc_intToString(id[i].fn_arg_vec[n]) + "].byref_offset ]";
|
||||
fn_line += "num_var[" + rc_intToString(id[i].fn_arg_vec[n]) + "].nid_value.value[ num_var[" + rc_intToString(id[i].fn_arg_vec[n]) + "].byref_offset ]";
|
||||
break;
|
||||
case ID_TYPE_BYREF_NUM:
|
||||
output_line += "ID_TYPE_BYREF_NUM);";
|
||||
fn_line += "num_var[" + rc_intToString(id[i].fn_arg_vec[n]) + "].nid_value[0].value[ num_var[" + rc_intToString(id[i].fn_arg_vec[n]) + "].byref_offset ]";
|
||||
fn_line += "num_var[" + rc_intToString(id[i].fn_arg_vec[n]) + "].nid_value.value[ num_var[" + rc_intToString(id[i].fn_arg_vec[n]) + "].byref_offset ]";
|
||||
break;
|
||||
case ID_TYPE_STR:
|
||||
output_line += "ID_TYPE_STR);";
|
||||
fn_line += "str_var[" + rc_intToString(id[i].fn_arg_vec[n]) + "].sid_value[0].value[ str_var[" + rc_intToString(id[i].fn_arg_vec[n]) + "].byref_offset ]";
|
||||
fn_line += "str_var[" + rc_intToString(id[i].fn_arg_vec[n]) + "].sid_value.value[ str_var[" + rc_intToString(id[i].fn_arg_vec[n]) + "].byref_offset ]";
|
||||
break;
|
||||
case ID_TYPE_BYREF_STR:
|
||||
output_line += "ID_TYPE_BYREF_STR);";
|
||||
fn_line += "str_var[" + rc_intToString(id[i].fn_arg_vec[n]) + "].sid_value[0].value[ str_var[" + rc_intToString(id[i].fn_arg_vec[n]) + "].byref_offset ]";
|
||||
fn_line += "str_var[" + rc_intToString(id[i].fn_arg_vec[n]) + "].sid_value.value[ str_var[" + rc_intToString(id[i].fn_arg_vec[n]) + "].byref_offset ]";
|
||||
break;
|
||||
case ID_TYPE_USER:
|
||||
//fn_arg_utype = "";
|
||||
//if(id[i].fn_arg_utype[n] >= 0)
|
||||
// fn_arg_utype = utype[id[i].fn_arg_utype[n]].name;
|
||||
output_line += "ID_TYPE_USER, " + rc_intToString(id[i].fn_arg_utype[n]) + ");";
|
||||
fn_line += "usr_var[" + rc_intToString(id[i].fn_arg_vec[n]) + "].var_ref->uid_value[0]";
|
||||
break;
|
||||
case ID_TYPE_BYREF_USER:
|
||||
//fn_arg_utype = "";
|
||||
//if(id[i].fn_arg_utype[n] >= 0)
|
||||
// fn_arg_utype = utype[id[i].fn_arg_utype[n]].name;
|
||||
output_line += "ID_TYPE_BYREF_USER, " + rc_intToString(id[i].fn_arg_utype[n]) + ");";
|
||||
fn_line += "usr_var[" + rc_intToString(id[i].fn_arg_vec[n]) + "].var_ref";
|
||||
break;
|
||||
}
|
||||
f2 << fn_line << endl;
|
||||
@@ -890,9 +912,50 @@ void rcbasic_export_dev()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for(int i = 0; i < utype.size(); i++)
|
||||
{
|
||||
output_line = "create_type(\"" + utype[i].name + "\");";
|
||||
|
||||
f4 << output_line << endl;
|
||||
|
||||
for(int n = 0; n < utype[i].num_members; n++)
|
||||
{
|
||||
output_line = "vm_asm.push_back(\"mov n0 " + rc_intToString(utype[i].member_dim[n].dim_size[0]) + "\");";
|
||||
f4 << output_line << endl;
|
||||
|
||||
output_line = "vm_asm.push_back(\"mov n1 " + rc_intToString(utype[i].member_dim[n].dim_size[1]) + "\");";
|
||||
f4 << output_line << endl;
|
||||
|
||||
output_line = "vm_asm.push_back(\"mov n2 " + rc_intToString(utype[i].member_dim[n].dim_size[2]) + "\");";
|
||||
f4 << output_line << endl;
|
||||
|
||||
int ut_index = utype[i].member_utype_index[n];
|
||||
string member_utype_name = "";
|
||||
|
||||
if(ut_index >= 0)
|
||||
member_utype_name = utype[ut_index].name;
|
||||
else if(utype[i].member_type[n] == ID_TYPE_USER)
|
||||
{
|
||||
cout << "ERROR CREATING TYPE" << endl;
|
||||
f.close();
|
||||
f2.close();
|
||||
f3.close();
|
||||
f4.close();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
output_line = "add_type_member(\"" + utype[i].member_name[n] + "\", " + rc_intToString(utype[i].member_type[n]) + ", \"" + member_utype_name + "\", " +
|
||||
rc_intToString(utype[i].member_dim_count[n]) + ", \"n0\", \"n1\", \"n2\");";
|
||||
f4 << output_line << endl;
|
||||
}
|
||||
}
|
||||
|
||||
f.close();
|
||||
f2.close();
|
||||
f3.close();
|
||||
f4.close();
|
||||
cout << "rcbasic_dev file was created" << endl;
|
||||
}
|
||||
|
||||
@@ -967,6 +1030,9 @@ void rcbasic_output_debug_info()
|
||||
case ID_TYPE_USER:
|
||||
f << "U " << id[i].scope << " " << id[i].name << " " << id[i].vec_pos << "\n";
|
||||
break;
|
||||
case ID_TYPE_BYREF_USER:
|
||||
f << "BU " << id[i].scope << " " << id[i].name << " " << id[i].vec_pos << "\n";
|
||||
break;
|
||||
case ID_TYPE_USER_NUM:
|
||||
f << "UN " << id[i].scope << " " << id[i].name << " " << id[i].vec_pos << "\n";
|
||||
break;
|
||||
@@ -998,7 +1064,7 @@ int main(int argc, char * argv[])
|
||||
{
|
||||
string line = "";
|
||||
|
||||
rcbasic_dev("embedded_functions.bas"); return 0;
|
||||
//rcbasic_dev("embedded_functions.bas"); return 0;
|
||||
|
||||
string rc_filename = "";// = "tst.bas";
|
||||
|
||||
|
||||
@@ -1452,6 +1452,21 @@ bool pre_parse(int start_token = 0, int end_token = -1, int pp_flags, bool eval_
|
||||
byref_type_flag = true;
|
||||
break;
|
||||
}
|
||||
else if(id[tmp_id].type == ID_TYPE_USER)
|
||||
{
|
||||
if(udt_id_init)
|
||||
tmp_instruction = "obj_usr_init";
|
||||
else
|
||||
tmp_instruction = "obj_usr";
|
||||
vm_asm.push_back("mov " + n + " 0");
|
||||
tmp_instruction += ( id[tmp_id].num_args <= 0 ? "" : rc_intToString(id[tmp_id].num_args) );
|
||||
for(int tmp_arg_i = 0; tmp_arg_i < id[tmp_id].num_args; tmp_arg_i++)
|
||||
args[tmp_arg_i] = n;
|
||||
|
||||
vm_asm.push_back(tmp_instruction + " !" + rc_intToString(id[tmp_id].vec_pos) + " " + args[0] + " " + args[1] + " " + args[2]);
|
||||
byref_type_flag = true;
|
||||
break;
|
||||
}
|
||||
//-------------------------------
|
||||
|
||||
return false;
|
||||
@@ -2088,6 +2103,7 @@ bool pre_parse(int start_token = 0, int end_token = -1, int pp_flags, bool eval_
|
||||
string tmp_fn_name = StringToLower(id[expr_id].name);
|
||||
if(tmp_fn_name.compare("arraydim")==0)
|
||||
{
|
||||
cout << "found array dim" << endl;
|
||||
int tmp_id_type = -1;
|
||||
|
||||
if(args[n].substr(0,4).compare("<id>")==0)
|
||||
@@ -2103,7 +2119,7 @@ bool pre_parse(int start_token = 0, int end_token = -1, int pp_flags, bool eval_
|
||||
expr_id = getIDInScope_ByIndex("numberarraydim");
|
||||
else if(args[n].substr(0,1).compare("s")==0 || tmp_id_type == ID_TYPE_STR || tmp_id_type == ID_TYPE_ARR_STR || tmp_id_type == ID_TYPE_BYREF_STR)
|
||||
expr_id = getIDInScope_ByIndex("stringarraydim");
|
||||
else if(args[n].substr(0,1).compare("u")==0)
|
||||
else if(args[n].substr(0,1).compare("u")==0 || tmp_id_type == ID_TYPE_USER || tmp_id_type == ID_TYPE_BYREF_USER)
|
||||
expr_id = getIDInScope_ByIndex("typearraydim");
|
||||
else
|
||||
{
|
||||
@@ -2138,6 +2154,17 @@ bool pre_parse(int start_token = 0, int end_token = -1, int pp_flags, bool eval_
|
||||
}
|
||||
vm_asm.push_back("ptr$ !" + rc_intToString(id[expr_id].fn_arg_vec[n]) + " " + args[n]);
|
||||
break;
|
||||
case ID_TYPE_BYREF_USER:
|
||||
//cout << "start up" << endl;
|
||||
if(args[n].substr(0,1).compare("u")!=0)
|
||||
{
|
||||
rc_setError("Expected defined type identifier for argument: " + rc_intToString(id[expr_id].fn_arg_utype[n]));
|
||||
return false;
|
||||
}
|
||||
//cout << "yolo: " << expr_id << " ~ " << id.size() << " -- " << id[expr_id].num_args << endl;
|
||||
vm_asm.push_back("uref_ptr !" + rc_intToString(id[expr_id].fn_arg_vec[n]) + " " + args[n]);
|
||||
//cout << "testing" << endl;
|
||||
break;
|
||||
}
|
||||
else
|
||||
switch(id[expr_id].fn_arg_type[n])
|
||||
@@ -2158,6 +2185,14 @@ bool pre_parse(int start_token = 0, int end_token = -1, int pp_flags, bool eval_
|
||||
}
|
||||
vm_asm.push_back("ptr$ !" + rc_intToString(id[expr_id].fn_arg_vec[n]) + " " + resolveID_id_reg[resolve_index]);
|
||||
break;
|
||||
case ID_TYPE_BYREF_USER:
|
||||
if(resolveID_id_type[resolve_index] != ID_TYPE_USER && resolveID_id_type[resolve_index] != ID_TYPE_BYREF_USER)
|
||||
{
|
||||
rc_setError("Expected defined type identifier for argument: " + rc_intToString(id[expr_id].fn_arg_utype[n]));
|
||||
return false;
|
||||
}
|
||||
vm_asm.push_back("uref_ptr !" + rc_intToString(id[expr_id].fn_arg_vec[n]) + " " + resolveID_id_reg[resolve_index]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(id[expr_id].fn_arg_type[n] == ID_TYPE_BYREF_USER)
|
||||
@@ -6025,6 +6060,33 @@ bool check_rule_embedded()
|
||||
{
|
||||
if(token.size() > 0)
|
||||
{
|
||||
if(current_block_state == BLOCK_STATE_TYPE)
|
||||
{
|
||||
if(token[0].compare("<dim>")!=0 && token[0].compare("<end>")!=0)
|
||||
{
|
||||
rc_setError("Expected DIM in TYPE definition");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(current_block_state != BLOCK_STATE_MAIN)
|
||||
{
|
||||
if(token[0].compare("<type>")==0)
|
||||
{
|
||||
rc_setError("TYPE cannot be declared in the current scope");
|
||||
return false;
|
||||
}
|
||||
else if(token[0].compare("<function>")==0)
|
||||
{
|
||||
rc_setError("FUNCTION cannot be declared in the current scope");
|
||||
return false;
|
||||
}
|
||||
else if(token[0].compare("<subp>")==0)
|
||||
{
|
||||
rc_setError("SUB ROUTINE cannot be declared in the current scope");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(token[0].compare("<function>")==0)
|
||||
{
|
||||
if(token.size()<2)
|
||||
@@ -6067,7 +6129,7 @@ bool check_rule_embedded()
|
||||
}
|
||||
}
|
||||
|
||||
if(!create_function(fn_name, fn_type, fn_type_name))
|
||||
if(!embed_function(fn_name, fn_type, getUType(fn_type_name)))
|
||||
{
|
||||
rc_setError("Could not create FUNCTION \"" + fn_name + "\" of type \"" + fn_type_name + "\"");
|
||||
return false;
|
||||
@@ -6140,7 +6202,7 @@ bool check_rule_embedded()
|
||||
fn_arg_type = ID_TYPE_BYREF_USER;
|
||||
}
|
||||
|
||||
if(!add_function_arg(fn_arg, fn_arg_type, fn_arg_user_type))
|
||||
if(!add_embedded_arg(fn_arg, fn_arg_type, getUType(fn_arg_user_type)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -6183,7 +6245,7 @@ bool check_rule_embedded()
|
||||
fn_arg_type = ID_TYPE_BYREF_USER;
|
||||
}
|
||||
|
||||
if(!add_function_arg(fn_arg, fn_arg_type, fn_arg_user_type))
|
||||
if(!add_embedded_arg(fn_arg, fn_arg_type, getUType(fn_arg_user_type)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -6236,7 +6298,7 @@ bool check_rule_embedded()
|
||||
|
||||
string fn_type_name = "";
|
||||
|
||||
if(!create_function(fn_name, fn_type, fn_type_name))
|
||||
if(!embed_function(fn_name, fn_type, getUType(fn_type_name)))
|
||||
{
|
||||
rc_setError("Could not create SUB ROUTINE \"" + fn_name + "\"");
|
||||
return false;
|
||||
@@ -6352,7 +6414,7 @@ bool check_rule_embedded()
|
||||
fn_arg_type = ID_TYPE_BYREF_USER;
|
||||
}
|
||||
|
||||
if(!add_function_arg(fn_arg, fn_arg_type, fn_arg_user_type))
|
||||
if(!add_embedded_arg(fn_arg, fn_arg_type, getUType(fn_arg_user_type)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -6412,6 +6474,245 @@ bool check_rule_embedded()
|
||||
|
||||
current_scope = start_label;
|
||||
}
|
||||
else if(token[0].compare("<dim>")==0)
|
||||
{
|
||||
if(current_block_state != BLOCK_STATE_TYPE)
|
||||
{
|
||||
rc_setError("DIM can only be used for type members when embedding");
|
||||
return false;
|
||||
}
|
||||
//cout << "DIM RULE FOUND" << endl; //'DIM' [ID]; '[' #; #; # ']' ; 'AS' [TYPE]; '=' (VALUE)
|
||||
|
||||
string id_name = "";
|
||||
int id_type = ID_TYPE_NUM;
|
||||
string id_type_name = "";
|
||||
int dimensions = 0;
|
||||
|
||||
//check if the next token is a identifier
|
||||
if(token.size() > 1)
|
||||
{
|
||||
if(token[1].substr(0,4).compare("<id>")==0)
|
||||
{
|
||||
//if the identifier is not a valid name then return false
|
||||
id_name = token[1].substr(4);
|
||||
id_type = ID_TYPE_NUM;
|
||||
id_type_name = "";
|
||||
dimensions = 0;
|
||||
|
||||
if(!isValidIDName(id_name))
|
||||
{
|
||||
rc_setError("Invalid Identifier name");
|
||||
return false;
|
||||
}
|
||||
|
||||
//check if the data type is a string
|
||||
if(id_name.substr(id_name.length()-1).compare("$")==0)
|
||||
id_type = ID_TYPE_STR;
|
||||
|
||||
//if the identifier already exists and current_block state is not type then return false
|
||||
if(idExistsInScope(id_name))
|
||||
{
|
||||
rc_setError("Identifier already defined in current scope");
|
||||
return false;
|
||||
}
|
||||
|
||||
//cout << "db1\n";
|
||||
|
||||
//if there are only two tokens then return here because there is nothing left to check
|
||||
if(token.size()==2)
|
||||
{
|
||||
if(current_block_state == BLOCK_STATE_TYPE)
|
||||
{
|
||||
//cout << "adding type member" << endl;
|
||||
if(!add_type_member_embedded(id_name, id_type, "", 0, 0, 0, 0))
|
||||
{
|
||||
//cout << rc_getError() << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//cout << "return true here" << endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
//cout << "db2\n";
|
||||
|
||||
//current token
|
||||
int token_index = 2;
|
||||
|
||||
int t_dim_arg[3];
|
||||
t_dim_arg[0] = 0;
|
||||
t_dim_arg[1] = 0;
|
||||
t_dim_arg[2] = 0;
|
||||
|
||||
//check for the next rule; must be [], AS, or =
|
||||
//cout << "token = " << token[token_index] << endl;
|
||||
if(token[token_index].compare("<square>")==0 && current_block_state == BLOCK_STATE_TYPE)
|
||||
{
|
||||
//token_index++;
|
||||
int end_token = token_index+1;
|
||||
int sq_scope = 1;
|
||||
multi_arg_count = 0;
|
||||
int arg_index = 0;
|
||||
|
||||
t_dim_arg[0] = 0;
|
||||
t_dim_arg[1] = 0;
|
||||
t_dim_arg[2] = 0;
|
||||
for(; end_token < token.size(); end_token++)
|
||||
{
|
||||
if(token[end_token].compare("<square>")==0)
|
||||
sq_scope++;
|
||||
else if(token[end_token].compare("</square>")==0)
|
||||
sq_scope--;
|
||||
else if(token[end_token].substr(0,5).compare("<num>")==0)
|
||||
{
|
||||
if(arg_index > 2)
|
||||
{
|
||||
rc_setError("Too many dimensions in type member declaration for embedded");
|
||||
return false;
|
||||
}
|
||||
multi_arg[arg_index] = token[end_token].substr(5);
|
||||
t_dim_arg[arg_index] = rc_stringToInt(multi_arg[arg_index]);
|
||||
multi_arg_count = arg_index+1;
|
||||
}
|
||||
else if(token[end_token].compare("<comma>")==0)
|
||||
arg_index++;
|
||||
else
|
||||
{
|
||||
rc_setError("Expected number constant in type member declaration for embedded: " + token[end_token]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(sq_scope==0)
|
||||
break;
|
||||
}
|
||||
if(sq_scope != 0)
|
||||
{
|
||||
rc_setError("Expected ] in array definition");
|
||||
return false;
|
||||
}
|
||||
|
||||
dimensions = multi_arg_count;
|
||||
|
||||
|
||||
token_index = end_token+1;
|
||||
|
||||
//cout << "DBG token = " << token[token_index] << std::endl;
|
||||
|
||||
if(token.size() > token_index)
|
||||
{
|
||||
if(token[token_index].compare("<as>")==0)
|
||||
{
|
||||
token_index++;
|
||||
if(token[token_index].substr(0,4).compare("<id>")!=0)
|
||||
{
|
||||
rc_setError("Invalid type identifier name in DIM");
|
||||
return false;
|
||||
}
|
||||
|
||||
id_type = ID_TYPE_USER;
|
||||
id_type_name = token[token_index].substr(4);
|
||||
//cout << "Add member (" << id_name << ") of type (" << id_type_name << ") with " << dimensions << " dimensions [" << constant_arg[0] << "," << constant_arg[1] << "," << constant_arg[2] << "]" << endl;
|
||||
//if(!add_type_member(id_name, id_type, id_type_name, dimensions, constant_arg[0], constant_arg[1], constant_arg[2]))
|
||||
if(!add_type_member_embedded(id_name, id_type, id_type_name, dimensions, t_dim_arg[0], t_dim_arg[1], t_dim_arg[2]))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
rc_setError("Invalid member array declaration in DIM");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//cout << "Add member (" << id_name << ") of type (num/str) with " << dimensions << " dimensions [" << constant_arg[0] << "," << constant_arg[1] << "," << constant_arg[2] << "]" << endl;
|
||||
//if(!add_type_member(id_name, id_type, "", dimensions, constant_arg[0], constant_arg[1], constant_arg[2]))
|
||||
if(!add_type_member_embedded(id_name, id_type, "", dimensions, t_dim_arg[0], t_dim_arg[1], t_dim_arg[2]))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
else if(token[token_index].compare("<as>")==0)
|
||||
{
|
||||
token_index++;
|
||||
|
||||
if(token_index >= token.size())
|
||||
{
|
||||
rc_setError("Invalid member declaration");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(token[token_index].substr(0,4).compare("<id>")!=0)
|
||||
{
|
||||
rc_setError("Invalid type identifier name in DIM");
|
||||
return false;
|
||||
}
|
||||
|
||||
id_type = ID_TYPE_USER;
|
||||
id_type_name = token[token_index].substr(4);
|
||||
//cout << "Add member (" << id_name << ") of type (" << id_type_name << ") with " << dimensions << " dimensions [" << constant_arg[0] << "," << constant_arg[1] << "," << constant_arg[2] << "]" << endl;
|
||||
//if(!add_type_member(id_name, id_type, id_type_name, dimensions, constant_arg[0], constant_arg[1], constant_arg[2]))
|
||||
if(!add_type_member_embedded(id_name, id_type, id_type_name, 0, 0, 0, 0))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if(token.size()>token_index)
|
||||
{
|
||||
rc_setError("Invalid variable definition: " + token[token_index] + ", " + rc_intToString(current_block_state) + " <--> " + rc_intToString(BLOCK_STATE_TYPE));
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//if the next token is not an id then the syntax is incorrect and false is returned
|
||||
rc_setError("Expected Identifier name");
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//if the size of the token vector is not greater than one then the syntax for the line is incomplete so I return false
|
||||
rc_setError("Expected Identifier name");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(token[0].compare("<end>")==0)
|
||||
{
|
||||
if(token.size()==1)
|
||||
{
|
||||
rc_setError("END can only be used to end TYPE when embedding");
|
||||
return false;
|
||||
}
|
||||
if(token[1].compare("<type>")==0)
|
||||
{
|
||||
if(token.size()>2)
|
||||
{
|
||||
rc_setError("Expected End of Line in END TYPE");
|
||||
return false;
|
||||
}
|
||||
if(current_block_state != BLOCK_STATE_TYPE)
|
||||
{
|
||||
rc_setError("Cannot exit TYPE definition from this scope");
|
||||
return false;
|
||||
}
|
||||
|
||||
block_state.pop();
|
||||
current_block_state = BLOCK_STATE_MAIN;
|
||||
current_scope = "main";
|
||||
}
|
||||
else
|
||||
{
|
||||
rc_setError("END can only be used to end TYPE when embedding");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define RC_BUILTIN_H_INCLUDED
|
||||
#include "identifier.h"
|
||||
|
||||
void init_embedded()
|
||||
void init_embedded_functions()
|
||||
{
|
||||
embed_function("FPrint", ID_TYPE_SUB);
|
||||
add_embedded_arg("txt$", ID_TYPE_STR);
|
||||
@@ -1422,18 +1422,23 @@ void init_embedded()
|
||||
add_embedded_arg("mB", ID_TYPE_NUM);
|
||||
add_embedded_arg("mC", ID_TYPE_NUM);
|
||||
embed_function("TypeArrayDim", ID_TYPE_FN_NUM);
|
||||
add_embedded_arg("id$", ID_TYPE_BYREF_STR);
|
||||
add_embedded_arg("id", ID_TYPE_BYREF_USER, 0);
|
||||
embed_function("TypeArraySize", ID_TYPE_FN_NUM);
|
||||
add_embedded_arg("id", ID_TYPE_BYREF_NUM);
|
||||
add_embedded_arg("id", ID_TYPE_BYREF_USER, 0);
|
||||
add_embedded_arg("array_dim", ID_TYPE_NUM);
|
||||
embed_function("TypeArrayCopy", ID_TYPE_SUB);
|
||||
add_embedded_arg("src", ID_TYPE_BYREF_NUM);
|
||||
add_embedded_arg("dst", ID_TYPE_BYREF_NUM);
|
||||
add_embedded_arg("src", ID_TYPE_BYREF_USER, 0);
|
||||
add_embedded_arg("dst", ID_TYPE_BYREF_USER, 0);
|
||||
embed_function("TypeArrayFill", ID_TYPE_SUB);
|
||||
add_embedded_arg("src", ID_TYPE_BYREF_NUM);
|
||||
add_embedded_arg("fdata", ID_TYPE_NUM);
|
||||
add_embedded_arg("src", ID_TYPE_BYREF_USER, 0);
|
||||
add_embedded_arg("fdata", ID_TYPE_USER, 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void init_embedded_types()
|
||||
{
|
||||
create_type("empty");
|
||||
}
|
||||
|
||||
#endif // RC_BUILTIN_H_INCLUDED
|
||||
|
||||
@@ -1416,13 +1416,13 @@ add_embedded_arg("mA", ID_TYPE_NUM);
|
||||
add_embedded_arg("mB", ID_TYPE_NUM);
|
||||
add_embedded_arg("mC", ID_TYPE_NUM);
|
||||
embed_function("TypeArrayDim", ID_TYPE_FN_NUM);
|
||||
add_embedded_arg("id$", ID_TYPE_BYREF_STR);
|
||||
add_embedded_arg("id", ID_TYPE_BYREF_USER, 0);
|
||||
embed_function("TypeArraySize", ID_TYPE_FN_NUM);
|
||||
add_embedded_arg("id", ID_TYPE_BYREF_NUM);
|
||||
add_embedded_arg("id", ID_TYPE_BYREF_USER, 0);
|
||||
add_embedded_arg("array_dim", ID_TYPE_NUM);
|
||||
embed_function("TypeArrayCopy", ID_TYPE_SUB);
|
||||
add_embedded_arg("src", ID_TYPE_BYREF_NUM);
|
||||
add_embedded_arg("dst", ID_TYPE_BYREF_NUM);
|
||||
add_embedded_arg("src", ID_TYPE_BYREF_USER, 0);
|
||||
add_embedded_arg("dst", ID_TYPE_BYREF_USER, 0);
|
||||
embed_function("TypeArrayFill", ID_TYPE_SUB);
|
||||
add_embedded_arg("src", ID_TYPE_BYREF_NUM);
|
||||
add_embedded_arg("fdata", ID_TYPE_NUM);
|
||||
add_embedded_arg("src", ID_TYPE_BYREF_USER, 0);
|
||||
add_embedded_arg("fdata", ID_TYPE_USER, 0);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
1
rcbasic_build/rcbasic_dev4.txt
Normal file
1
rcbasic_build/rcbasic_dev4.txt
Normal file
@@ -0,0 +1 @@
|
||||
create_type("empty");
|
||||
@@ -172,6 +172,8 @@ struct rc_usrId
|
||||
rc_usrId * var_ref;
|
||||
uint64_t var_ref_index;
|
||||
|
||||
rc_usrId* byref_ptr;
|
||||
|
||||
bool preset_init = false;
|
||||
|
||||
#ifdef RCBASIC_DEBUG
|
||||
@@ -1378,30 +1380,71 @@ void obj_usr_81(uint64_t uid)
|
||||
{
|
||||
//cout << "obj_usr " << uid << ": size = " << usr_object.obj_ref->uid_value[uid].uid_value.size() << endl;
|
||||
usr_object.index = 0;
|
||||
|
||||
rc_usrId* tmp_usr_id = &usr_object.obj_ref->uid_value[uid];
|
||||
|
||||
usr_object.obj_ref = &usr_object.obj_ref->uid_value[uid].uid_value[0];
|
||||
|
||||
usr_object.obj_ref->byref_ptr = tmp_usr_id;
|
||||
//usr_object.obj_ref->byref_ptr = &usr_object.obj_ref->uid_value[uid];
|
||||
}
|
||||
|
||||
void obj_usr1_82(uint64_t uid, int n1)
|
||||
{
|
||||
//cout << "obj_usr2 " << uid << " " << (uint64_t)vm_n[n1].value << " " << (uint64_t)vm_n[n2].value << ": size = " << usr_object.obj_ref->uid_value.size() << endl;
|
||||
//rc_usrId* tmp_usr_id = &usr_object.obj_ref->uid_value[uid];
|
||||
//usr_object.index = (uint64_t)vm_n[n1].value;;
|
||||
//cout << "\n\nuid =" << uid << ", index = (" << usr_object.index << ") old_index = " << usr_object.index << endl << endl;
|
||||
//cout << "\n\nusr index = " << usr_object.obj_ref->uid_value[uid].uid_value[usr_object.index].str_var.size() << endl << endl;
|
||||
|
||||
|
||||
//cout << "obj_usr1 " << uid << " " << (uint64_t)vm_n[n1].value << endl;
|
||||
//cout << " ---dbg[uid]: " << usr_object.obj_ref->uid_value[uid].uid_value[1].num_var[0].nid_value.value[0] << endl;
|
||||
//cout << " ---dbg[str]: " << usr_object.obj_ref->uid_value[uid].uid_value[0].str_var.size() << endl;
|
||||
usr_object.index = (uint64_t)vm_n[n1].value;
|
||||
|
||||
rc_usrId* tmp_usr_id = &usr_object.obj_ref->uid_value[uid];
|
||||
|
||||
usr_object.obj_ref = &usr_object.obj_ref->uid_value[uid].uid_value[usr_object.index];
|
||||
|
||||
usr_object.obj_ref->byref_ptr = tmp_usr_id;
|
||||
//usr_object.obj_ref->byref_ptr = &usr_object.obj_ref->uid_value[uid];
|
||||
}
|
||||
|
||||
void obj_usr2_83(uint64_t uid, int n1, int n2)
|
||||
{
|
||||
//cout << "obj_usr2 " << uid << " " << (uint64_t)vm_n[n1].value << " " << (uint64_t)vm_n[n2].value << ": size = " << usr_object.obj_ref->uid_value.size() << endl;
|
||||
//rc_usrId* tmp_usr_id = &usr_object.obj_ref->uid_value[uid];
|
||||
//usr_object.index = (uint64_t)vm_n[n1].value * usr_object.obj_ref->uid_value[uid].dim[1] + (uint64_t)vm_n[n2].value;
|
||||
//cout << "\n\nuid =" << uid << ", index = (" << usr_object.index << ") old_index = " << usr_object.index << endl << endl;
|
||||
//cout << "\n\nusr index = " << usr_object.obj_ref->uid_value[uid].uid_value.size() << endl << endl;
|
||||
|
||||
usr_object.index = (uint64_t)vm_n[n1].value * usr_object.obj_ref->uid_value[uid].dim[1] + (uint64_t)vm_n[n2].value;
|
||||
|
||||
rc_usrId* tmp_usr_id = &usr_object.obj_ref->uid_value[uid];
|
||||
|
||||
usr_object.obj_ref = &usr_object.obj_ref->uid_value[uid].uid_value[usr_object.index];
|
||||
|
||||
usr_object.obj_ref->byref_ptr = tmp_usr_id;
|
||||
//usr_object.obj_ref->byref_ptr = &usr_object.obj_ref->uid_value[uid];
|
||||
}
|
||||
|
||||
void obj_usr3_84(uint64_t uid, int n1, int n2, int n3)
|
||||
{
|
||||
//rc_usrId* tmp_usr_id = &usr_object.obj_ref->uid_value[uid];
|
||||
|
||||
//cout << "obj_usr3 " << uid << " " << (uint64_t)vm_n[n1].value << " " << (uint64_t)vm_n[n2].value << " " << (uint64_t)vm_n[n3].value << endl;
|
||||
usr_object.index = ( (uint64_t)vm_n[n1].value * usr_object.obj_ref->uid_value[uid].dim[1] * usr_object.obj_ref->uid_value[uid].dim[2] ) + ((uint64_t)vm_n[n2].value * usr_object.obj_ref->uid_value[uid].dim[2]) + (uint64_t)vm_n[n3].value;;
|
||||
|
||||
//----test
|
||||
rc_usrId* tmp_usr_id = &usr_object.obj_ref->uid_value[uid];
|
||||
//------------------------------------------
|
||||
|
||||
usr_object.obj_ref = &usr_object.obj_ref->uid_value[uid].uid_value[usr_object.index];
|
||||
|
||||
usr_object.obj_ref->byref_ptr = tmp_usr_id;
|
||||
|
||||
//usr_object.obj_ref->byref_ptr = &usr_object.obj_ref->uid_value[uid];
|
||||
}
|
||||
|
||||
void obj_get_85(int n1)
|
||||
@@ -2205,6 +2248,11 @@ uint64_t rc_number_array_dim(rc_numId n_var)
|
||||
return n->dimensions;
|
||||
}
|
||||
|
||||
uint64_t rc_type_array_dim(rc_usrId* u_var)
|
||||
{
|
||||
return u_var->dimensions;
|
||||
}
|
||||
|
||||
uint64_t rc_number_array_size(rc_numId n_var, int d_num)
|
||||
{
|
||||
switch(d_num)
|
||||
@@ -4043,6 +4091,17 @@ void func_130(uint64_t fn)
|
||||
JoinMatrixColumns(JOINMATRIXCOLUMNS_MA, JOINMATRIXCOLUMNS_MB, JOINMATRIXCOLUMNS_MC);
|
||||
break;
|
||||
|
||||
case FN_TypeArrayDim: //Number Function
|
||||
rc_push_num( rc_type_array_dim( TYPEARRAYDIM_ID ) );
|
||||
arr_ref_id.clear();
|
||||
break;
|
||||
case FN_TypeArraySize: //Number Function
|
||||
break;
|
||||
case FN_TypeArrayCopy: //Sub Procedure
|
||||
break;
|
||||
case FN_TypeArrayFill: //Sub Procedure
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4410,14 +4469,25 @@ void obj_usr_get_165(int s1)
|
||||
void obj_usr_get_166(int u1)
|
||||
{
|
||||
//cout << "obj_usr_get start u" << u1 << endl;
|
||||
//rc_usrId * tmp_usr_id = usr_object.obj_ref->byref_ptr;
|
||||
//cout << "tmp check = " << usr_object.obj_ref->byref_ptr->dimensions << endl;
|
||||
|
||||
rc_free_type(&vm_u[u1]); //this should free any memory previously allocated in u1
|
||||
|
||||
//cout << "tmp check[2] = " << usr_object.obj_ref->byref_ptr->dimensions << endl;
|
||||
|
||||
//cout << "mem free: " << usr_object.obj_ref->dimensions << endl;
|
||||
vm_u[u1] = usr_object.obj_ref[0];
|
||||
//cout << "1: " << usr_object.obj_ref[0].uid_value.size() << endl;
|
||||
vm_u[u1].var_ref = usr_object.obj_ref;
|
||||
//cout << "2" << endl;
|
||||
vm_u[u1].var_ref_index = 0 ; //usr_object.index; This has become unnecessary because var_ref points to the correct index
|
||||
vm_u[u1].var_ref_index = usr_object.index; //usr_object.index;
|
||||
|
||||
//cout << "obj_usr_get end" << endl;
|
||||
|
||||
//cout << "tmp check[3] = " << vm_u[u1].var_ref->byref_ptr->dimensions << endl;
|
||||
|
||||
//cout << "bcheck = " << tmp_usr_id->dimensions << endl;
|
||||
}
|
||||
|
||||
void uref_ptr_167(uint64_t uid, int u1)
|
||||
@@ -4429,8 +4499,17 @@ void uref_ptr_167(uint64_t uid, int u1)
|
||||
byref_addr_table.push(byref_id);
|
||||
byref_var_byref_offset.push(usr_var[uid].var_ref_index);
|
||||
|
||||
usr_var[uid].var_ref = vm_u[u1].var_ref;
|
||||
usr_var[uid].var_ref_index = vm_u[u1].var_ref_index;
|
||||
//cout << "start index = " << usr_var[uid].var_ref_index << endl;
|
||||
|
||||
int i = vm_u[u1].var_ref_index;
|
||||
|
||||
usr_var[uid].var_ref = vm_u[u1].var_ref->byref_ptr;
|
||||
usr_var[uid].var_ref_index = i; //vm_u[u1].var_ref_index;
|
||||
|
||||
//int i = vm_u[u1].var_ref_index;
|
||||
//cout << "index = " << usr_var[uid].var_ref_index << endl;
|
||||
//cout << "uref end: " << usr_var[uid].var_ref->uid_value.size() << endl;
|
||||
//cout << "debug out = " << usr_var[uid].var_ref->uid_value[i].str_var[0].sid_value.value[3] << endl;
|
||||
}
|
||||
|
||||
void mov_type_168(uint64_t uid, int u1)
|
||||
@@ -4520,7 +4599,7 @@ void delete_t_174(uint64_t oid, uint64_t top_level_flag, uint64_t obj_type)
|
||||
break;
|
||||
}
|
||||
}
|
||||
cout << "Done" << endl;
|
||||
//cout << "Done" << endl;
|
||||
}
|
||||
|
||||
void dim_type_175(int u1, int udt_index)
|
||||
@@ -4561,15 +4640,25 @@ void obj_usr_init_180(uint64_t uid)
|
||||
{
|
||||
//cout << "obj_usr_init " << uid << endl;
|
||||
usr_object.index = 0;
|
||||
|
||||
usr_object.index += usr_var[uid].var_ref_index;
|
||||
|
||||
usr_object.obj_ref = &usr_var[uid].var_ref->uid_value[usr_object.index]; //need to switch to var_ref
|
||||
//cout << "obj_usr_init done: " << usr_object.obj_ref[0].uid_value.size() << endl;
|
||||
|
||||
usr_object.obj_ref->byref_ptr = usr_var[uid].var_ref;
|
||||
}
|
||||
|
||||
void obj_usr_init1_181(uint64_t uid, int n1)
|
||||
{
|
||||
//cout << "obj_usr_init1 " << uid << endl;
|
||||
usr_object.index = (uint64_t)vm_n[n1].value;
|
||||
|
||||
usr_object.index += usr_var[uid].var_ref_index;
|
||||
|
||||
usr_object.obj_ref = &usr_var[uid].var_ref->uid_value[usr_object.index];
|
||||
|
||||
usr_object.obj_ref->byref_ptr = usr_var[uid].var_ref;
|
||||
}
|
||||
|
||||
void obj_usr_init2_182(uint64_t uid, int n1, int n2)
|
||||
@@ -4580,14 +4669,27 @@ void obj_usr_init2_182(uint64_t uid, int n1, int n2)
|
||||
//d[2] = usr_var[uid].dim[2];
|
||||
//cout << "obj_usr_init2: " << uid << " --dim=[" << d[0] << ", " << d[1] << ", " << d[2] << "]" << endl;
|
||||
usr_object.index = (uint64_t)vm_n[n1].value * usr_var[uid].dim[1] + (uint64_t)vm_n[n2].value;
|
||||
|
||||
usr_object.index += usr_var[uid].var_ref_index;
|
||||
|
||||
usr_object.obj_ref = &usr_var[uid].var_ref->uid_value[usr_object.index];
|
||||
|
||||
usr_object.obj_ref->byref_ptr = usr_var[uid].var_ref;
|
||||
|
||||
//cout << "dimbr = " << uid << " " << n1 << " " << n2 << " " << usr_object.obj_ref->byref_ptr->dimensions << endl;
|
||||
//cout << "d2_dbg = " << usr_var[uid].var_ref->uid_value.size() << " --- " << usr_object.index << endl;
|
||||
}
|
||||
|
||||
void obj_usr_init3_183(uint64_t uid, int n1, int n2, int n3)
|
||||
{
|
||||
//cout << "obj_usr_init3 " << uid << endl;
|
||||
usr_object.index = ( (uint64_t)vm_n[n1].value * usr_var[uid].dim[1] * usr_var[uid].dim[2] ) + ((uint64_t)vm_n[n2].value * usr_var[uid].dim[2]) + (uint64_t)vm_n[n3].value;;
|
||||
|
||||
usr_object.index += usr_var[uid].var_ref_index;
|
||||
|
||||
usr_object.obj_ref = &usr_var[uid].var_ref->uid_value[usr_object.index];
|
||||
|
||||
usr_object.obj_ref->byref_ptr = usr_var[uid].var_ref;
|
||||
}
|
||||
|
||||
|
||||
@@ -4842,7 +4944,7 @@ void redim_type2_206(uint64_t uid, int udt_index, int n1, int n2)
|
||||
else
|
||||
rc_dim_type(&usr_object.obj_ref->uid_value[uid], udt_index, 2, (uint64_t)vm_n[n1].value, (uint64_t)vm_n[n2].value, 0, usr_object.obj_ref->uid_value[uid].uid_value.size());
|
||||
|
||||
cout << "test tl: " << redim_toplevel_flag << " -- " << usr_var[uid].uid_value.size() << endl;
|
||||
//cout << "test tl: " << redim_toplevel_flag << " -- " << usr_var[uid].uid_value.size() << endl;
|
||||
|
||||
redim_toplevel_flag = false;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user