mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 06:15:37 +03:00
Added GNU GCC support, linux binary
This commit is contained in:
parent
bd11b5eb90
commit
2a1ee3fd37
14
compiler/scasm/Makefile
Executable file
14
compiler/scasm/Makefile
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
CPPFILES = amxasm.cpp cexpr.cpp amx_symbol.cpp amx_proc.cpp \
|
||||||
|
amx_parser.cpp amx_natives.cpp amx_macro.cpp amx_label.cpp \
|
||||||
|
amx_error.cpp amx_define.cpp amx_data.cpp amx_compiler.cpp
|
||||||
|
|
||||||
|
FLAGS = -march=i386
|
||||||
|
|
||||||
|
all: sasm
|
||||||
|
|
||||||
|
sasm:
|
||||||
|
g++ $(FLAGS) -Wall $(CPPFILES) -o sasm -s
|
||||||
|
|
||||||
|
clean:
|
||||||
|
-rm *.o
|
||||||
|
-rm sasm
|
@ -43,7 +43,7 @@
|
|||||||
typedef int int32_t;
|
typedef int int32_t;
|
||||||
typedef unsigned int uint32_t;
|
typedef unsigned int uint32_t;
|
||||||
#else
|
#else
|
||||||
typedef long int int32_t;
|
//typedef long int int32_t;
|
||||||
typedef unsigned long int uint32_t;
|
typedef unsigned long int uint32_t;
|
||||||
#endif
|
#endif
|
||||||
#if defined __WIN32__ || defined _WIN32 || defined WIN32
|
#if defined __WIN32__ || defined _WIN32 || defined WIN32
|
||||||
|
@ -199,13 +199,12 @@ bool Compiler::Compile(std::string &out)
|
|||||||
dat = cod + CipCount();
|
dat = cod + CipCount();
|
||||||
hea = dat + DAT->GetSize();
|
hea = dat + DAT->GetSize();
|
||||||
stp = hea + stacksize;
|
stp = hea + stacksize;
|
||||||
int16_t cipHdr = 0x00;
|
|
||||||
cip = -1;
|
cip = -1;
|
||||||
fileSize = hea;
|
fileSize = hea;
|
||||||
|
|
||||||
std::string amxname;
|
std::string amxname;
|
||||||
amxname.assign(out);
|
amxname.assign(out);
|
||||||
int pos = (int)amxname.find(".asm");
|
size_t pos = amxname.find(".asm");
|
||||||
if (pos != std::string::npos)
|
if (pos != std::string::npos)
|
||||||
{
|
{
|
||||||
amxname.replace(pos, 4, ".amx");
|
amxname.replace(pos, 4, ".amx");
|
||||||
@ -264,8 +263,6 @@ bool Compiler::Compile(std::string &out)
|
|||||||
fwrite(s, sizeof(char), strlen(s)+1, fp);
|
fwrite(s, sizeof(char), strlen(s)+1, fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
//fwrite((void*)&cipHdr, sizeof(int16_t), 1, fp);
|
|
||||||
|
|
||||||
/* Write the code */
|
/* Write the code */
|
||||||
|
|
||||||
std::vector<Asm *>::iterator ci;
|
std::vector<Asm *>::iterator ci;
|
||||||
@ -662,7 +659,7 @@ bool Compiler::Parse()
|
|||||||
if (params.size() > 0)
|
if (params.size() > 0)
|
||||||
{
|
{
|
||||||
FindArguments(params, paramList, argPos, true);
|
FindArguments(params, paramList, argPos, true);
|
||||||
if (argPos != params.size()-1)
|
if (argPos != (int)(params.size()-1))
|
||||||
{
|
{
|
||||||
CError->ErrorMsg(Err_Unexpected_Char, params[argPos]);
|
CError->ErrorMsg(Err_Unexpected_Char, params[argPos]);
|
||||||
continue;
|
continue;
|
||||||
@ -1723,7 +1720,6 @@ int Compiler::FindArguments(std::string &text, std::vector<std::string*> &List,
|
|||||||
char c = 0, d = 0, l = 0, size = 0;
|
char c = 0, d = 0, l = 0, size = 0;
|
||||||
std::stack<char> Stack;
|
std::stack<char> Stack;
|
||||||
end = -1;
|
end = -1;
|
||||||
bool temp = false;
|
|
||||||
|
|
||||||
for (i=0; i<text.size(); i++)
|
for (i=0; i<text.size(); i++)
|
||||||
{
|
{
|
||||||
@ -1896,7 +1892,6 @@ int Compiler::Eval(std::string &str, SymbolType sym)
|
|||||||
{
|
{
|
||||||
std::stack<rpn *> Stack;
|
std::stack<rpn *> Stack;
|
||||||
std::string bpstr;
|
std::string bpstr;
|
||||||
int litidx = 0;
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
rpn *r = new rpn;
|
rpn *r = new rpn;
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
@ -2036,7 +2031,6 @@ int Compiler::Eval(std::string &str, SymbolType sym)
|
|||||||
CExpr Compiler::EvalRpn(rpn *r, SymbolType sym)
|
CExpr Compiler::EvalRpn(rpn *r, SymbolType sym)
|
||||||
{
|
{
|
||||||
int i = 0, j = 0;
|
int i = 0, j = 0;
|
||||||
char c = 0;
|
|
||||||
CExpr er, el;
|
CExpr er, el;
|
||||||
std::vector<CExpr>::iterator Q;
|
std::vector<CExpr>::iterator Q;
|
||||||
std::vector<char>::iterator R;
|
std::vector<char>::iterator R;
|
||||||
@ -2205,4 +2199,4 @@ rpn::~rpn()
|
|||||||
{
|
{
|
||||||
// ops.clear();
|
// ops.clear();
|
||||||
// vals.clear();
|
// vals.clear();
|
||||||
}
|
}
|
||||||
|
@ -126,4 +126,5 @@ void DataMngr::GetData(std::vector<DataMngr::Datum *> &dList)
|
|||||||
{
|
{
|
||||||
dList.push_back( (*i) );
|
dList.push_back( (*i) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,4 +86,5 @@ void DefineMngr::SearchAndReplace(std::string &text)
|
|||||||
i = List.begin();
|
i = List.begin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,4 +193,5 @@ bool ErrorMngr::IsSymbol(std::string &str)
|
|||||||
void ErrorMngr::SetLine(int ln)
|
void ErrorMngr::SetLine(int ln)
|
||||||
{
|
{
|
||||||
line = ln;
|
line = ln;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ void LabelMngr::CompleteQueue(bool isLocal)
|
|||||||
while (!stk->empty())
|
while (!stk->empty())
|
||||||
{
|
{
|
||||||
CError->SetLine(stk->top()->line);
|
CError->SetLine(stk->top()->line);
|
||||||
CError->ErrorMsg(Err_Bad_Lbel);
|
CError->ErrorMsg(Err_Bad_Label);
|
||||||
stk->pop();
|
stk->pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -154,4 +154,5 @@ bool LabelMngr::EraseLabel(std::string &sym)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ std::string *MacroList::BeginReplacement(MacroList::Macro *macro)
|
|||||||
|
|
||||||
int MacroList::ReplaceArgument(MacroList::Macro *m, std::string *macro, std::string &arg, int pos = 0)
|
int MacroList::ReplaceArgument(MacroList::Macro *m, std::string *macro, std::string &arg, int pos = 0)
|
||||||
{
|
{
|
||||||
int i = 0, bPos = 0;
|
int bPos = 0;
|
||||||
|
|
||||||
bPos = FindSymbol(*macro, *(*m->arg), pos);
|
bPos = FindSymbol(*macro, *(*m->arg), pos);
|
||||||
|
|
||||||
@ -169,4 +169,5 @@ void MacroList::SearchAndReplace(std::string &text)
|
|||||||
i = List.begin();
|
i = List.begin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,4 +37,5 @@ public:
|
|||||||
int32_t offset;
|
int32_t offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //_INCLUDE_NAMETABLE_H
|
#endif //_INCLUDE_NAMETABLE_H
|
||||||
|
|
||||||
|
@ -90,4 +90,5 @@ void NativeMngr::GetNatives(std::vector<NativeMngr::Native *> &nList)
|
|||||||
{
|
{
|
||||||
nList.push_back( (*i) );
|
nList.push_back( (*i) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,6 @@ void StripComments(std::string &text)
|
|||||||
void StringBreak(std::string &Source, std::string &Left, std::string &Right)
|
void StringBreak(std::string &Source, std::string &Left, std::string &Right)
|
||||||
{
|
{
|
||||||
int done_flag = 0;
|
int done_flag = 0;
|
||||||
int l=0;
|
|
||||||
unsigned int i=0;
|
unsigned int i=0;
|
||||||
|
|
||||||
Left.clear();
|
Left.clear();
|
||||||
|
@ -103,4 +103,5 @@ int ProcMngr::GetCip(std::string &sym)
|
|||||||
return ncip;
|
return ncip;
|
||||||
|
|
||||||
return p->ASM->cip;
|
return p->ASM->cip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,6 @@ void get_options(int argc, char **argv, Compiler &Prog)
|
|||||||
int i = 0; /* index */
|
int i = 0; /* index */
|
||||||
char opt_flag = 0; /* flag for option detection */
|
char opt_flag = 0; /* flag for option detection */
|
||||||
char *option = 0; /* option pointer */
|
char *option = 0; /* option pointer */
|
||||||
char c = 0; /* option marker */
|
|
||||||
for (i=1; i<argc; i++)
|
for (i=1; i<argc; i++)
|
||||||
{
|
{
|
||||||
if (argv[i][0] == '-')
|
if (argv[i][0] == '-')
|
||||||
@ -122,4 +121,4 @@ void print_options()
|
|||||||
printf("\t-v\t\t- Output version and exit\n");
|
printf("\t-v\t\t- Output version and exit\n");
|
||||||
printf("\t-o\t\t- Specify file to write\n");
|
printf("\t-o\t\t- Specify file to write\n");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
@ -223,8 +223,8 @@ int CExpr::Analyze()
|
|||||||
|
|
||||||
cExprType CExpr::Evaluate(int symNum)
|
cExprType CExpr::Evaluate(int symNum)
|
||||||
{
|
{
|
||||||
size_t i = 0, blk = 0;
|
size_t i = 0;
|
||||||
char litc = 0, c = 0, csave = 0;
|
char litc = 0, c = 0;
|
||||||
cExprType t = Val_None;
|
cExprType t = Val_None;
|
||||||
std::string num;
|
std::string num;
|
||||||
|
|
||||||
@ -531,4 +531,4 @@ void CExpr::Update()
|
|||||||
sprintf(buf, "%d", numVal);
|
sprintf(buf, "%d", numVal);
|
||||||
data.assign(buf);
|
data.assign(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BIN
compiler/scasm/sasm
Executable file
BIN
compiler/scasm/sasm
Executable file
Binary file not shown.
Loading…
Reference in New Issue
Block a user