Skip to content

Commit

Permalink
Merge pull request #459 from AmyrAhmady/dev
Browse files Browse the repository at this point in the history
remove `emit` keyword
  • Loading branch information
Y-Less authored Oct 6, 2019
2 parents 2f64289 + bd670fb commit e89d8fe
Show file tree
Hide file tree
Showing 12 changed files with 550 additions and 555 deletions.
1 change: 0 additions & 1 deletion source/compiler/sc.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ enum {
tDEFINED,
tDO,
tELSE,
tEMIT,
t__EMIT,
tEND,
tENUM,
Expand Down
4 changes: 1 addition & 3 deletions source/compiler/sc1.c
Original file line number Diff line number Diff line change
Expand Up @@ -1693,7 +1693,6 @@ static void parse(void)
case 0:
/* ignore zero's */
break;
case tEMIT:
case t__EMIT:
emit_flags |= efGLOBAL;
lex(&val,&str);
Expand Down Expand Up @@ -5405,13 +5404,12 @@ static void statement(int *lastindent,int allow_decl)
matchtoken(tSTATIC);
decl_enum(sLOCAL,FALSE);
break;
case tEMIT:
case t__EMIT: {
extern char *sc_tokens[];
const unsigned char *bck_lptr=lptr-strlen(sc_tokens[tok-tFIRST]);
if (matchtoken('{')) {
emit_flags |= efBLOCK;
lastst=tEMIT;
lastst=t__EMIT;
break;
} /* if */
lptr=bck_lptr;
Expand Down
7 changes: 3 additions & 4 deletions source/compiler/sc2.c
Original file line number Diff line number Diff line change
Expand Up @@ -2171,10 +2171,9 @@ char *sc_tokens[] = {
"||", "&&", "==", "!=", "<=", ">=", "<<", ">>>", ">>", "++", "--",
"...", "..",
"assert", "*begin", "break", "case", "char", "const", "continue", "default",
"defined", "do", "else", "emit", "__emit", "*end", "enum", "exit", "for",
"forward", "goto", "if", "native", "new", "operator", "public", "return",
"sizeof", "sleep", "state", "static", "stock", "switch", "tagof", "*then",
"while",
"defined", "do", "else", "__emit", "*end", "enum", "exit", "for", "forward",
"goto", "if", "native", "new", "operator", "public", "return", "sizeof",
"sleep", "state", "static", "stock", "switch", "tagof", "*then", "while",
"#assert", "#define", "#else", "#elseif", "#emit", "#endif", "#endinput",
"#endscript", "#error", "#file", "#if", "#include", "#line", "#pragma",
"#tryinclude", "#undef", "#warning",
Expand Down
1 change: 0 additions & 1 deletion source/compiler/sc3.c
Original file line number Diff line number Diff line change
Expand Up @@ -1462,7 +1462,6 @@ static int hier2(value *lval)
} /* if */
return FALSE;
} /* case */
case tEMIT:
case t__EMIT:
paranthese=matchtoken('(');
emit_flags |= efEXPR;
Expand Down
158 changes: 79 additions & 79 deletions source/compiler/tests/__emit_p1.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -9,55 +9,55 @@ stock test__any(&local_refvar, local_refarray[])
local_label:

// ok
emit const.pri global_const;
emit const.pri global_var;
emit const.pri global_func;
emit const.pri local_refvar;
emit const.pri local_refarray;
emit const.pri local_const;
emit const.pri local_var;
emit const.pri local_static_var;
emit const.pri local_label;
emit const.pri :local_label;
emit const.pri :local_label2;
emit const.pri 0;
emit const.pri -0;
emit const.pri 1;
emit const.pri -1;
emit const.pri 0x0;
emit const.pri -0x0;
emit const.pri 0x1;
emit const.pri -0x1;
__emit const.pri global_const;
__emit const.pri global_var;
__emit const.pri global_func;
__emit const.pri local_refvar;
__emit const.pri local_refarray;
__emit const.pri local_const;
__emit const.pri local_var;
__emit const.pri local_static_var;
__emit const.pri local_label;
__emit const.pri :local_label;
__emit const.pri :local_label2;
__emit const.pri 0;
__emit const.pri -0;
__emit const.pri 1;
__emit const.pri -1;
__emit const.pri 0x0;
__emit const.pri -0x0;
__emit const.pri 0x1;
__emit const.pri -0x1;
#if cellbits == 16
emit const.pri 32767;
emit const.pri -32768;
emit const.pri 0x7FFF;
emit const.pri -0x7FFF;
emit const.pri 0x8000;
emit const.pri -0x8000;
__emit const.pri 32767;
__emit const.pri -32768;
__emit const.pri 0x7FFF;
__emit const.pri -0x7FFF;
__emit const.pri 0x8000;
__emit const.pri -0x8000;
#elseif cellbits == 32
emit const.pri 2147483647;
emit const.pri -2147483648;
emit const.pri 0x7FFFFFFF;
emit const.pri -0x7FFFFFFF;
emit const.pri 0x80000000;
emit const.pri -0x80000000;
__emit const.pri 2147483647;
__emit const.pri -2147483648;
__emit const.pri 0x7FFFFFFF;
__emit const.pri -0x7FFFFFFF;
__emit const.pri 0x80000000;
__emit const.pri -0x80000000;
#else // cellbits == 64
emit const.pri 9223372036854775807;
emit const.pri -9223372036854775808;
emit const.pri 0x7FFFFFFFFFFFFFFF;
emit const.pri -0x7FFFFFFFFFFFFFFF;
emit const.pri 0x8000000000000000;
emit const.pri -0x8000000000000000;
__emit const.pri 9223372036854775807;
__emit const.pri -9223372036854775808;
__emit const.pri 0x7FFFFFFFFFFFFFFF;
__emit const.pri -0x7FFFFFFFFFFFFFFF;
__emit const.pri 0x8000000000000000;
__emit const.pri -0x8000000000000000;
#endif
emit const.pri (cellbits / charbits * 2);
__emit const.pri (cellbits / charbits * 2);

// should trigger an error
emit const.pri -global_func;
emit const.pri -local_label;
emit const.pri --0;
emit const.pri local_label2;
emit const.pri -:local_label;
__emit const.pri -global_func;
__emit const.pri -local_label;
__emit const.pri --0;
__emit const.pri local_label2;
__emit const.pri -:local_label;

local_label2:
}
Expand All @@ -70,23 +70,23 @@ stock test__integer(&local_refvar, local_refarray[])
local_label:

