Added IntPtrOp alias

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6929 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2017-10-13 21:23:33 +00:00
parent 97898cc03b
commit 34e9873d5f
10 changed files with 59 additions and 24 deletions

View file

@ -318,6 +318,7 @@ class CEXEBuild {
#else
void ps_addtoline(const TCHAR *str, GrowBuf &linedata, StringList &hist);
#endif
int doParse(int verbosity, const TCHAR *fmt, ...);
int doParse(const TCHAR *str);
int doCommand(int which_token, LineParser &line);
TCHAR m_templinebuf[MAX_LINELENGTH]; // Buffer used by parseScript() & doCommand(), not recursion safe!

View file

@ -702,7 +702,7 @@ static int NSISCALL ExecuteEntry(entry *entry_)
{
int v,v2;
TCHAR *p=var0;
v=GetIntFromParm(1); // BUGBUG64: TODO: These should be INT_PTR, the script might be playing with pointers and System::Call
v=GetIntFromParm(1);
v2=GetIntFromParm(2);
switch (parm3)
{
@ -728,7 +728,7 @@ static int NSISCALL ExecuteEntry(entry *entry_)
TCHAR *buf0=GetStringFromParm(0x01);
wsprintf(var0,
buf0,
GetIntPtrFromParm(2));
GetIntPtrFromParm(2)); // TODO: BUGBUG64: This sign-extends from INT32 to INT64, do we want that?
}
break;
#endif//NSIS_SUPPORT_INTOPTS

View file

@ -161,6 +161,20 @@ int CEXEBuild::num_ifblock()
return build_preprocessor_data.getlen() / sizeof(ifblock);
}
int CEXEBuild::doParse(int verbosity, const TCHAR *fmt, ...)
{
ExpandoString<TCHAR, NSIS_MAX_STRLEN> buf;
int orgv = get_verbosity(), res;
va_list val;
va_start(val, fmt);
buf.StrVFmt(fmt, val);
va_end(val);
if (verbosity >= 0) set_verbosity(verbosity);
res = doParse(buf.GetPtr());
set_verbosity(orgv);
return res;
}
int CEXEBuild::doParse(const TCHAR *str)
{
LineParser line(inside_comment);
@ -4122,17 +4136,30 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
return PS_ERROR;
#endif //~ NSIS_SUPPORT_GETFILETIME
#ifdef NSIS_SUPPORT_INTOPTS
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~\0"));
if (ent.offsets[0] < 0 || ent.offsets[3] < 0 ||
((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] != 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));
case TOK_INTOP: case TOK_INTPTROP:
{
const TCHAR *val1=line.gettoken_str(2), *opstr=0, *val2=0, *cmdname=get_commandtoken_name(which_token);
int t64 = is_target_64bit(), res;
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~\0"));
if (ent.offsets[0] < 0 || ent.offsets[3] < 0 || ((ent.offsets[3] == 7 || ent.offsets[3] == 14) && line.getnumtokens() > 4))
PRINTHELP()
if (ent.offsets[3] != 7 && ent.offsets[3] != 14) val2=line.gettoken_str(4);
if (ent.offsets[3] == 14) val2=t64?_T("0xFFFFFFFFFFFFFFFF"):_T("0xFFFFFFFF"), ent.offsets[3]=6, opstr = _T("^"); // ~ using ^
if (TOK_INTPTROP == which_token && t64)
{
res = doParse(2, _T("System::Int64Op %") NPRIs _T(" %") NPRIs _T(" %") NPRIs _T("\n"), val1, opstr ? opstr : line.gettoken_str(3), val2 ? val2 : _T(""));
if (res != PS_OK) return res;
ent.which=EW_PUSHPOP, ent.offsets[1]=1, ent.offsets[3]=0; // Pop $result
}
else
{
ent.offsets[1]=add_string(val1);
if (val2) ent.offsets[2]=add_string(val2);
}
SCRIPT_MSG(_T("%") NPRIs _T(": %") NPRIs _T("=%") NPRIs _T("%") NPRIs _T("%") NPRIs _T("\n"),cmdname,line.gettoken_str(1),line.gettoken_str(2),line.gettoken_str(3),line.gettoken_str(4));
}
return add_entry(&ent);
case TOK_INTFMT:
ent.which=EW_INTFMT;
@ -5010,7 +5037,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
// Call the DLL
tstring funcname = get_string_suffix(command, _T("::"));
SCRIPT_MSG(_T("Plugin Command: %") NPRIs,funcname.c_str());
SCRIPT_MSG(_T("Plugin command: %") NPRIs,funcname.c_str());
int i = 1;
int nounload = 0;

View file

@ -123,6 +123,7 @@ static tokenType tokenlist[TOK__LAST] =
{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_INTPTROP,_T("IntPtrOp"),3,1,_T("$(user_var: result) val1 OP [val2]"),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},

View file

@ -238,6 +238,7 @@ enum
TOK_GETFILETIMELOCAL,
TOK_STRLEN,
TOK_INTOP,
TOK_INTPTROP,
TOK_INTCMP,
TOK_INTCMPU,
TOK_INTFMT,