Added IntOp and System::Int64Op >>> SHR operator

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6926 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2017-10-08 15:26:54 +00:00
parent b97de6887d
commit 99235da725
9 changed files with 25 additions and 15 deletions

View file

@ -719,6 +719,7 @@ static int NSISCALL ExecuteEntry(entry *entry_)
case 10: if (v2) v%=v2; else { v=0; exec_error++; } break;
case 11: v=v<<v2; break;
case 12: v=v>>v2; break;
case 13: v=(unsigned int)v>>(unsigned int)v2; break;
}
myitoa(p,v);
}

View file

@ -97,7 +97,7 @@ enum
#endif
#ifdef NSIS_SUPPORT_INTOPTS
EW_INTCMP, // IntCmp: 6 [val1, val2, equal, val1<val2, val1>val2, unsigned?]
EW_INTOP, // IntOp: 4 [output, input1, input2, op] where op: 0=add, 1=sub, 2=mul, 3=div, 4=bor, 5=band, 6=bxor, 7=bnot input1, 8=lnot input1, 9=lor, 10=land], 11=1%2
EW_INTOP, // IntOp: 4 [output, input1, input2, op] where op: 0=add, 1=sub, 2=mul, 3=div, 4=bor, 5=band, 6=bxor, 7=bnot input1, 8=lor, 9=land 10=mod, 11=shl, 12=sar, 13=shr (bneg is implemented with bxor in compiler)
EW_INTFMT, // IntFmt: [output, format, input]
#endif
#ifdef NSIS_SUPPORT_STACK

View file

@ -4125,16 +4125,13 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
case TOK_INTOP:
ent.which=EW_INTOP;
ent.offsets[0]=GetUserVarIndex(line, 1);
ent.offsets[3]=line.gettoken_enum(3,_T("+\0-\0*\0/\0|\0&\0^\0!\0||\0&&\0%\0<<\0>>\0~\0"));
ent.offsets[3]=line.gettoken_enum(3,_T("+\0-\0*\0/\0|\0&\0^\0!\0||\0&&\0%\0<<\0>>\0>>>\0~\0"));
if (ent.offsets[0] < 0 || ent.offsets[3] < 0 ||
((ent.offsets[3] == 7 || ent.offsets[3] == 13) && line.getnumtokens() > 4))
((ent.offsets[3] == 7 || ent.offsets[3] == 14) && line.getnumtokens() > 4))
PRINTHELP()
ent.offsets[1]=add_string(line.gettoken_str(2));
if (ent.offsets[3] != 7 && ent.offsets[3] != 13) ent.offsets[2]=add_string(line.gettoken_str(4));
if (ent.offsets[3] == 13) {
ent.offsets[3]=6;
ent.offsets[2]=add_asciistring(_T("0xFFFFFFFF"));
}
if (ent.offsets[3] != 7 && ent.offsets[3] != 14) ent.offsets[2]=add_string(line.gettoken_str(4));
if (ent.offsets[3] == 14) ent.offsets[2]=add_asciistring(_T("0xFFFFFFFF")), ent.offsets[3]=6; // ~ using ^
SCRIPT_MSG(_T("IntOp: %") NPRIs _T("=%") NPRIs _T("%") NPRIs _T("%") NPRIs _T("\n"),line.gettoken_str(1),line.gettoken_str(2),line.gettoken_str(3),line.gettoken_str(4));
return add_entry(&ent);
case TOK_INTFMT:

View file

@ -122,7 +122,7 @@ static tokenType tokenlist[TOK__LAST] =
{TOK_INSTDIR,_T("InstallDir"),1,0,_T("default_install_directory"),TP_GLOBAL},
{TOK_INSTPROGRESSFLAGS,_T("InstProgressFlags"),0,-1,_T("[flag [...]]\n flag={smooth|colored}"),TP_GLOBAL},
{TOK_INSTTYPE,_T("InstType"),1,0,_T("[un.]install_type_name | /NOCUSTOM | /CUSTOMSTRING=str | /COMPONENTSONLYONCUSTOM"),TP_GLOBAL},
{TOK_INTOP,_T("IntOp"),3,1,_T("$(user_var: result) val1 OP [val2]\n OP=(+ - * / % | & ^ ~ ! || && << >>)"),TP_CODE},
{TOK_INTOP,_T("IntOp"),3,1,_T("$(user_var: result) val1 OP [val2]\n OP=(+ - * / % | & ^ ~ ! || && << >> >>>)"),TP_CODE},
{TOK_INTCMP,_T("IntCmp"),3,2,_T("val1 val2 jump_if_equal [jump_if_val1_less] [jump_if_val1_more]"),TP_CODE},
{TOK_INTCMPU,_T("IntCmpU"),3,2,_T("val1 val2 jump_if_equal [jump_if_val1_less] [jump_if_val1_more]"),TP_CODE},
{TOK_INTFMT,_T("IntFmt"),3,0,_T("$(user_var: output) format_string input"),TP_CODE},