// ok
emit jrel global_const;
emit jrel local_const;
emit jrel 0;
emit jrel 1;
emit jrel -1;
emit jrel 0x1;
emit jrel -0x1;
emit jrel (cellbits / charbits * 2);
__emit jrel global_const;
__emit jrel local_const;
__emit jrel 0;
__emit jrel 1;
__emit jrel -1;
__emit jrel 0x1;
__emit jrel -0x1;
__emit jrel (cellbits / charbits * 2);

// should trigger an error
emit jrel global_var;
emit jrel global_func;
emit jrel local_refvar;
emit jrel local_refarray;
emit jrel local_var;
emit jrel local_static_var;
emit jrel local_label;
__emit jrel global_var;
__emit jrel global_func;
__emit jrel local_refvar;
__emit jrel local_refarray;
__emit jrel local_var;
__emit jrel local_static_var;
__emit jrel local_label;
}

stock test__nonneg(&local_refvar, local_refarray[])
Expand All @@ -97,36 +97,36 @@ stock test__nonneg(&local_refvar, local_refarray[])
local_label:

// ok
emit cmps global_const;
emit cmps local_const;
emit cmps 0;
emit cmps 1;
emit cmps 0x1;
emit cmps (cellbits / charbits * 2);
__emit cmps global_const;
__emit cmps local_const;
__emit cmps 0;
__emit cmps 1;
__emit cmps 0x1;
__emit cmps (cellbits / charbits * 2);
#if cellbits == 16
emit cmps 0x7FFF;
__emit cmps 0x7FFF;
#elseif cellbits == 32
emit cmps 0x7FFFFFFF;
__emit cmps 0x7FFFFFFF;
#else // cellbits == 64
emit cmps 0x7FFFFFFFFFFFFFFF;
__emit cmps 0x7FFFFFFFFFFFFFFF;
#endif

