Skip to content

Commit

Permalink
move all labelname() errors to pass 2
Browse files Browse the repository at this point in the history
these are used in getnum, which sometimes doesn't get called until pass
2
  • Loading branch information
randomdude999 committed Jan 19, 2024
1 parent 9a4a0a3 commit f517893
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions src/asar/assembleblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ static string labelname(const char ** rawname, bool define=false)
string name;
int i=-1;

if (is_digit(*deref_rawname)) asar_throw_error(1, error_type_block, error_id_invalid_label_name);
if (is_digit(*deref_rawname)) asar_throw_error(2, error_type_block, error_id_invalid_label_name);
if (*deref_rawname ==':')
{
deref_rawname++;
Expand All @@ -443,10 +443,10 @@ static string labelname(const char ** rawname, bool define=false)
else if (!in_struct && !in_sub_struct)
{
for (i=0;(*deref_rawname =='.');i++) deref_rawname++;
if (!is_ualnum(*deref_rawname)) asar_throw_error(1, error_type_block, error_id_invalid_label_name);
if (!is_ualnum(*deref_rawname)) asar_throw_error(2, error_type_block, error_id_invalid_label_name);
if (i)
{
if (!sublabellist || !(*sublabellist)[i - 1]) asar_throw_error(1, error_type_block, error_id_label_missing_parent);
if (!sublabellist || !(*sublabellist)[i - 1]) asar_throw_error(2, error_type_block, error_id_label_missing_parent);
name+=STR(*sublabellist)[i-1]+"_";
issublabel = true;
}
Expand All @@ -456,7 +456,7 @@ static string labelname(const char ** rawname, bool define=false)
{
// RPG Hacker: Don't add the prefix for sublabels, because they already inherit it from
// their parents' names.
if (!macrorecursion || macrosublabels == nullptr) asar_throw_error(1, error_type_block, error_id_macro_label_outside_of_macro);
if (!macrorecursion || macrosublabels == nullptr) asar_throw_error(2, error_type_block, error_id_macro_label_outside_of_macro);
name = STR":macro_" + dec(calledmacros) + "_" + name;
}

Expand All @@ -469,11 +469,11 @@ static string labelname(const char ** rawname, bool define=false)
}
name += struct_name;
name += '.';
if(*deref_rawname != '.') asar_throw_error(1, error_type_block, error_id_invalid_label_name); //probably should be a better error. TODO!!!
if(*deref_rawname != '.') asar_throw_error(2, error_type_block, error_id_invalid_label_name); //probably should be a better error. TODO!!!
deref_rawname++;
}

if (!is_ualnum(*deref_rawname)) asar_throw_error(1, error_type_block, error_id_invalid_label_name);
if (!is_ualnum(*deref_rawname)) asar_throw_error(2, error_type_block, error_id_invalid_label_name);

while (is_ualnum(*deref_rawname) || *deref_rawname == '.')
{
Expand All @@ -483,9 +483,9 @@ static string labelname(const char ** rawname, bool define=false)
if(!define && *deref_rawname == '[')
{
while (*deref_rawname && *deref_rawname != ']') deref_rawname++;
if(*deref_rawname != ']') asar_throw_error(1, error_type_block, error_id_invalid_label_missing_closer);
if(*deref_rawname != ']') asar_throw_error(2, error_type_block, error_id_invalid_label_missing_closer);
deref_rawname++;
if(*deref_rawname != '.') asar_throw_error(1, error_type_block, error_id_invalid_label_name);
if(*deref_rawname != '.') asar_throw_error(2, error_type_block, error_id_invalid_label_name);
}

while (is_ualnum(*deref_rawname) || *deref_rawname == '.')
Expand Down
2 changes: 1 addition & 1 deletion tests/badlabels.asm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;`errEinvalid_label_name
;`errEinvalid_subscript
;`errEinvalid_subscript
;`errEinvalid_label_name
;`errEinvalid_subscript
;`errEinvalid_subscript
org $008000
Expand Down

0 comments on commit f517893

Please sign in to comment.