Added new redim instructions to runtime
This commit is contained in:
@@ -1480,6 +1480,12 @@ bool pre_parse(int start_token = 0, int end_token = -1, int pp_flags, bool eval_
|
||||
type_redim_dim[0] = args[0];
|
||||
type_redim_dim[1] = args[1];
|
||||
type_redim_dim[2] = args[2];
|
||||
|
||||
if(arg_count != id[tmp_id].num_args)
|
||||
{
|
||||
rc_setError("Expected " + rc_intToString(id[tmp_id].num_args) + " dimensions but found " + rc_intToString(arg_count));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(type_delete_flag && (!has_child))
|
||||
{
|
||||
@@ -3767,9 +3773,7 @@ bool check_rule()
|
||||
//cout << "M_ARG[2] = " << multi_arg[2] << endl;
|
||||
dimensions = multi_arg_count;
|
||||
}
|
||||
token_index = end_token+1;
|
||||
|
||||
type_redim_flag = false;
|
||||
token_index = end_token+1;
|
||||
|
||||
//cout << "debug 3: " << id_index << endl;
|
||||
}
|
||||
@@ -3793,7 +3797,18 @@ bool check_rule()
|
||||
//if the next token is not an id then the syntax is incorrect and false is returned
|
||||
rc_setError("Expected Identifier name");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!type_redim_flag) //if type_redim_flag is set, then this error will get raised in the pre_parse step
|
||||
{
|
||||
if(dimensions != id[id_index].num_args) // no longer allowing the user to change dimensions since it can lead to unnecessary confusion
|
||||
{
|
||||
rc_setError("Expected " + rc_intToString(id[id_index].num_args) + " dimensions but found " + rc_intToString(dimensions));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
type_redim_flag = false;
|
||||
|
||||
if(dimensions > 0)
|
||||
{
|
||||
@@ -3810,10 +3825,10 @@ bool check_rule()
|
||||
|
||||
//cout << "debug 6: " << id_index << endl;
|
||||
|
||||
if(id[id_index].num_args != dimensions)
|
||||
{
|
||||
id[id_index].num_args = dimensions;
|
||||
}
|
||||
//if(id[id_index].num_args != dimensions)
|
||||
//{
|
||||
// id[id_index].num_args = dimensions;
|
||||
//}
|
||||
|
||||
//cout << "debug 7: " << id_index << " -- " << id[id_index].type << endl;
|
||||
|
||||
@@ -3873,6 +3888,8 @@ bool check_rule()
|
||||
}
|
||||
else if(id[id_index].type == ID_TYPE_USER)
|
||||
{
|
||||
vm_asm.push_back("redim_top"); //This will set the top level flag for redim_type
|
||||
|
||||
//cout << "debug 8" << endl;
|
||||
switch(dimensions)
|
||||
{
|
||||
|
||||
@@ -168,7 +168,7 @@ public:
|
||||
s.substr(0,s.find_first_of(" ")).compare("clear_stack$")==0 || s.substr(0,s.find_first_of(" ")).compare("do")==0 ||
|
||||
s.substr(0,s.find_first_of(" ")).compare("pop_loop_stack")==0 || s.substr(0,s.find_first_of(" ")).compare("return")==0 ||
|
||||
s.substr(0,s.find_first_of(" ")).compare("println")==0 || s.substr(0,s.find_first_of(" ")).compare("for_offset_0")==0 ||
|
||||
s.substr(0,s.find_first_of(" ")).compare("push_t_null")==0)
|
||||
s.substr(0,s.find_first_of(" ")).compare("push_t_null")==0 || s.substr(0,s.find_first_of(" ")).compare("redim_top")==0)
|
||||
{
|
||||
current_address[current_segment] += 1; //1 byte for instruction and no arguments
|
||||
}
|
||||
|
||||
@@ -1271,6 +1271,10 @@ namespace rc_cbc_assembler
|
||||
{
|
||||
writeSegment(203);
|
||||
}
|
||||
else if(line_arg[0].compare("redim_top")==0)
|
||||
{
|
||||
writeSegment(208);
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "unrecognized cmd: " << line_arg[0] << endl;
|
||||
|
||||
@@ -305,3 +305,5 @@ OBJ_CURRENT_TYPE
|
||||
205 - redim_type1 !id !id (user type) n# (dim1)
|
||||
206 - redim_type2 !id !id (user type) n# (dim1) n# (dim2)
|
||||
207 - redim_type3 !id !id (user type) n# (dim1) n# (dim2) n# (dim3)
|
||||
|
||||
208 - redim_top
|
||||
|
||||
Reference in New Issue
Block a user