// should trigger an error
emit cmps global_var;
emit cmps global_func;
emit cmps local_refvar;
emit cmps local_refarray;
emit cmps local_var;
emit cmps local_static_var;
emit cmps local_label;
emit cmps -1;
emit cmps -0x1;
__emit cmps global_var;
__emit cmps global_func;
__emit cmps local_refvar;
__emit cmps local_refarray;
__emit cmps local_var;
__emit cmps local_static_var;
__emit cmps local_label;
__emit cmps -1;
__emit cmps -0x1;
#if cellbits == 16
emit cmps 0x8000;
__emit cmps 0x8000;
#elseif cellbits == 32
emit cmps 0x80000000;
__emit cmps 0x80000000;
#else // cellbits == 64
emit cmps 0x8000000000000000;
__emit cmps 0x8000000000000000;
#endif
}

Expand Down
78 changes: 39 additions & 39 deletions source/compiler/tests/__emit_p2.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,42 @@ stock test__shift(&local_refvar, local_refarray[])
local_label:

// ok
emit shl.c.pri global_const;
emit shl.c.pri local_const;
emit shl.c.pri 0;
emit shl.c.pri 1;
emit shl.c.pri 15;
emit shl.c.pri (cellbits / charbits);
__emit shl.c.pri global_const;
__emit shl.c.pri local_const;
__emit shl.c.pri 0;
__emit shl.c.pri 1;
__emit shl.c.pri 15;
__emit shl.c.pri (cellbits / charbits);
#if cellbits == 16
emit shl.c.pri 15;
emit shl.c.pri 0xF;
__emit shl.c.pri 15;
__emit shl.c.pri 0xF;
#elseif cellbits == 32
emit shl.c.pri 31;
emit shl.c.pri 0x1F;
__emit shl.c.pri 31;
__emit shl.c.pri 0x1F;
#else // cellbits == 64
emit shl.c.pri 63;
emit shl.c.pri 0x3F;
__emit shl.c.pri 63;
__emit shl.c.pri 0x3F;
#endif

// should trigger an error
emit shl.c.pri global_var;
emit shl.c.pri global_func;
emit shl.c.pri local_refvar;
emit shl.c.pri local_refarray;
emit shl.c.pri local_var;
emit shl.c.pri local_static_var;
emit shl.c.pri local_label;
emit shl.c.pri -1;
emit shl.c.pri -0x1;
__emit shl.c.pri global_var;
__emit shl.c.pri global_func;
__emit shl.c.pri local_refvar;
__emit shl.c.pri local_refarray;
__emit shl.c.pri local_var;
__emit shl.c.pri local_static_var;
__emit shl.c.pri local_label;
__emit shl.c.pri -1;
__emit shl.c.pri -0x1;
#if cellbits == 16
emit shl.c.pri 16;
emit shl.c.pri 0x10;
__emit shl.c.pri 16;
__emit shl.c.pri 0x10;
#elseif cellbits == 32
emit shl.c.pri 32;
emit shl.c.pri 0x20;
__emit shl.c.pri 32;
__emit shl.c.pri 0x20;
#else // cellbits == 64
emit shl.c.pri 64;
emit shl.c.pri 0x40;
__emit shl.c.pri 64;
__emit shl.c.pri 0x40;
#endif
}

Expand All @@ -56,21 +56,21 @@ stock test__label(&local_refvar, local_refarray[])
local_label:

// ok
emit jump local_label;
emit jump local_label2;
emit jump :local_label2;
__emit jump local_label;
__emit jump local_label2;
__emit jump :local_label2;
local_label2:

// should trigger an error
emit jump global_const;
emit jump global_var;
emit jump global_func;
emit jump local_refvar;
emit jump local_refarray;
emit jump local_const;
emit jump local_var;
emit jump local_static_var;
emit jump 0;
__emit jump global_const;
__emit jump global_var;
__emit jump global_func;
__emit jump local_refvar;
__emit jump local_refarray;
__emit jump local_const;
__emit jump local_var;
__emit jump local_static_var;
__emit jump 0;
}


Expand Down
Loading

0 comments on commit e89d8fe

Please sign in to comment.