[DEV] coding review ...
This commit is contained in:
parent
177d1ba8c0
commit
209d18ed08
@ -22,8 +22,8 @@ static int LittleEndian = 0;
|
||||
/* global initialisation for libraries */
|
||||
void LibraryInit() {
|
||||
/* define the version number macro */
|
||||
VersionString = TableStrRegister(PICOC_VERSION);
|
||||
VariableDefinePlatformVar(NULL, "PICOC_VERSION", CharPtrType, (union AnyValue *)&VersionString, FALSE);
|
||||
VersionString = TableStrRegister(ECI_VERSION);
|
||||
VariableDefinePlatformVar(NULL, "ECI_VERSION", CharPtrType, (union AnyValue *)&VersionString, FALSE);
|
||||
/* define endian-ness macros */
|
||||
BigEndian = ((*(char*)&__ENDIAN_CHECK__) == 0);
|
||||
LittleEndian = ((*(char*)&__ENDIAN_CHECK__) == 1);
|
||||
@ -32,7 +32,7 @@ void LibraryInit() {
|
||||
}
|
||||
|
||||
/* add a library */
|
||||
void LibraryAdd(struct Table *GlobalTable, const char *LibraryName, struct LibraryFunction *FuncList) {
|
||||
void LibraryAdd(struct Table *_globalTable, const char *_libraryName, struct LibraryFunction *_funcList) {
|
||||
struct ParseState Parser;
|
||||
int Count;
|
||||
char *Identifier;
|
||||
@ -41,83 +41,83 @@ void LibraryAdd(struct Table *GlobalTable, const char *LibraryName, struct Libra
|
||||
void *Tokens;
|
||||
const char *IntrinsicName = TableStrRegister("c library");
|
||||
/* read all the library definitions */
|
||||
for (Count = 0; FuncList[Count].Prototype != NULL; Count++) {
|
||||
Tokens = LexAnalyse(IntrinsicName, FuncList[Count].Prototype, strlen((char *)FuncList[Count].Prototype), NULL);
|
||||
LexInitParser(&Parser, FuncList[Count].Prototype, Tokens, IntrinsicName, TRUE);
|
||||
for (Count = 0; _funcList[Count].Prototype != NULL; Count++) {
|
||||
Tokens = LexAnalyse(IntrinsicName, _funcList[Count].Prototype, strlen((char *)_funcList[Count].Prototype), NULL);
|
||||
LexInitParser(&Parser, _funcList[Count].Prototype, Tokens, IntrinsicName, TRUE);
|
||||
TypeParse(&Parser, &ReturnType, &Identifier, NULL);
|
||||
NewValue = ParseFunctionDefinition(&Parser, ReturnType, Identifier);
|
||||
NewValue->Val->FuncDef.Intrinsic = FuncList[Count].Func;
|
||||
NewValue->Val->FuncDef.Intrinsic = _funcList[Count].Func;
|
||||
HeapFreeMem(Tokens);
|
||||
}
|
||||
}
|
||||
|
||||
/* print a type to a stream without using printf/sprintf */
|
||||
void PrintType(struct ValueType *Typ, IOFILE *Stream) {
|
||||
switch (Typ->Base) {
|
||||
void PrintType(struct ValueType* _type, IOFILE *_stream) {
|
||||
switch (_type->Base) {
|
||||
case TypeVoid:
|
||||
PrintStr("void", Stream);
|
||||
PrintStr("void", _stream);
|
||||
break;
|
||||
case TypeInt:
|
||||
PrintStr("int", Stream);
|
||||
PrintStr("int", _stream);
|
||||
break;
|
||||
case TypeShort:
|
||||
PrintStr("short", Stream);
|
||||
PrintStr("short", _stream);
|
||||
break;
|
||||
case TypeChar:
|
||||
PrintStr("char", Stream);
|
||||
PrintStr("char", _stream);
|
||||
break;
|
||||
case TypeLong:
|
||||
PrintStr("long", Stream);
|
||||
PrintStr("long", _stream);
|
||||
break;
|
||||
case TypeUnsignedInt:
|
||||
PrintStr("unsigned int", Stream);
|
||||
PrintStr("unsigned int", _stream);
|
||||
break;
|
||||
case TypeUnsignedShort:
|
||||
PrintStr("unsigned short", Stream);
|
||||
PrintStr("unsigned short", _stream);
|
||||
break;
|
||||
case TypeUnsignedLong:
|
||||
PrintStr("unsigned long", Stream);
|
||||
PrintStr("unsigned long", _stream);
|
||||
break;
|
||||
case TypeFP:
|
||||
PrintStr("double", Stream);
|
||||
PrintStr("double", _stream);
|
||||
break;
|
||||
case TypeFunction:
|
||||
PrintStr("function", Stream);
|
||||
PrintStr("function", _stream);
|
||||
break;
|
||||
case TypeMacro:
|
||||
PrintStr("macro", Stream);
|
||||
PrintStr("macro", _stream);
|
||||
break;
|
||||
case TypePointer:
|
||||
if (Typ->FromType) {
|
||||
PrintType(Typ->FromType, Stream);
|
||||
if (_type->FromType) {
|
||||
PrintType(_type->FromType, _stream);
|
||||
}
|
||||
PrintCh('*', Stream);
|
||||
PrintCh('*', _stream);
|
||||
break;
|
||||
case TypeArray:
|
||||
PrintType(Typ->FromType, Stream);
|
||||
PrintCh('[', Stream);
|
||||
if (Typ->ArraySize != 0) {
|
||||
PrintSimpleInt(Typ->ArraySize, Stream);
|
||||
PrintType(_type->FromType, _stream);
|
||||
PrintCh('[', _stream);
|
||||
if (_type->ArraySize != 0) {
|
||||
PrintSimpleInt(_type->ArraySize, _stream);
|
||||
}
|
||||
PrintCh(']', Stream);
|
||||
PrintCh(']', _stream);
|
||||
break;
|
||||
case TypeStruct:
|
||||
PrintStr("struct ", Stream);
|
||||
PrintStr(Typ->Identifier, Stream);
|
||||
PrintStr("struct ", _stream);
|
||||
PrintStr(_type->Identifier, _stream);
|
||||
break;
|
||||
case TypeUnion:
|
||||
PrintStr("union ", Stream);
|
||||
PrintStr(Typ->Identifier, Stream);
|
||||
PrintStr("union ", _stream);
|
||||
PrintStr(_type->Identifier, _stream);
|
||||
break;
|
||||
case TypeEnum:
|
||||
PrintStr("enum ", Stream);
|
||||
PrintStr(Typ->Identifier, Stream);
|
||||
PrintStr("enum ", _stream);
|
||||
PrintStr(_type->Identifier, _stream);
|
||||
break;
|
||||
case TypeGotoLabel:
|
||||
PrintStr("goto label ", Stream);
|
||||
PrintStr("goto label ", _stream);
|
||||
break;
|
||||
case Type_Type:
|
||||
PrintStr("type ", Stream);
|
||||
PrintStr("type ", _stream);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
20
eci/clibrary.h
Normal file
20
eci/clibrary.h
Normal file
@ -0,0 +1,20 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ECI_C_LIBRARY_H__
|
||||
#define __ECI_C_LIBRARY_H__
|
||||
|
||||
|
||||
|
||||
void LibraryInit();
|
||||
void LibraryAdd(struct Table* _globalTable, const char* _libraryName, struct LibraryFunction* _funcList);
|
||||
void CLibraryInit();
|
||||
void PrintType(struct ValueType* _type, IOFILE* _stream);
|
||||
|
||||
|
||||
#endif
|
@ -12,69 +12,69 @@
|
||||
|
||||
#ifndef BUILTIN_MINI_STDLIB
|
||||
|
||||
void StdIsalnum(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = isalnum(Param[0]->Val->Integer);
|
||||
void StdIsalnum(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = isalnum(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdIsalpha(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = isalpha(Param[0]->Val->Integer);
|
||||
void StdIsalpha(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = isalpha(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdIsblank(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
int ch = Param[0]->Val->Integer;
|
||||
ReturnValue->Val->Integer = (ch == ' ') | (ch == '\t');
|
||||
void StdIsblank(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
int ch = _param[0]->Val->Integer;
|
||||
_returnValue->Val->Integer = (ch == ' ') | (ch == '\t');
|
||||
}
|
||||
|
||||
void StdIscntrl(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = iscntrl(Param[0]->Val->Integer);
|
||||
void StdIscntrl(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = iscntrl(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdIsdigit(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = isdigit(Param[0]->Val->Integer);
|
||||
void StdIsdigit(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = isdigit(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdIsgraph(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = isgraph(Param[0]->Val->Integer);
|
||||
void StdIsgraph(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = isgraph(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdIslower(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = islower(Param[0]->Val->Integer);
|
||||
void StdIslower(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = islower(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdIsprint(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = isprint(Param[0]->Val->Integer);
|
||||
void StdIsprint(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = isprint(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdIspunct(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = ispunct(Param[0]->Val->Integer);
|
||||
void StdIspunct(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = ispunct(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdIsspace(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = isspace(Param[0]->Val->Integer);
|
||||
void StdIsspace(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = isspace(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdIsupper(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = isupper(Param[0]->Val->Integer);
|
||||
void StdIsupper(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = isupper(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdIsxdigit(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = isxdigit(Param[0]->Val->Integer);
|
||||
void StdIsxdigit(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = isxdigit(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdTolower(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = tolower(Param[0]->Val->Integer);
|
||||
void StdTolower(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = tolower(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdToupper(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = toupper(Param[0]->Val->Integer);
|
||||
void StdToupper(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = toupper(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdIsascii(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = isascii(Param[0]->Val->Integer);
|
||||
void StdIsascii(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = isascii(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdToascii(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = toascii(Param[0]->Val->Integer);
|
||||
void StdToascii(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = toascii(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
/* all string.h functions */
|
||||
|
15
eci/cstdlib/ctype.h
Normal file
15
eci/cstdlib/ctype.h
Normal file
@ -0,0 +1,15 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ECI_C_TYPE_H__
|
||||
#define __ECI_C_TYPE_H__
|
||||
|
||||
|
||||
extern struct LibraryFunction StdCtypeFunctions[];
|
||||
|
||||
#endif
|
14
eci/cstdlib/errno.h
Normal file
14
eci/cstdlib/errno.h
Normal file
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ECI_ERRNO_H__
|
||||
#define __ECI_ERRNO_H__
|
||||
|
||||
void StdErrnoSetupFunc();
|
||||
|
||||
#endif
|
@ -26,98 +26,98 @@ static double M_SQRT2Value = 1.41421356237309504880; /* sqrt(2) */
|
||||
static double M_SQRT1_2Value = 0.70710678118654752440; /* 1/sqrt(2) */
|
||||
|
||||
|
||||
void MathSin(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->FP = sin(Param[0]->Val->FP);
|
||||
void MathSin(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->FP = sin(_param[0]->Val->FP);
|
||||
}
|
||||
|
||||
void MathCos(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs){
|
||||
ReturnValue->Val->FP = cos(Param[0]->Val->FP);
|
||||
void MathCos(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs){
|
||||
_returnValue->Val->FP = cos(_param[0]->Val->FP);
|
||||
}
|
||||
|
||||
void MathTan(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->FP = tan(Param[0]->Val->FP);
|
||||
void MathTan(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->FP = tan(_param[0]->Val->FP);
|
||||
}
|
||||
|
||||
void MathAsin(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->FP = asin(Param[0]->Val->FP);
|
||||
void MathAsin(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->FP = asin(_param[0]->Val->FP);
|
||||
}
|
||||
|
||||
void MathAcos(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->FP = acos(Param[0]->Val->FP);
|
||||
void MathAcos(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->FP = acos(_param[0]->Val->FP);
|
||||
}
|
||||
|
||||
void MathAtan(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->FP = atan(Param[0]->Val->FP);
|
||||
void MathAtan(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->FP = atan(_param[0]->Val->FP);
|
||||
}
|
||||
|
||||
void MathAtan2(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->FP = atan2(Param[0]->Val->FP, Param[1]->Val->FP);
|
||||
void MathAtan2(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->FP = atan2(_param[0]->Val->FP, _param[1]->Val->FP);
|
||||
}
|
||||
|
||||
void MathSinh(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->FP = sinh(Param[0]->Val->FP);
|
||||
void MathSinh(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->FP = sinh(_param[0]->Val->FP);
|
||||
}
|
||||
|
||||
void MathCosh(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->FP = cosh(Param[0]->Val->FP);
|
||||
void MathCosh(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->FP = cosh(_param[0]->Val->FP);
|
||||
}
|
||||
|
||||
void MathTanh(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->FP = tanh(Param[0]->Val->FP);
|
||||
void MathTanh(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->FP = tanh(_param[0]->Val->FP);
|
||||
}
|
||||
|
||||
void MathExp(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->FP = exp(Param[0]->Val->FP);
|
||||
void MathExp(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->FP = exp(_param[0]->Val->FP);
|
||||
}
|
||||
|
||||
void MathFabs(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->FP = fabs(Param[0]->Val->FP);
|
||||
void MathFabs(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->FP = fabs(_param[0]->Val->FP);
|
||||
}
|
||||
|
||||
void MathFmod(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->FP = fmod(Param[0]->Val->FP, Param[1]->Val->FP);
|
||||
void MathFmod(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->FP = fmod(_param[0]->Val->FP, _param[1]->Val->FP);
|
||||
}
|
||||
|
||||
void MathFrexp(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->FP = frexp(Param[0]->Val->FP, Param[1]->Val->Pointer);
|
||||
void MathFrexp(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->FP = frexp(_param[0]->Val->FP, _param[1]->Val->Pointer);
|
||||
}
|
||||
|
||||
void MathLdexp(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->FP = ldexp(Param[0]->Val->FP, Param[1]->Val->Integer);
|
||||
void MathLdexp(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->FP = ldexp(_param[0]->Val->FP, _param[1]->Val->Integer);
|
||||
}
|
||||
|
||||
void MathLog(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->FP = log(Param[0]->Val->FP);
|
||||
void MathLog(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->FP = log(_param[0]->Val->FP);
|
||||
}
|
||||
|
||||
void MathLog10(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->FP = log10(Param[0]->Val->FP);
|
||||
void MathLog10(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->FP = log10(_param[0]->Val->FP);
|
||||
}
|
||||
|
||||
void MathModf(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->FP = modf(Param[0]->Val->FP, Param[0]->Val->Pointer);
|
||||
void MathModf(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->FP = modf(_param[0]->Val->FP, _param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void MathPow(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->FP = pow(Param[0]->Val->FP, Param[1]->Val->FP);
|
||||
void MathPow(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->FP = pow(_param[0]->Val->FP, _param[1]->Val->FP);
|
||||
}
|
||||
|
||||
void MathSqrt(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->FP = sqrt(Param[0]->Val->FP);
|
||||
void MathSqrt(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->FP = sqrt(_param[0]->Val->FP);
|
||||
}
|
||||
|
||||
void MathRound(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
void MathRound(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
/* this awkward definition of "round()" due to it being inconsistently
|
||||
* declared in math.h */
|
||||
ReturnValue->Val->FP = ceil(Param[0]->Val->FP - 0.5);
|
||||
_returnValue->Val->FP = ceil(_param[0]->Val->FP - 0.5);
|
||||
}
|
||||
|
||||
void MathCeil(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->FP = ceil(Param[0]->Val->FP);
|
||||
void MathCeil(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->FP = ceil(_param[0]->Val->FP);
|
||||
}
|
||||
|
||||
void MathFloor(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->FP = floor(Param[0]->Val->FP);
|
||||
void MathFloor(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->FP = floor(_param[0]->Val->FP);
|
||||
}
|
||||
|
||||
/* all math.h functions */
|
||||
|
16
eci/cstdlib/math.h
Normal file
16
eci/cstdlib/math.h
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ECI_MATH_H__
|
||||
#define __ECI_MATH_H__
|
||||
|
||||
|
||||
extern struct LibraryFunction MathFunctions[];
|
||||
void MathSetupFunc();
|
||||
|
||||
#endif
|
16
eci/cstdlib/stdbool.h
Normal file
16
eci/cstdlib/stdbool.h
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ECI_STD_BOOL_H__
|
||||
#define __ECI_STD_BOOL_H__
|
||||
|
||||
|
||||
extern const char StdboolDefs[];
|
||||
void StdboolSetupFunc();
|
||||
|
||||
#endif
|
@ -47,8 +47,8 @@ typedef struct StdOutStreamStruct {
|
||||
|
||||
/* our representation of varargs within picoc */
|
||||
struct StdVararg {
|
||||
struct Value **Param;
|
||||
int NumArgs;
|
||||
struct Value **_param;
|
||||
int _numArgs;
|
||||
};
|
||||
|
||||
/* initialises the I/O system so error reporting works */
|
||||
@ -149,8 +149,8 @@ void StdioFprintfPointer(StdOutStream *Stream, const char *Format, void *Value)
|
||||
}
|
||||
|
||||
/* internal do-anything v[s][n]printf() formatting system with output to strings or FILE * */
|
||||
int StdioBasePrintf(struct ParseState *Parser, FILE *Stream, char *StrOut, int StrOutLen, char *Format, struct StdVararg *Args) {
|
||||
struct Value *ThisArg = Args->Param[0];
|
||||
int StdioBasePrintf(struct ParseState *_parser, FILE *Stream, char *StrOut, int StrOutLen, char *Format, struct StdVararg *Args) {
|
||||
struct Value *ThisArg = Args->_param[0];
|
||||
int ArgCount = 0;
|
||||
char *FPos = Format;
|
||||
char OneFormatBuf[MAX_FORMAT+1];
|
||||
@ -260,7 +260,7 @@ int StdioBasePrintf(struct ParseState *Parser, FILE *Stream, char *StrOut, int S
|
||||
} while ( ShowType == NULL
|
||||
&& OneFormatCount < MAX_FORMAT);
|
||||
if (ShowType != &VoidType) {
|
||||
if (ArgCount >= Args->NumArgs) {
|
||||
if (ArgCount >= Args->_numArgs) {
|
||||
StdioOutPuts("XXX", &SOStream);
|
||||
} else {
|
||||
/* null-terminate the buffer */
|
||||
@ -317,21 +317,21 @@ int StdioBasePrintf(struct ParseState *Parser, FILE *Stream, char *StrOut, int S
|
||||
}
|
||||
|
||||
/* internal do-anything v[s][n]scanf() formatting system with input from strings or FILE * */
|
||||
int StdioBaseScanf(struct ParseState *Parser, FILE *Stream, char *StrIn, char *Format, struct StdVararg *Args) {
|
||||
struct Value *ThisArg = Args->Param[0];
|
||||
int StdioBaseScanf(struct ParseState *_parser, FILE *Stream, char *StrIn, char *Format, struct StdVararg *Args) {
|
||||
struct Value *ThisArg = Args->_param[0];
|
||||
int ArgCount = 0;
|
||||
void *ScanfArg[MAX_SCANF_ARGS];
|
||||
if (Args->NumArgs > MAX_SCANF_ARGS) {
|
||||
ProgramFail(Parser, "too many arguments to scanf() - %d max", MAX_SCANF_ARGS);
|
||||
if (Args->_numArgs > MAX_SCANF_ARGS) {
|
||||
ProgramFail(_parser, "too many arguments to scanf() - %d max", MAX_SCANF_ARGS);
|
||||
}
|
||||
for (ArgCount = 0; ArgCount < Args->NumArgs; ++ArgCount) {
|
||||
for (ArgCount = 0; ArgCount < Args->_numArgs; ++ArgCount) {
|
||||
ThisArg = (struct Value *)((char *)ThisArg + MEM_ALIGN(sizeof(struct Value) + TypeStackSizeValue(ThisArg)));
|
||||
if (ThisArg->Typ->Base == TypePointer) {
|
||||
ScanfArg[ArgCount] = ThisArg->Val->Pointer;
|
||||
} else if (ThisArg->Typ->Base == TypeArray) {
|
||||
ScanfArg[ArgCount] = &ThisArg->Val->ArrayMem[0];
|
||||
} else {
|
||||
ProgramFail(Parser, "non-pointer argument to scanf() - argument %d after format", ArgCount+1);
|
||||
ProgramFail(_parser, "non-pointer argument to scanf() - argument %d after format", ArgCount+1);
|
||||
}
|
||||
}
|
||||
if (Stream != NULL) {
|
||||
@ -342,211 +342,211 @@ int StdioBaseScanf(struct ParseState *Parser, FILE *Stream, char *StrIn, char *F
|
||||
}
|
||||
|
||||
/* stdio calls */
|
||||
void StdioFopen(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = fopen(Param[0]->Val->Pointer, Param[1]->Val->Pointer);
|
||||
void StdioFopen(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = fopen(_param[0]->Val->Pointer, _param[1]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioFreopen(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = freopen(Param[0]->Val->Pointer, Param[1]->Val->Pointer, Param[2]->Val->Pointer);
|
||||
void StdioFreopen(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = freopen(_param[0]->Val->Pointer, _param[1]->Val->Pointer, _param[2]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioFclose(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = fclose(Param[0]->Val->Pointer);
|
||||
void StdioFclose(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = fclose(_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioFread(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = fread(Param[0]->Val->Pointer, Param[1]->Val->Integer, Param[2]->Val->Integer, Param[3]->Val->Pointer);
|
||||
void StdioFread(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = fread(_param[0]->Val->Pointer, _param[1]->Val->Integer, _param[2]->Val->Integer, _param[3]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioFwrite(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = fwrite(Param[0]->Val->Pointer, Param[1]->Val->Integer, Param[2]->Val->Integer, Param[3]->Val->Pointer);
|
||||
void StdioFwrite(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = fwrite(_param[0]->Val->Pointer, _param[1]->Val->Integer, _param[2]->Val->Integer, _param[3]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioFgetc(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = fgetc(Param[0]->Val->Pointer);
|
||||
void StdioFgetc(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = fgetc(_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioFgets(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = fgets(Param[0]->Val->Pointer, Param[1]->Val->Integer, Param[2]->Val->Pointer);
|
||||
void StdioFgets(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = fgets(_param[0]->Val->Pointer, _param[1]->Val->Integer, _param[2]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioRemove(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = remove(Param[0]->Val->Pointer);
|
||||
void StdioRemove(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = remove(_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioRename(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = rename(Param[0]->Val->Pointer, Param[1]->Val->Pointer);
|
||||
void StdioRename(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = rename(_param[0]->Val->Pointer, _param[1]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioRewind(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
rewind(Param[0]->Val->Pointer);
|
||||
void StdioRewind(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
rewind(_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioTmpfile(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = tmpfile();
|
||||
void StdioTmpfile(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = tmpfile();
|
||||
}
|
||||
|
||||
void StdioClearerr(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
clearerr((FILE *)Param[0]->Val->Pointer);
|
||||
void StdioClearerr(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
clearerr((FILE *)_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioFeof(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = feof((FILE *)Param[0]->Val->Pointer);
|
||||
void StdioFeof(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = feof((FILE *)_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioFerror(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = ferror((FILE *)Param[0]->Val->Pointer);
|
||||
void StdioFerror(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = ferror((FILE *)_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioFileno(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = fileno(Param[0]->Val->Pointer);
|
||||
void StdioFileno(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = fileno(_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioFflush(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = fflush(Param[0]->Val->Pointer);
|
||||
void StdioFflush(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = fflush(_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioFgetpos(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = fgetpos(Param[0]->Val->Pointer, Param[1]->Val->Pointer);
|
||||
void StdioFgetpos(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = fgetpos(_param[0]->Val->Pointer, _param[1]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioFsetpos(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = fsetpos(Param[0]->Val->Pointer, Param[1]->Val->Pointer);
|
||||
void StdioFsetpos(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = fsetpos(_param[0]->Val->Pointer, _param[1]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioFputc(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = fputc(Param[0]->Val->Integer, Param[1]->Val->Pointer);
|
||||
void StdioFputc(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = fputc(_param[0]->Val->Integer, _param[1]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioFputs(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = fputs(Param[0]->Val->Pointer, Param[1]->Val->Pointer);
|
||||
void StdioFputs(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = fputs(_param[0]->Val->Pointer, _param[1]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioFtell(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = ftell(Param[0]->Val->Pointer);
|
||||
void StdioFtell(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = ftell(_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioFseek(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = fseek(Param[0]->Val->Pointer, Param[1]->Val->Integer, Param[2]->Val->Integer);
|
||||
void StdioFseek(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = fseek(_param[0]->Val->Pointer, _param[1]->Val->Integer, _param[2]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdioPerror(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
perror(Param[0]->Val->Pointer);
|
||||
void StdioPerror(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
perror(_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioPutc(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = putc(Param[0]->Val->Integer, Param[1]->Val->Pointer);
|
||||
void StdioPutc(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = putc(_param[0]->Val->Integer, _param[1]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioPutchar(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = putchar(Param[0]->Val->Integer);
|
||||
void StdioPutchar(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = putchar(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdioSetbuf(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
setbuf(Param[0]->Val->Pointer, Param[1]->Val->Pointer);
|
||||
void StdioSetbuf(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
setbuf(_param[0]->Val->Pointer, _param[1]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioSetvbuf(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
setvbuf(Param[0]->Val->Pointer, Param[1]->Val->Pointer, Param[2]->Val->Integer, Param[3]->Val->Integer);
|
||||
void StdioSetvbuf(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
setvbuf(_param[0]->Val->Pointer, _param[1]->Val->Pointer, _param[2]->Val->Integer, _param[3]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdioUngetc(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = ungetc(Param[0]->Val->Integer, Param[1]->Val->Pointer);
|
||||
void StdioUngetc(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = ungetc(_param[0]->Val->Integer, _param[1]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioPuts(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = puts(Param[0]->Val->Pointer);
|
||||
void StdioPuts(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = puts(_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioGets(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = fgets(Param[0]->Val->Pointer, GETS_MAXValue, stdin);
|
||||
if (ReturnValue->Val->Pointer != NULL) {
|
||||
char *EOLPos = strchr(Param[0]->Val->Pointer, '\n');
|
||||
void StdioGets(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = fgets(_param[0]->Val->Pointer, GETS_MAXValue, stdin);
|
||||
if (_returnValue->Val->Pointer != NULL) {
|
||||
char *EOLPos = strchr(_param[0]->Val->Pointer, '\n');
|
||||
if (EOLPos != NULL) {
|
||||
*EOLPos = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StdioGetchar(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = getchar();
|
||||
void StdioGetchar(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = getchar();
|
||||
}
|
||||
|
||||
void StdioPrintf(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
void StdioPrintf(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
struct StdVararg PrintfArgs;
|
||||
PrintfArgs.Param = Param;
|
||||
PrintfArgs.NumArgs = NumArgs-1;
|
||||
ReturnValue->Val->Integer = StdioBasePrintf(Parser, stdout, NULL, 0, Param[0]->Val->Pointer, &PrintfArgs);
|
||||
PrintfArgs._param = _param;
|
||||
PrintfArgs._numArgs = _numArgs-1;
|
||||
_returnValue->Val->Integer = StdioBasePrintf(_parser, stdout, NULL, 0, _param[0]->Val->Pointer, &PrintfArgs);
|
||||
}
|
||||
|
||||
void StdioVprintf(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = StdioBasePrintf(Parser, stdout, NULL, 0, Param[0]->Val->Pointer, Param[1]->Val->Pointer);
|
||||
void StdioVprintf(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = StdioBasePrintf(_parser, stdout, NULL, 0, _param[0]->Val->Pointer, _param[1]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioFprintf(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
void StdioFprintf(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
struct StdVararg PrintfArgs;
|
||||
PrintfArgs.Param = Param + 1;
|
||||
PrintfArgs.NumArgs = NumArgs-2;
|
||||
ReturnValue->Val->Integer = StdioBasePrintf(Parser, Param[0]->Val->Pointer, NULL, 0, Param[1]->Val->Pointer, &PrintfArgs);
|
||||
PrintfArgs._param = _param + 1;
|
||||
PrintfArgs._numArgs = _numArgs-2;
|
||||
_returnValue->Val->Integer = StdioBasePrintf(_parser, _param[0]->Val->Pointer, NULL, 0, _param[1]->Val->Pointer, &PrintfArgs);
|
||||
}
|
||||
|
||||
void StdioVfprintf(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = StdioBasePrintf(Parser, Param[0]->Val->Pointer, NULL, 0, Param[1]->Val->Pointer, Param[2]->Val->Pointer);
|
||||
void StdioVfprintf(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = StdioBasePrintf(_parser, _param[0]->Val->Pointer, NULL, 0, _param[1]->Val->Pointer, _param[2]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioSprintf(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
void StdioSprintf(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
struct StdVararg PrintfArgs;
|
||||
PrintfArgs.Param = Param + 1;
|
||||
PrintfArgs.NumArgs = NumArgs-2;
|
||||
ReturnValue->Val->Integer = StdioBasePrintf(Parser, NULL, Param[0]->Val->Pointer, -1, Param[1]->Val->Pointer, &PrintfArgs);
|
||||
PrintfArgs._param = _param + 1;
|
||||
PrintfArgs._numArgs = _numArgs-2;
|
||||
_returnValue->Val->Integer = StdioBasePrintf(_parser, NULL, _param[0]->Val->Pointer, -1, _param[1]->Val->Pointer, &PrintfArgs);
|
||||
}
|
||||
|
||||
void StdioSnprintf(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
void StdioSnprintf(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
struct StdVararg PrintfArgs;
|
||||
PrintfArgs.Param = Param+2;
|
||||
PrintfArgs.NumArgs = NumArgs-3;
|
||||
ReturnValue->Val->Integer = StdioBasePrintf(Parser, NULL, Param[0]->Val->Pointer, Param[1]->Val->Integer, Param[2]->Val->Pointer, &PrintfArgs);
|
||||
PrintfArgs._param = _param+2;
|
||||
PrintfArgs._numArgs = _numArgs-3;
|
||||
_returnValue->Val->Integer = StdioBasePrintf(_parser, NULL, _param[0]->Val->Pointer, _param[1]->Val->Integer, _param[2]->Val->Pointer, &PrintfArgs);
|
||||
}
|
||||
|
||||
void StdioScanf(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
void StdioScanf(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
struct StdVararg ScanfArgs;
|
||||
ScanfArgs.Param = Param;
|
||||
ScanfArgs.NumArgs = NumArgs-1;
|
||||
ReturnValue->Val->Integer = StdioBaseScanf(Parser, stdin, NULL, Param[0]->Val->Pointer, &ScanfArgs);
|
||||
ScanfArgs._param = _param;
|
||||
ScanfArgs._numArgs = _numArgs-1;
|
||||
_returnValue->Val->Integer = StdioBaseScanf(_parser, stdin, NULL, _param[0]->Val->Pointer, &ScanfArgs);
|
||||
}
|
||||
|
||||
void StdioFscanf(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
void StdioFscanf(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
struct StdVararg ScanfArgs;
|
||||
ScanfArgs.Param = Param+1;
|
||||
ScanfArgs.NumArgs = NumArgs-2;
|
||||
ReturnValue->Val->Integer = StdioBaseScanf(Parser, Param[0]->Val->Pointer, NULL, Param[1]->Val->Pointer, &ScanfArgs);
|
||||
ScanfArgs._param = _param+1;
|
||||
ScanfArgs._numArgs = _numArgs-2;
|
||||
_returnValue->Val->Integer = StdioBaseScanf(_parser, _param[0]->Val->Pointer, NULL, _param[1]->Val->Pointer, &ScanfArgs);
|
||||
}
|
||||
|
||||
void StdioSscanf(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
void StdioSscanf(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
struct StdVararg ScanfArgs;
|
||||
ScanfArgs.Param = Param+1;
|
||||
ScanfArgs.NumArgs = NumArgs-2;
|
||||
ReturnValue->Val->Integer = StdioBaseScanf(Parser, NULL, Param[0]->Val->Pointer, Param[1]->Val->Pointer, &ScanfArgs);
|
||||
ScanfArgs._param = _param+1;
|
||||
ScanfArgs._numArgs = _numArgs-2;
|
||||
_returnValue->Val->Integer = StdioBaseScanf(_parser, NULL, _param[0]->Val->Pointer, _param[1]->Val->Pointer, &ScanfArgs);
|
||||
}
|
||||
|
||||
void StdioVsprintf(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = StdioBasePrintf(Parser, NULL, Param[0]->Val->Pointer, -1, Param[1]->Val->Pointer, Param[2]->Val->Pointer);
|
||||
void StdioVsprintf(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = StdioBasePrintf(_parser, NULL, _param[0]->Val->Pointer, -1, _param[1]->Val->Pointer, _param[2]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioVsnprintf(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = StdioBasePrintf(Parser, NULL, Param[0]->Val->Pointer, Param[1]->Val->Integer, Param[2]->Val->Pointer, Param[3]->Val->Pointer);
|
||||
void StdioVsnprintf(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = StdioBasePrintf(_parser, NULL, _param[0]->Val->Pointer, _param[1]->Val->Integer, _param[2]->Val->Pointer, _param[3]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioVscanf(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = StdioBaseScanf(Parser, stdin, NULL, Param[0]->Val->Pointer, Param[1]->Val->Pointer);
|
||||
void StdioVscanf(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = StdioBaseScanf(_parser, stdin, NULL, _param[0]->Val->Pointer, _param[1]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioVfscanf(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = StdioBaseScanf(Parser, Param[0]->Val->Pointer, NULL, Param[1]->Val->Pointer, Param[2]->Val->Pointer);
|
||||
void StdioVfscanf(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = StdioBaseScanf(_parser, _param[0]->Val->Pointer, NULL, _param[1]->Val->Pointer, _param[2]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdioVsscanf(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = StdioBaseScanf(Parser, NULL, Param[0]->Val->Pointer, Param[1]->Val->Pointer, Param[2]->Val->Pointer);
|
||||
void StdioVsscanf(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = StdioBaseScanf(_parser, NULL, _param[0]->Val->Pointer, _param[1]->Val->Pointer, _param[2]->Val->Pointer);
|
||||
}
|
||||
|
||||
/* handy structure definitions */
|
||||
|
17
eci/cstdlib/stdio.h
Normal file
17
eci/cstdlib/stdio.h
Normal file
@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ECI_STDIO_H__
|
||||
#define __ECI_STDIO_H__
|
||||
|
||||
|
||||
extern const char StdioDefs[];
|
||||
extern struct LibraryFunction StdioFunctions[];
|
||||
void StdioSetupFunc();
|
||||
|
||||
#endif
|
@ -13,76 +13,76 @@
|
||||
|
||||
static int ZeroValue = 0;
|
||||
|
||||
void StdlibAtof(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->FP = atof(Param[0]->Val->Pointer);
|
||||
void StdlibAtof(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->FP = atof(_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdlibAtoi(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = atoi(Param[0]->Val->Pointer);
|
||||
void StdlibAtoi(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = atoi(_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdlibAtol(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = atol(Param[0]->Val->Pointer);
|
||||
void StdlibAtol(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = atol(_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdlibStrtod(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->FP = strtod(Param[0]->Val->Pointer, Param[1]->Val->Pointer);
|
||||
void StdlibStrtod(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->FP = strtod(_param[0]->Val->Pointer, _param[1]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdlibStrtol(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = strtol(Param[0]->Val->Pointer, Param[1]->Val->Pointer, Param[2]->Val->Integer);
|
||||
void StdlibStrtol(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = strtol(_param[0]->Val->Pointer, _param[1]->Val->Pointer, _param[2]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdlibStrtoul(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = strtoul(Param[0]->Val->Pointer, Param[1]->Val->Pointer, Param[2]->Val->Integer);
|
||||
void StdlibStrtoul(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = strtoul(_param[0]->Val->Pointer, _param[1]->Val->Pointer, _param[2]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdlibMalloc(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = malloc(Param[0]->Val->Integer);
|
||||
void StdlibMalloc(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = malloc(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdlibCalloc(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = calloc(Param[0]->Val->Integer, Param[1]->Val->Integer);
|
||||
void StdlibCalloc(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = calloc(_param[0]->Val->Integer, _param[1]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdlibRealloc(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = realloc(Param[0]->Val->Pointer, Param[1]->Val->Integer);
|
||||
void StdlibRealloc(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = realloc(_param[0]->Val->Pointer, _param[1]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdlibFree(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
free(Param[0]->Val->Pointer);
|
||||
void StdlibFree(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
free(_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdlibRand(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = rand();
|
||||
void StdlibRand(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = rand();
|
||||
}
|
||||
|
||||
void StdlibSrand(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
srand(Param[0]->Val->Integer);
|
||||
void StdlibSrand(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
srand(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdlibAbort(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ProgramFail(Parser, "abort");
|
||||
void StdlibAbort(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
ProgramFail(_parser, "abort");
|
||||
}
|
||||
|
||||
void StdlibExit(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
PlatformExit(Param[0]->Val->Integer);
|
||||
void StdlibExit(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
PlatformExit(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdlibGetenv(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = getenv(Param[0]->Val->Pointer);
|
||||
void StdlibGetenv(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = getenv(_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdlibSystem(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = system(Param[0]->Val->Pointer);
|
||||
void StdlibSystem(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = system(_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdlibAbs(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = abs(Param[0]->Val->Integer);
|
||||
void StdlibAbs(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = abs(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdlibLabs(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = labs(Param[0]->Val->Integer);
|
||||
void StdlibLabs(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = labs(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
/* all stdlib.h functions */
|
||||
|
16
eci/cstdlib/stdlib.h
Normal file
16
eci/cstdlib/stdlib.h
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ECI_STD_LIB_H__
|
||||
#define __ECI_STD_LIB_H__
|
||||
|
||||
|
||||
extern struct LibraryFunction StdlibFunctions[];
|
||||
void StdlibSetupFunc();
|
||||
|
||||
#endif
|
@ -13,108 +13,108 @@
|
||||
|
||||
static int ZeroValue = 0;
|
||||
|
||||
void StringStrcpy(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = strcpy(Param[0]->Val->Pointer, Param[1]->Val->Pointer);
|
||||
void StringStrcpy(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = strcpy(_param[0]->Val->Pointer, _param[1]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StringStrncpy(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = strncpy(Param[0]->Val->Pointer, Param[1]->Val->Pointer, Param[2]->Val->Integer);
|
||||
void StringStrncpy(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = strncpy(_param[0]->Val->Pointer, _param[1]->Val->Pointer, _param[2]->Val->Integer);
|
||||
}
|
||||
|
||||
void StringStrcmp(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = strcmp(Param[0]->Val->Pointer, Param[1]->Val->Pointer);
|
||||
void StringStrcmp(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = strcmp(_param[0]->Val->Pointer, _param[1]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StringStrncmp(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = strncmp(Param[0]->Val->Pointer, Param[1]->Val->Pointer, Param[2]->Val->Integer);
|
||||
void StringStrncmp(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = strncmp(_param[0]->Val->Pointer, _param[1]->Val->Pointer, _param[2]->Val->Integer);
|
||||
}
|
||||
|
||||
void StringStrcat(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = strcat(Param[0]->Val->Pointer, Param[1]->Val->Pointer);
|
||||
void StringStrcat(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = strcat(_param[0]->Val->Pointer, _param[1]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StringStrncat(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = strncat(Param[0]->Val->Pointer, Param[1]->Val->Pointer, Param[2]->Val->Integer);
|
||||
void StringStrncat(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = strncat(_param[0]->Val->Pointer, _param[1]->Val->Pointer, _param[2]->Val->Integer);
|
||||
}
|
||||
|
||||
void StringIndex(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = index(Param[0]->Val->Pointer, Param[1]->Val->Integer);
|
||||
void StringIndex(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = index(_param[0]->Val->Pointer, _param[1]->Val->Integer);
|
||||
}
|
||||
|
||||
void StringRindex(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = rindex(Param[0]->Val->Pointer, Param[1]->Val->Integer);
|
||||
void StringRindex(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = rindex(_param[0]->Val->Pointer, _param[1]->Val->Integer);
|
||||
}
|
||||
|
||||
void StringStrlen(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = strlen(Param[0]->Val->Pointer);
|
||||
void StringStrlen(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = strlen(_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StringMemset(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = memset(Param[0]->Val->Pointer, Param[1]->Val->Integer, Param[2]->Val->Integer);
|
||||
void StringMemset(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = memset(_param[0]->Val->Pointer, _param[1]->Val->Integer, _param[2]->Val->Integer);
|
||||
}
|
||||
|
||||
void StringMemcpy(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = memcpy(Param[0]->Val->Pointer, Param[1]->Val->Pointer, Param[2]->Val->Integer);
|
||||
void StringMemcpy(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = memcpy(_param[0]->Val->Pointer, _param[1]->Val->Pointer, _param[2]->Val->Integer);
|
||||
}
|
||||
|
||||
void StringMemcmp(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = memcmp(Param[0]->Val->Pointer, Param[1]->Val->Pointer, Param[2]->Val->Integer);
|
||||
void StringMemcmp(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = memcmp(_param[0]->Val->Pointer, _param[1]->Val->Pointer, _param[2]->Val->Integer);
|
||||
}
|
||||
|
||||
void StringMemmove(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = memmove(Param[0]->Val->Pointer, Param[1]->Val->Pointer, Param[2]->Val->Integer);
|
||||
void StringMemmove(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = memmove(_param[0]->Val->Pointer, _param[1]->Val->Pointer, _param[2]->Val->Integer);
|
||||
}
|
||||
|
||||
void StringMemchr(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = memchr(Param[0]->Val->Pointer, Param[1]->Val->Integer, Param[2]->Val->Integer);
|
||||
void StringMemchr(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = memchr(_param[0]->Val->Pointer, _param[1]->Val->Integer, _param[2]->Val->Integer);
|
||||
}
|
||||
|
||||
void StringStrchr(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = strchr(Param[0]->Val->Pointer, Param[1]->Val->Integer);
|
||||
void StringStrchr(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = strchr(_param[0]->Val->Pointer, _param[1]->Val->Integer);
|
||||
}
|
||||
|
||||
void StringStrrchr(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = strrchr(Param[0]->Val->Pointer, Param[1]->Val->Integer);
|
||||
void StringStrrchr(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = strrchr(_param[0]->Val->Pointer, _param[1]->Val->Integer);
|
||||
}
|
||||
|
||||
void StringStrcoll(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = strcoll(Param[0]->Val->Pointer, Param[1]->Val->Pointer);
|
||||
void StringStrcoll(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = strcoll(_param[0]->Val->Pointer, _param[1]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StringStrerror(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = strerror(Param[0]->Val->Integer);
|
||||
void StringStrerror(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = strerror(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void StringStrspn(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = strspn(Param[0]->Val->Pointer, Param[1]->Val->Pointer);
|
||||
void StringStrspn(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = strspn(_param[0]->Val->Pointer, _param[1]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StringStrcspn(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = strcspn(Param[0]->Val->Pointer, Param[1]->Val->Pointer);
|
||||
void StringStrcspn(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = strcspn(_param[0]->Val->Pointer, _param[1]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StringStrpbrk(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = strpbrk(Param[0]->Val->Pointer, Param[1]->Val->Pointer);
|
||||
void StringStrpbrk(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = strpbrk(_param[0]->Val->Pointer, _param[1]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StringStrstr(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = strstr(Param[0]->Val->Pointer, Param[1]->Val->Pointer);
|
||||
void StringStrstr(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = strstr(_param[0]->Val->Pointer, _param[1]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StringStrtok(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = strtok(Param[0]->Val->Pointer, Param[1]->Val->Pointer);
|
||||
void StringStrtok(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = strtok(_param[0]->Val->Pointer, _param[1]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StringStrxfrm(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = strxfrm(Param[0]->Val->Pointer, Param[1]->Val->Pointer, Param[2]->Val->Integer);
|
||||
void StringStrxfrm(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = strxfrm(_param[0]->Val->Pointer, _param[1]->Val->Pointer, _param[2]->Val->Integer);
|
||||
}
|
||||
|
||||
void StringStrdup(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = strdup(Param[0]->Val->Pointer);
|
||||
void StringStrdup(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = strdup(_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StringStrtok_r(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = strtok_r(Param[0]->Val->Pointer, Param[1]->Val->Pointer, Param[2]->Val->Pointer);
|
||||
void StringStrtok_r(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = strtok_r(_param[0]->Val->Pointer, _param[1]->Val->Pointer, _param[2]->Val->Pointer);
|
||||
}
|
||||
|
||||
/* all string.h functions */
|
||||
|
16
eci/cstdlib/string.h
Normal file
16
eci/cstdlib/string.h
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ECI_STRING_H__
|
||||
#define __ECI_STRING_H__
|
||||
|
||||
|
||||
extern struct LibraryFunction StringFunctions[];
|
||||
void StringSetupFunc();
|
||||
|
||||
#endif
|
@ -22,53 +22,53 @@ static int CLK_PER_SECValue = CLK_PER_SEC;
|
||||
static int CLK_TCKValue = CLK_TCK;
|
||||
#endif
|
||||
|
||||
void StdAsctime(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = asctime(Param[0]->Val->Pointer);
|
||||
void StdAsctime(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = asctime(_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdClock(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = clock();
|
||||
void StdClock(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = clock();
|
||||
}
|
||||
|
||||
void StdCtime(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = ctime(Param[0]->Val->Pointer);
|
||||
void StdCtime(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = ctime(_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdDifftime(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->FP = difftime((time_t)Param[0]->Val->Integer, Param[1]->Val->Integer);
|
||||
void StdDifftime(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->FP = difftime((time_t)_param[0]->Val->Integer, _param[1]->Val->Integer);
|
||||
}
|
||||
|
||||
void StdGmtime(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = gmtime(Param[0]->Val->Pointer);
|
||||
void StdGmtime(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = gmtime(_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdGmtime_r(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = gmtime_r(Param[0]->Val->Pointer, Param[1]->Val->Pointer);
|
||||
void StdGmtime_r(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = gmtime_r(_param[0]->Val->Pointer, _param[1]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdLocaltime(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = localtime(Param[0]->Val->Pointer);
|
||||
void StdLocaltime(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = localtime(_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdMktime(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = mktime(Param[0]->Val->Pointer);
|
||||
void StdMktime(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = mktime(_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdTime(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = time(Param[0]->Val->Pointer);
|
||||
void StdTime(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = time(_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdStrftime(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = strftime(Param[0]->Val->Pointer, Param[1]->Val->Integer, Param[2]->Val->Pointer, Param[3]->Val->Pointer);
|
||||
void StdStrftime(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = strftime(_param[0]->Val->Pointer, _param[1]->Val->Integer, _param[2]->Val->Pointer, _param[3]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdStrptime(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
void StdStrptime(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
extern char *strptime(const char *s, const char *format, struct tm *tm);
|
||||
ReturnValue->Val->Pointer = strptime(Param[0]->Val->Pointer, Param[1]->Val->Pointer, Param[2]->Val->Pointer);
|
||||
_returnValue->Val->Pointer = strptime(_param[0]->Val->Pointer, _param[1]->Val->Pointer, _param[2]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdTimegm(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = timegm(Param[0]->Val->Pointer);
|
||||
void StdTimegm(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = timegm(_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
/* handy structure definitions */
|
||||
|
16
eci/cstdlib/time.h
Normal file
16
eci/cstdlib/time.h
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ECI_TIME_H__
|
||||
#define __ECI_TIME_H__
|
||||
|
||||
extern const char StdTimeDefs[];
|
||||
extern struct LibraryFunction StdTimeFunctions[];
|
||||
void StdTimeSetupFunc();
|
||||
|
||||
#endif
|
@ -16,268 +16,268 @@
|
||||
|
||||
static int ZeroValue = 0;
|
||||
|
||||
void UnistdAccess(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = access(Param[0]->Val->Pointer, Param[1]->Val->Integer);
|
||||
void UnistdAccess(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = access(_param[0]->Val->Pointer, _param[1]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdAlarm(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = alarm(Param[0]->Val->Integer);
|
||||
void UnistdAlarm(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = alarm(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdChdir(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = chdir(Param[0]->Val->Pointer);
|
||||
void UnistdChdir(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = chdir(_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void UnistdChroot(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = chroot(Param[0]->Val->Pointer);
|
||||
void UnistdChroot(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = chroot(_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void UnistdChown(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = chown(Param[0]->Val->Pointer, Param[1]->Val->Integer, Param[2]->Val->Integer);
|
||||
void UnistdChown(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = chown(_param[0]->Val->Pointer, _param[1]->Val->Integer, _param[2]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdClose(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = close(Param[0]->Val->Integer);
|
||||
void UnistdClose(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = close(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdConfstr(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = confstr(Param[0]->Val->Integer, Param[1]->Val->Pointer, Param[2]->Val->Integer);
|
||||
void UnistdConfstr(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = confstr(_param[0]->Val->Integer, _param[1]->Val->Pointer, _param[2]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdCtermid(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = ctermid(Param[0]->Val->Pointer);
|
||||
void UnistdCtermid(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = ctermid(_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void UnistdDup(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = dup(Param[0]->Val->Integer);
|
||||
void UnistdDup(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = dup(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdDup2(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = dup2(Param[0]->Val->Integer, Param[1]->Val->Integer);
|
||||
void UnistdDup2(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = dup2(_param[0]->Val->Integer, _param[1]->Val->Integer);
|
||||
}
|
||||
|
||||
void Unistd_Exit(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
_exit(Param[0]->Val->Integer);
|
||||
void Unistd_Exit(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_exit(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdFchown(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = fchown(Param[0]->Val->Integer, Param[1]->Val->Integer, Param[2]->Val->Integer);
|
||||
void UnistdFchown(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = fchown(_param[0]->Val->Integer, _param[1]->Val->Integer, _param[2]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdFchdir(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = fchdir(Param[0]->Val->Integer);
|
||||
void UnistdFchdir(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = fchdir(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdFdatasync(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = fdatasync(Param[0]->Val->Integer);
|
||||
void UnistdFdatasync(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = fdatasync(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdFork(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = fork();
|
||||
void UnistdFork(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = fork();
|
||||
}
|
||||
|
||||
void UnistdFpathconf(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = fpathconf(Param[0]->Val->Integer, Param[1]->Val->Integer);
|
||||
void UnistdFpathconf(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = fpathconf(_param[0]->Val->Integer, _param[1]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdFsync(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = fsync(Param[0]->Val->Integer);
|
||||
void UnistdFsync(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = fsync(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdFtruncate(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = ftruncate(Param[0]->Val->Integer, Param[1]->Val->Integer);
|
||||
void UnistdFtruncate(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = ftruncate(_param[0]->Val->Integer, _param[1]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdGetcwd(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = getcwd(Param[0]->Val->Pointer, Param[1]->Val->Integer);
|
||||
void UnistdGetcwd(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = getcwd(_param[0]->Val->Pointer, _param[1]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdGetdtablesize(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = getdtablesize();
|
||||
void UnistdGetdtablesize(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = getdtablesize();
|
||||
}
|
||||
|
||||
void UnistdGetegid(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = getegid();
|
||||
void UnistdGetegid(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = getegid();
|
||||
}
|
||||
|
||||
void UnistdGeteuid(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = geteuid();
|
||||
void UnistdGeteuid(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = geteuid();
|
||||
}
|
||||
|
||||
void UnistdGetgid(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = getgid();
|
||||
void UnistdGetgid(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = getgid();
|
||||
}
|
||||
|
||||
void UnistdGethostid(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = gethostid();
|
||||
void UnistdGethostid(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = gethostid();
|
||||
}
|
||||
|
||||
void UnistdGetlogin(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = getlogin();
|
||||
void UnistdGetlogin(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = getlogin();
|
||||
}
|
||||
|
||||
void UnistdGetlogin_r(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = getlogin_r(Param[0]->Val->Pointer, Param[1]->Val->Integer);
|
||||
void UnistdGetlogin_r(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = getlogin_r(_param[0]->Val->Pointer, _param[1]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdGetpagesize(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = getpagesize();
|
||||
void UnistdGetpagesize(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = getpagesize();
|
||||
}
|
||||
|
||||
void UnistdGetpass(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = getpass(Param[0]->Val->Pointer);
|
||||
void UnistdGetpass(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = getpass(_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void UnistdGetpgrp(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = getpgrp();
|
||||
void UnistdGetpgrp(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = getpgrp();
|
||||
}
|
||||
|
||||
void UnistdGetpid(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = getpid();
|
||||
void UnistdGetpid(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = getpid();
|
||||
}
|
||||
|
||||
void UnistdGetppid(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = getppid();
|
||||
void UnistdGetppid(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = getppid();
|
||||
}
|
||||
|
||||
void UnistdGetuid(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = getuid();
|
||||
void UnistdGetuid(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = getuid();
|
||||
}
|
||||
|
||||
void UnistdGetwd(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = getcwd(Param[0]->Val->Pointer, PATH_MAX);
|
||||
void UnistdGetwd(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = getcwd(_param[0]->Val->Pointer, PATH_MAX);
|
||||
}
|
||||
|
||||
void UnistdIsatty(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = isatty(Param[0]->Val->Integer);
|
||||
void UnistdIsatty(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = isatty(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdLchown(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = lchown(Param[0]->Val->Pointer, Param[1]->Val->Integer, Param[2]->Val->Integer);
|
||||
void UnistdLchown(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = lchown(_param[0]->Val->Pointer, _param[1]->Val->Integer, _param[2]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdLink(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = link(Param[0]->Val->Pointer, Param[1]->Val->Pointer);
|
||||
void UnistdLink(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = link(_param[0]->Val->Pointer, _param[1]->Val->Pointer);
|
||||
}
|
||||
|
||||
void UnistdLockf(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = lockf(Param[0]->Val->Integer, Param[1]->Val->Integer, Param[2]->Val->Integer);
|
||||
void UnistdLockf(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = lockf(_param[0]->Val->Integer, _param[1]->Val->Integer, _param[2]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdLseek(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = lseek(Param[0]->Val->Integer, Param[1]->Val->Integer, Param[2]->Val->Integer);
|
||||
void UnistdLseek(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = lseek(_param[0]->Val->Integer, _param[1]->Val->Integer, _param[2]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdNice(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = nice(Param[0]->Val->Integer);
|
||||
void UnistdNice(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = nice(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdPathconf(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = pathconf(Param[0]->Val->Pointer, Param[1]->Val->Integer);
|
||||
void UnistdPathconf(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = pathconf(_param[0]->Val->Pointer, _param[1]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdPause(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = pause();
|
||||
void UnistdPause(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = pause();
|
||||
}
|
||||
|
||||
void UnistdRead(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = read(Param[0]->Val->Integer, Param[1]->Val->Pointer, Param[2]->Val->Integer);
|
||||
void UnistdRead(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = read(_param[0]->Val->Integer, _param[1]->Val->Pointer, _param[2]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdReadlink(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = readlink(Param[0]->Val->Pointer, Param[1]->Val->Pointer, Param[2]->Val->Integer);
|
||||
void UnistdReadlink(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = readlink(_param[0]->Val->Pointer, _param[1]->Val->Pointer, _param[2]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdRmdir(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = rmdir(Param[0]->Val->Pointer);
|
||||
void UnistdRmdir(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = rmdir(_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void UnistdSbrk(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = sbrk(Param[0]->Val->Integer);
|
||||
void UnistdSbrk(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = sbrk(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdSetgid(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = setgid(Param[0]->Val->Integer);
|
||||
void UnistdSetgid(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = setgid(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdSetpgid(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = setpgid(Param[0]->Val->Integer, Param[1]->Val->Integer);
|
||||
void UnistdSetpgid(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = setpgid(_param[0]->Val->Integer, _param[1]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdSetpgrp(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = setpgrp();
|
||||
void UnistdSetpgrp(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = setpgrp();
|
||||
}
|
||||
|
||||
void UnistdSetregid(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = setregid(Param[0]->Val->Integer, Param[1]->Val->Integer);
|
||||
void UnistdSetregid(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = setregid(_param[0]->Val->Integer, _param[1]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdSetreuid(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = setreuid(Param[0]->Val->Integer, Param[1]->Val->Integer);
|
||||
void UnistdSetreuid(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = setreuid(_param[0]->Val->Integer, _param[1]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdSetsid(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = setsid();
|
||||
void UnistdSetsid(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = setsid();
|
||||
}
|
||||
|
||||
void UnistdSetuid(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = setuid(Param[0]->Val->Integer);
|
||||
void UnistdSetuid(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = setuid(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdSleep(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = sleep(Param[0]->Val->Integer);
|
||||
void UnistdSleep(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = sleep(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdSymlink(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = symlink(Param[0]->Val->Pointer, Param[1]->Val->Pointer);
|
||||
void UnistdSymlink(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = symlink(_param[0]->Val->Pointer, _param[1]->Val->Pointer);
|
||||
}
|
||||
|
||||
void UnistdSync(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
void UnistdSync(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
sync();
|
||||
}
|
||||
|
||||
void UnistdSysconf(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = sysconf(Param[0]->Val->Integer);
|
||||
void UnistdSysconf(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = sysconf(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdTcgetpgrp(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = tcgetpgrp(Param[0]->Val->Integer);
|
||||
void UnistdTcgetpgrp(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = tcgetpgrp(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdTcsetpgrp(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = tcsetpgrp(Param[0]->Val->Integer, Param[1]->Val->Integer);
|
||||
void UnistdTcsetpgrp(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = tcsetpgrp(_param[0]->Val->Integer, _param[1]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdTruncate(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = truncate(Param[0]->Val->Pointer, Param[1]->Val->Integer);
|
||||
void UnistdTruncate(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = truncate(_param[0]->Val->Pointer, _param[1]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdTtyname(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Pointer = ttyname(Param[0]->Val->Integer);
|
||||
void UnistdTtyname(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Pointer = ttyname(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdTtyname_r(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = ttyname_r(Param[0]->Val->Integer, Param[1]->Val->Pointer, Param[2]->Val->Integer);
|
||||
void UnistdTtyname_r(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = ttyname_r(_param[0]->Val->Integer, _param[1]->Val->Pointer, _param[2]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdUalarm(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = ualarm(Param[0]->Val->Integer, Param[1]->Val->Integer);
|
||||
void UnistdUalarm(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = ualarm(_param[0]->Val->Integer, _param[1]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdUnlink(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = unlink(Param[0]->Val->Pointer);
|
||||
void UnistdUnlink(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = unlink(_param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void UnistdUsleep(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = usleep(Param[0]->Val->Integer);
|
||||
void UnistdUsleep(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = usleep(_param[0]->Val->Integer);
|
||||
}
|
||||
|
||||
void UnistdVfork(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = vfork();
|
||||
void UnistdVfork(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = vfork();
|
||||
}
|
||||
|
||||
void UnistdWrite(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs) {
|
||||
ReturnValue->Val->Integer = write(Param[0]->Val->Integer, Param[1]->Val->Pointer, Param[2]->Val->Integer);
|
||||
void UnistdWrite(struct ParseState *_parser, struct Value *_returnValue, struct Value **_param, int _numArgs) {
|
||||
_returnValue->Val->Integer = write(_param[0]->Val->Integer, _param[1]->Val->Pointer, _param[2]->Val->Integer);
|
||||
}
|
||||
|
||||
|
||||
|
17
eci/cstdlib/unistd.h
Normal file
17
eci/cstdlib/unistd.h
Normal file
@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ECI_UNI_STD_H__
|
||||
#define __ECI_UNI_STD_H__
|
||||
|
||||
|
||||
extern const char UnistdDefs[];
|
||||
extern struct LibraryFunction UnistdFunctions[];
|
||||
void UnistdSetupFunc();
|
||||
|
||||
#endif
|
847
eci/expression.c
847
eci/expression.c
File diff suppressed because it is too large
Load Diff
19
eci/expression.h
Normal file
19
eci/expression.h
Normal file
@ -0,0 +1,19 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ECI_EXPRESSION_H__
|
||||
#define __ECI_EXPRESSION_H__
|
||||
|
||||
int ExpressionParse(struct ParseState *_parser, struct Value **_result);
|
||||
long ExpressionParseInt(struct ParseState *_parser);
|
||||
void ExpressionAssign(struct ParseState *_parser, struct Value *_destValue, struct Value *_sourceValue, int _force, const char *_funcName, int _paramNo, int _allowPointerCoercion);
|
||||
long ExpressionCoerceInteger(struct Value *_value);
|
||||
unsigned long ExpressionCoerceUnsignedInteger(struct Value *_value);
|
||||
double ExpressionCoerceFP(struct Value *_value);
|
||||
|
||||
#endif
|
23
eci/heap.h
Normal file
23
eci/heap.h
Normal file
@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ECI_HEAP_H__
|
||||
#define __ECI_HEAP_H__
|
||||
|
||||
|
||||
void HeapInit(int _stackSize);
|
||||
void HeapCleanup();
|
||||
void *HeapAllocStack(int _size);
|
||||
int HeapPopStack(void *_addr, int _size);
|
||||
void HeapUnpopStack(int _size);
|
||||
void HeapPushStackFrame();
|
||||
int HeapPopStackFrame();
|
||||
void *HeapAllocMem(int _size);
|
||||
void HeapFreeMem(void *_mem);
|
||||
|
||||
#endif
|
21
eci/include.h
Normal file
21
eci/include.h
Normal file
@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ECI_INCLUDE_H__
|
||||
#define __ECI_INCLUDE_H__
|
||||
|
||||
|
||||
void IncludeInit();
|
||||
void IncludeCleanup();
|
||||
void IncludeRegister(const char *_includeName, void (*_setupFunction)(void), struct LibraryFunction *_funcList, const char *_setupCSource);
|
||||
void IncludeFile(char *_filename);
|
||||
/* the following is defined in picoc.h:
|
||||
* void PicocIncludeAllSystemHeaders(); */
|
||||
|
||||
|
||||
#endif
|
@ -336,18 +336,18 @@ extern IOFILE *CStdOut;
|
||||
* void PicocCleanup();
|
||||
* void PicocPlatformScanFile(const char *FileName);
|
||||
* extern int PicocExitValue; */
|
||||
void ProgramFail(struct ParseState *Parser, const char *Message, ...);
|
||||
void AssignFail(struct ParseState *Parser, const char *Format, struct ValueType *Type1, struct ValueType *Type2, int Num1, int Num2, const char *FuncName, int ParamNo);
|
||||
void LexFail(struct LexState *Lexer, const char *Message, ...);
|
||||
void ProgramFail(struct ParseState *_parser, const char *_message, ...);
|
||||
void AssignFail(struct ParseState *_parser, const char *_mormat, struct ValueType *_type1, struct ValueType *_type2, int _num1, int _num2, const char *_funcName, int _paramNo);
|
||||
void LexFail(struct LexState *_lexer, const char *_message, ...);
|
||||
void PlatformCleanup();
|
||||
char *PlatformGetLine(char *Buf, int MaxLen, const char *Prompt);
|
||||
char *PlatformGetLine(char *_buf, int _maxLen, const char *_prompt);
|
||||
int PlatformGetCharacter();
|
||||
void PlatformPutc(unsigned char OutCh, union OutputStreamInfo *);
|
||||
void PlatformErrorPrefix(struct ParseState *Parser);
|
||||
void PlatformPrintf(const char *Format, ...);
|
||||
void PlatformVPrintf(const char *Format, va_list Args);
|
||||
void PlatformExit(int ExitVal);
|
||||
char *PlatformMakeTempName(char *TempNameBuffer);
|
||||
void PlatformPutc(unsigned char _outCh, union OutputStreamInfo *);
|
||||
void PlatformErrorPrefix(struct ParseState *_parser);
|
||||
void PlatformPrintf(const char *_format, ...);
|
||||
void PlatformVPrintf(const char *_format, va_list _args);
|
||||
void PlatformExit(int _exitVal);
|
||||
char *PlatformMakeTempName(char *_tempNameBuffer);
|
||||
void PlatformLibraryInit();
|
||||
|
||||
|
||||
|
25
eci/lex.h
Normal file
25
eci/lex.h
Normal file
@ -0,0 +1,25 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ECI_LEX_H__
|
||||
#define __ECI_LEX_H__
|
||||
|
||||
|
||||
void LexInit();
|
||||
void LexCleanup();
|
||||
void* LexAnalyse(const char* _fileName, const char *_source, int _sourceLen, int *_tokenLen);
|
||||
void LexInitParser(struct ParseState* _parser, const char *_sourceText, void* _tokenSource, const char* _fileName, int _runIt);
|
||||
enum LexToken LexGetToken(struct ParseState* _parser, struct Value **_value, int _incPos);
|
||||
enum LexToken LexRawPeekToken(struct ParseState* _parser);
|
||||
void LexToEndOfLine(struct ParseState* _parser);
|
||||
void* LexCopyTokens(struct ParseState* _startParser, struct ParseState* _endParser);
|
||||
void LexInteractiveClear(struct ParseState* _parser);
|
||||
void LexInteractiveCompleted(struct ParseState* _parser);
|
||||
void LexInteractiveStatementPrompt();
|
||||
|
||||
#endif
|
22
eci/parse.h
Normal file
22
eci/parse.h
Normal file
@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ECI_PARSE_H__
|
||||
#define __ECI_PARSE_H__
|
||||
|
||||
|
||||
/* the following are defined in picoc.h:
|
||||
* void PicocParse(const char *FileName, const char *Source, int SourceLen, int RunIt, int CleanupNow, int CleanupSource);
|
||||
* void PicocParseInteractive(); */
|
||||
enum ParseResult ParseStatement(struct ParseState *_parser, int _checkTrailingSemicolon);
|
||||
struct Value *ParseFunctionDefinition(struct ParseState *_parser, struct ValueType *_returnType, char *_identifier);
|
||||
void ParseCleanup();
|
||||
void ParserCopyPos(struct ParseState *_to, struct ParseState *_from);
|
||||
void ParserCopy(struct ParseState *_to, struct ParseState *_from);
|
||||
|
||||
#endif
|
@ -28,14 +28,14 @@ extern jmp_buf PicocExitBuf;
|
||||
#define PicocPlatformSetExitPoint() setjmp(PicocExitBuf)
|
||||
|
||||
/* parse.c */
|
||||
void PicocParse(const char *FileName, const char *Source, int SourceLen, int RunIt, int CleanupNow, int CleanupSource);
|
||||
void PicocParse(const char *_fileName, const char *_source, int _sourceLen, int _runIt, int _cleanupNow, int _cleanupSource);
|
||||
void PicocParseInteractive();
|
||||
|
||||
/* platform.c */
|
||||
void PicocCallMain(int argc, char **argv);
|
||||
void PicocInitialise(int StackSize);
|
||||
void PicocCallMain(int _argc, char **_argv);
|
||||
void PicocInitialise(int _stackSize);
|
||||
void PicocCleanup();
|
||||
void PicocPlatformScanFile(const char *FileName);
|
||||
void PicocPlatformScanFile(const char *_fileName);
|
||||
|
||||
extern int PicocExitValue;
|
||||
|
||||
|
@ -119,16 +119,16 @@ void PrintSourceTextErrorLine(const char *FileName, const char *SourceText, int
|
||||
}
|
||||
|
||||
/* display the source line and line number to identify an error */
|
||||
void PlatformErrorPrefix(struct ParseState *Parser) {
|
||||
if (Parser != NULL) {
|
||||
PrintSourceTextErrorLine(Parser->FileName, Parser->SourceText, Parser->Line, Parser->CharacterPos);
|
||||
void PlatformErrorPrefix(struct ParseState *_parser) {
|
||||
if (_parser != NULL) {
|
||||
PrintSourceTextErrorLine(_parser->FileName, _parser->SourceText, _parser->Line, _parser->CharacterPos);
|
||||
}
|
||||
}
|
||||
|
||||
/* exit with a message */
|
||||
void ProgramFail(struct ParseState *Parser, const char *Message, ...) {
|
||||
void ProgramFail(struct ParseState *_parser, const char *Message, ...) {
|
||||
va_list Args;
|
||||
PlatformErrorPrefix(Parser);
|
||||
PlatformErrorPrefix(_parser);
|
||||
va_start(Args, Message);
|
||||
PlatformVPrintf(Message, Args);
|
||||
va_end(Args);
|
||||
@ -137,8 +137,8 @@ void ProgramFail(struct ParseState *Parser, const char *Message, ...) {
|
||||
}
|
||||
|
||||
/* like ProgramFail() but gives descriptive error messages for assignment */
|
||||
void AssignFail(struct ParseState *Parser, const char *Format, struct ValueType *Type1, struct ValueType *Type2, int Num1, int Num2, const char *FuncName, int ParamNo) {
|
||||
PlatformErrorPrefix(Parser);
|
||||
void AssignFail(struct ParseState *_parser, const char *Format, struct ValueType *Type1, struct ValueType *Type2, int Num1, int Num2, const char *FuncName, int ParamNo) {
|
||||
PlatformErrorPrefix(_parser);
|
||||
PlatformPrintf("can't %s ", (FuncName == NULL) ? "assign" : "set");
|
||||
if (Type1 != NULL) {
|
||||
PlatformPrintf(Format, Type1, Type2);
|
||||
|
23
eci/table.h
Normal file
23
eci/table.h
Normal file
@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ECI_TABLE_H__
|
||||
#define __ECI_TABLE_H__
|
||||
|
||||
|
||||
void TableInit();
|
||||
char *TableStrRegister(const char *_str);
|
||||
char *TableStrRegister2(const char *_str, int Len);
|
||||
void TableInitTable(struct Table *_table, struct TableEntry **_hashTable, int _size, int _onHeap);
|
||||
int TableSet(struct Table *_tbl, char *_key, struct Value *_val, const char *_declFileName, int _declLine, int _declColumn);
|
||||
int TableGet(struct Table *_tbl, const char *_key, struct Value **_val, const char **_declFileName, int *_declLine, int *_declColumn);
|
||||
struct Value *TableDelete(struct Table *_tbl, const char *_key);
|
||||
char *TableSetIdentifier(struct Table *_tbl, const char *_ident, int _identLen);
|
||||
void TableStrFree();
|
||||
|
||||
#endif
|
164
eci/type.c
164
eci/type.c
@ -33,8 +33,8 @@ static int PointerAlignBytes;
|
||||
static int IntAlignBytes;
|
||||
|
||||
/* add a new type to the set of types we know about */
|
||||
struct ValueType *TypeAdd(struct ParseState *Parser, struct ValueType *ParentType, enum BaseType Base, int ArraySize, const char *Identifier, int Sizeof, int AlignBytes) {
|
||||
struct ValueType *NewType = VariableAlloc(Parser, sizeof(struct ValueType), TRUE);
|
||||
struct ValueType *TypeAdd(struct ParseState *_parser, struct ValueType *ParentType, enum BaseType Base, int ArraySize, const char *Identifier, int Sizeof, int AlignBytes) {
|
||||
struct ValueType *NewType = VariableAlloc(_parser, sizeof(struct ValueType), TRUE);
|
||||
NewType->Base = Base;
|
||||
NewType->ArraySize = ArraySize;
|
||||
NewType->Sizeof = Sizeof;
|
||||
@ -51,7 +51,7 @@ struct ValueType *TypeAdd(struct ParseState *Parser, struct ValueType *ParentTyp
|
||||
|
||||
/* given a parent type, get a matching derived type and make one if necessary.
|
||||
* Identifier should be registered with the shared string table. */
|
||||
struct ValueType *TypeGetMatching(struct ParseState *Parser, struct ValueType *ParentType, enum BaseType Base, int ArraySize, const char *Identifier, int AllowDuplicates) {
|
||||
struct ValueType *TypeGetMatching(struct ParseState *_parser, struct ValueType *ParentType, enum BaseType Base, int ArraySize, const char *Identifier, int AllowDuplicates) {
|
||||
int Sizeof;
|
||||
int AlignBytes;
|
||||
struct ValueType *ThisType = ParentType->DerivedTypeList;
|
||||
@ -65,7 +65,7 @@ struct ValueType *TypeGetMatching(struct ParseState *Parser, struct ValueType *P
|
||||
if (AllowDuplicates) {
|
||||
return ThisType;
|
||||
} else {
|
||||
ProgramFail(Parser, "data type '%s' is already defined", Identifier);
|
||||
ProgramFail(_parser, "data type '%s' is already defined", Identifier);
|
||||
}
|
||||
}
|
||||
switch (Base) {
|
||||
@ -87,7 +87,7 @@ struct ValueType *TypeGetMatching(struct ParseState *Parser, struct ValueType *P
|
||||
break;
|
||||
/* structs and unions will get bigger when we add members to them */
|
||||
}
|
||||
return TypeAdd(Parser, ParentType, Base, ArraySize, Identifier, Sizeof, AlignBytes);
|
||||
return TypeAdd(_parser, ParentType, Base, ArraySize, Identifier, Sizeof, AlignBytes);
|
||||
}
|
||||
|
||||
/* stack space used by a value */
|
||||
@ -211,7 +211,7 @@ void TypeCleanup() {
|
||||
}
|
||||
|
||||
/* parse a struct or union declaration */
|
||||
void TypeParseStruct(struct ParseState *Parser, struct ValueType **Typ, int IsStruct) {
|
||||
void TypeParseStruct(struct ParseState *_parser, struct ValueType **Typ, int IsStruct) {
|
||||
struct Value *LexValue;
|
||||
struct ValueType *MemberType;
|
||||
char *MemberIdentifier;
|
||||
@ -219,37 +219,37 @@ void TypeParseStruct(struct ParseState *Parser, struct ValueType **Typ, int IsSt
|
||||
struct Value *MemberValue;
|
||||
enum LexToken Token;
|
||||
int AlignBoundary;
|
||||
Token = LexGetToken(Parser, &LexValue, FALSE);
|
||||
Token = LexGetToken(_parser, &LexValue, FALSE);
|
||||
if (Token == TokenIdentifier) {
|
||||
LexGetToken(Parser, &LexValue, TRUE);
|
||||
LexGetToken(_parser, &LexValue, TRUE);
|
||||
StructIdentifier = LexValue->Val->Identifier;
|
||||
Token = LexGetToken(Parser, NULL, FALSE);
|
||||
Token = LexGetToken(_parser, NULL, FALSE);
|
||||
} else {
|
||||
static char TempNameBuf[7] = "^s0000";
|
||||
StructIdentifier = PlatformMakeTempName(TempNameBuf);
|
||||
}
|
||||
*Typ = TypeGetMatching(Parser, &UberType, IsStruct ? TypeStruct : TypeUnion, 0, StructIdentifier, Token != TokenLeftBrace);
|
||||
Token = LexGetToken(Parser, NULL, FALSE);
|
||||
*Typ = TypeGetMatching(_parser, &UberType, IsStruct ? TypeStruct : TypeUnion, 0, StructIdentifier, Token != TokenLeftBrace);
|
||||
Token = LexGetToken(_parser, NULL, FALSE);
|
||||
if (Token != TokenLeftBrace) {
|
||||
/* use the already defined structure */
|
||||
if ((*Typ)->Members == NULL) {
|
||||
ProgramFail(Parser, "structure '%s' isn't defined", LexValue->Val->Identifier);
|
||||
ProgramFail(_parser, "structure '%s' isn't defined", LexValue->Val->Identifier);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (TopStackFrame != NULL) {
|
||||
ProgramFail(Parser, "struct/union definitions can only be globals");
|
||||
ProgramFail(_parser, "struct/union definitions can only be globals");
|
||||
}
|
||||
LexGetToken(Parser, NULL, TRUE);
|
||||
(*Typ)->Members = VariableAlloc(Parser, sizeof(struct Table) + STRUCT_TABLE_SIZE * sizeof(struct TableEntry), TRUE);
|
||||
LexGetToken(_parser, NULL, TRUE);
|
||||
(*Typ)->Members = VariableAlloc(_parser, sizeof(struct Table) + STRUCT_TABLE_SIZE * sizeof(struct TableEntry), TRUE);
|
||||
(*Typ)->Members->HashTable = (struct TableEntry **)((char *)(*Typ)->Members + sizeof(struct Table));
|
||||
TableInitTable((*Typ)->Members, (struct TableEntry **)((char *)(*Typ)->Members + sizeof(struct Table)), STRUCT_TABLE_SIZE, TRUE);
|
||||
do {
|
||||
TypeParse(Parser, &MemberType, &MemberIdentifier, NULL);
|
||||
TypeParse(_parser, &MemberType, &MemberIdentifier, NULL);
|
||||
if (MemberType == NULL || MemberIdentifier == NULL) {
|
||||
ProgramFail(Parser, "invalid type in struct");
|
||||
ProgramFail(_parser, "invalid type in struct");
|
||||
}
|
||||
MemberValue = VariableAllocValueAndData(Parser, sizeof(int), FALSE, NULL, TRUE);
|
||||
MemberValue = VariableAllocValueAndData(_parser, sizeof(int), FALSE, NULL, TRUE);
|
||||
MemberValue->Typ = MemberType;
|
||||
if (IsStruct) {
|
||||
/* allocate this member's location in the struct */
|
||||
@ -271,26 +271,26 @@ void TypeParseStruct(struct ParseState *Parser, struct ValueType **Typ, int IsSt
|
||||
(*Typ)->AlignBytes = MemberValue->Typ->AlignBytes;
|
||||
}
|
||||
/* define it */
|
||||
if (!TableSet((*Typ)->Members, MemberIdentifier, MemberValue, Parser->FileName, Parser->Line, Parser->CharacterPos)) {
|
||||
ProgramFail(Parser, "member '%s' already defined", &MemberIdentifier);
|
||||
if (!TableSet((*Typ)->Members, MemberIdentifier, MemberValue, _parser->FileName, _parser->Line, _parser->CharacterPos)) {
|
||||
ProgramFail(_parser, "member '%s' already defined", &MemberIdentifier);
|
||||
}
|
||||
if (LexGetToken(Parser, NULL, TRUE) != TokenSemicolon) {
|
||||
ProgramFail(Parser, "semicolon expected");
|
||||
if (LexGetToken(_parser, NULL, TRUE) != TokenSemicolon) {
|
||||
ProgramFail(_parser, "semicolon expected");
|
||||
}
|
||||
} while (LexGetToken(Parser, NULL, FALSE) != TokenRightBrace);
|
||||
} while (LexGetToken(_parser, NULL, FALSE) != TokenRightBrace);
|
||||
/* now align the structure to the size of its largest member's alignment */
|
||||
AlignBoundary = (*Typ)->AlignBytes;
|
||||
if (((*Typ)->Sizeof & (AlignBoundary-1)) != 0) {
|
||||
(*Typ)->Sizeof += AlignBoundary - ((*Typ)->Sizeof & (AlignBoundary-1));
|
||||
}
|
||||
LexGetToken(Parser, NULL, TRUE);
|
||||
LexGetToken(_parser, NULL, TRUE);
|
||||
}
|
||||
|
||||
/* create a system struct which has no user-visible members */
|
||||
struct ValueType *TypeCreateOpaqueStruct(struct ParseState *Parser, const char *StructName, int Size) {
|
||||
struct ValueType *Typ = TypeGetMatching(Parser, &UberType, TypeStruct, 0, StructName, FALSE);
|
||||
struct ValueType *TypeCreateOpaqueStruct(struct ParseState *_parser, const char *StructName, int Size) {
|
||||
struct ValueType *Typ = TypeGetMatching(_parser, &UberType, TypeStruct, 0, StructName, FALSE);
|
||||
/* create the (empty) table */
|
||||
Typ->Members = VariableAlloc(Parser, sizeof(struct Table) + STRUCT_TABLE_SIZE * sizeof(struct TableEntry), TRUE);
|
||||
Typ->Members = VariableAlloc(_parser, sizeof(struct Table) + STRUCT_TABLE_SIZE * sizeof(struct TableEntry), TRUE);
|
||||
Typ->Members->HashTable = (struct TableEntry **)((char *)Typ->Members + sizeof(struct Table));
|
||||
TableInitTable(Typ->Members, (struct TableEntry **)((char *)Typ->Members + sizeof(struct Table)), STRUCT_TABLE_SIZE, TRUE);
|
||||
Typ->Sizeof = Size;
|
||||
@ -298,60 +298,60 @@ struct ValueType *TypeCreateOpaqueStruct(struct ParseState *Parser, const char *
|
||||
}
|
||||
|
||||
/* parse an enum declaration */
|
||||
void TypeParseEnum(struct ParseState *Parser, struct ValueType **Typ) {
|
||||
void TypeParseEnum(struct ParseState *_parser, struct ValueType **Typ) {
|
||||
struct Value *LexValue;
|
||||
struct Value InitValue;
|
||||
enum LexToken Token;
|
||||
struct ValueType *EnumType;
|
||||
int EnumValue = 0;
|
||||
char *EnumIdentifier;
|
||||
Token = LexGetToken(Parser, &LexValue, FALSE);
|
||||
Token = LexGetToken(_parser, &LexValue, FALSE);
|
||||
if (Token == TokenIdentifier) {
|
||||
LexGetToken(Parser, &LexValue, TRUE);
|
||||
LexGetToken(_parser, &LexValue, TRUE);
|
||||
EnumIdentifier = LexValue->Val->Identifier;
|
||||
Token = LexGetToken(Parser, NULL, FALSE);
|
||||
Token = LexGetToken(_parser, NULL, FALSE);
|
||||
} else {
|
||||
static char TempNameBuf[7] = "^e0000";
|
||||
EnumIdentifier = PlatformMakeTempName(TempNameBuf);
|
||||
}
|
||||
EnumType = TypeGetMatching(Parser, &UberType, TypeEnum, 0, EnumIdentifier, Token != TokenLeftBrace);
|
||||
EnumType = TypeGetMatching(_parser, &UberType, TypeEnum, 0, EnumIdentifier, Token != TokenLeftBrace);
|
||||
*Typ = &IntType;
|
||||
if (Token != TokenLeftBrace) {
|
||||
/* use the already defined enum */
|
||||
if ((*Typ)->Members == NULL) {
|
||||
ProgramFail(Parser, "enum '%s' isn't defined", EnumIdentifier);
|
||||
ProgramFail(_parser, "enum '%s' isn't defined", EnumIdentifier);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (TopStackFrame != NULL) {
|
||||
ProgramFail(Parser, "enum definitions can only be globals");
|
||||
ProgramFail(_parser, "enum definitions can only be globals");
|
||||
}
|
||||
LexGetToken(Parser, NULL, TRUE);
|
||||
LexGetToken(_parser, NULL, TRUE);
|
||||
(*Typ)->Members = &GlobalTable;
|
||||
memset((void *)&InitValue, '\0', sizeof(struct Value));
|
||||
InitValue.Typ = &IntType;
|
||||
InitValue.Val = (union AnyValue *)&EnumValue;
|
||||
do {
|
||||
if (LexGetToken(Parser, &LexValue, TRUE) != TokenIdentifier) {
|
||||
ProgramFail(Parser, "identifier expected");
|
||||
if (LexGetToken(_parser, &LexValue, TRUE) != TokenIdentifier) {
|
||||
ProgramFail(_parser, "identifier expected");
|
||||
}
|
||||
EnumIdentifier = LexValue->Val->Identifier;
|
||||
if (LexGetToken(Parser, NULL, FALSE) == TokenAssign) {
|
||||
LexGetToken(Parser, NULL, TRUE);
|
||||
EnumValue = ExpressionParseInt(Parser);
|
||||
if (LexGetToken(_parser, NULL, FALSE) == TokenAssign) {
|
||||
LexGetToken(_parser, NULL, TRUE);
|
||||
EnumValue = ExpressionParseInt(_parser);
|
||||
}
|
||||
VariableDefine(Parser, EnumIdentifier, &InitValue, NULL, FALSE);
|
||||
VariableDefine(_parser, EnumIdentifier, &InitValue, NULL, FALSE);
|
||||
|
||||
Token = LexGetToken(Parser, NULL, TRUE);
|
||||
Token = LexGetToken(_parser, NULL, TRUE);
|
||||
if (Token != TokenComma && Token != TokenRightBrace) {
|
||||
ProgramFail(Parser, "comma expected");
|
||||
ProgramFail(_parser, "comma expected");
|
||||
}
|
||||
EnumValue++;
|
||||
} while (Token == TokenComma);
|
||||
}
|
||||
|
||||
/* parse a type - just the basic type */
|
||||
int TypeParseFront(struct ParseState *Parser, struct ValueType **Typ, int *IsStatic) {
|
||||
int TypeParseFront(struct ParseState *_parser, struct ValueType **Typ, int *IsStatic) {
|
||||
struct ParseState Before;
|
||||
struct Value *LexerValue;
|
||||
enum LexToken Token;
|
||||
@ -360,8 +360,8 @@ int TypeParseFront(struct ParseState *Parser, struct ValueType **Typ, int *IsSta
|
||||
int StaticQualifier = FALSE;
|
||||
*Typ = NULL;
|
||||
/* ignore leading type qualifiers */
|
||||
ParserCopy(&Before, Parser);
|
||||
Token = LexGetToken(Parser, &LexerValue, TRUE);
|
||||
ParserCopy(&Before, _parser);
|
||||
Token = LexGetToken(_parser, &LexerValue, TRUE);
|
||||
while ( Token == TokenStaticType
|
||||
|| Token == TokenAutoType
|
||||
|| Token == TokenRegisterType
|
||||
@ -369,14 +369,14 @@ int TypeParseFront(struct ParseState *Parser, struct ValueType **Typ, int *IsSta
|
||||
if (Token == TokenStaticType) {
|
||||
StaticQualifier = TRUE;
|
||||
}
|
||||
Token = LexGetToken(Parser, &LexerValue, TRUE);
|
||||
Token = LexGetToken(_parser, &LexerValue, TRUE);
|
||||
}
|
||||
if (IsStatic != NULL) {
|
||||
*IsStatic = StaticQualifier;
|
||||
}
|
||||
/* handle signed/unsigned with no trailing type */
|
||||
if (Token == TokenSignedType || Token == TokenUnsignedType) {
|
||||
enum LexToken FollowToken = LexGetToken(Parser, &LexerValue, FALSE);
|
||||
enum LexToken FollowToken = LexGetToken(_parser, &LexerValue, FALSE);
|
||||
Unsigned = (Token == TokenUnsignedType);
|
||||
if ( FollowToken != TokenIntType
|
||||
&& FollowToken != TokenLongType
|
||||
@ -389,7 +389,7 @@ int TypeParseFront(struct ParseState *Parser, struct ValueType **Typ, int *IsSta
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
Token = LexGetToken(Parser, &LexerValue, TRUE);
|
||||
Token = LexGetToken(_parser, &LexerValue, TRUE);
|
||||
}
|
||||
switch (Token) {
|
||||
case TokenIntType:
|
||||
@ -414,54 +414,54 @@ int TypeParseFront(struct ParseState *Parser, struct ValueType **Typ, int *IsSta
|
||||
case TokenStructType:
|
||||
case TokenUnionType:
|
||||
if (*Typ != NULL) {
|
||||
ProgramFail(Parser, "bad type declaration");
|
||||
ProgramFail(_parser, "bad type declaration");
|
||||
}
|
||||
TypeParseStruct(Parser, Typ, Token == TokenStructType);
|
||||
TypeParseStruct(_parser, Typ, Token == TokenStructType);
|
||||
break;
|
||||
case TokenEnumType:
|
||||
if (*Typ != NULL) {
|
||||
ProgramFail(Parser, "bad type declaration");
|
||||
ProgramFail(_parser, "bad type declaration");
|
||||
}
|
||||
TypeParseEnum(Parser, Typ);
|
||||
TypeParseEnum(_parser, Typ);
|
||||
break;
|
||||
case TokenIdentifier:
|
||||
/* we already know it's a typedef-defined type because we got here */
|
||||
VariableGet(Parser, LexerValue->Val->Identifier, &VarValue);
|
||||
VariableGet(_parser, LexerValue->Val->Identifier, &VarValue);
|
||||
*Typ = VarValue->Val->Typ;
|
||||
break;
|
||||
default:
|
||||
ParserCopy(Parser, &Before);
|
||||
ParserCopy(_parser, &Before);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* parse a type - the part at the end after the identifier. eg. array specifications etc. */
|
||||
struct ValueType *TypeParseBack(struct ParseState *Parser, struct ValueType *FromType) {
|
||||
struct ValueType *TypeParseBack(struct ParseState *_parser, struct ValueType *FromType) {
|
||||
enum LexToken Token;
|
||||
struct ParseState Before;
|
||||
ParserCopy(&Before, Parser);
|
||||
Token = LexGetToken(Parser, NULL, TRUE);
|
||||
ParserCopy(&Before, _parser);
|
||||
Token = LexGetToken(_parser, NULL, TRUE);
|
||||
if (Token == TokenLeftSquareBracket) {
|
||||
/* add another array bound */
|
||||
enum RunMode OldMode = Parser->Mode;
|
||||
enum RunMode OldMode = _parser->Mode;
|
||||
int ArraySize;
|
||||
Parser->Mode = RunModeRun;
|
||||
ArraySize = ExpressionParseInt(Parser);
|
||||
Parser->Mode = OldMode;
|
||||
if (LexGetToken(Parser, NULL, TRUE) != TokenRightSquareBracket) {
|
||||
ProgramFail(Parser, "']' expected");
|
||||
_parser->Mode = RunModeRun;
|
||||
ArraySize = ExpressionParseInt(_parser);
|
||||
_parser->Mode = OldMode;
|
||||
if (LexGetToken(_parser, NULL, TRUE) != TokenRightSquareBracket) {
|
||||
ProgramFail(_parser, "']' expected");
|
||||
}
|
||||
return TypeGetMatching(Parser, TypeParseBack(Parser, FromType), TypeArray, ArraySize, StrEmpty, TRUE);
|
||||
return TypeGetMatching(_parser, TypeParseBack(_parser, FromType), TypeArray, ArraySize, StrEmpty, TRUE);
|
||||
} else {
|
||||
/* the type specification has finished */
|
||||
ParserCopy(Parser, &Before);
|
||||
ParserCopy(_parser, &Before);
|
||||
return FromType;
|
||||
}
|
||||
}
|
||||
|
||||
/* parse a type - the part which is repeated with each identifier in a declaration list */
|
||||
void TypeParseIdentPart(struct ParseState *Parser, struct ValueType *BasicTyp, struct ValueType **Typ, char **Identifier) {
|
||||
void TypeParseIdentPart(struct ParseState *_parser, struct ValueType *BasicTyp, struct ValueType **Typ, char **Identifier) {
|
||||
struct ParseState Before;
|
||||
enum LexToken Token;
|
||||
struct Value *LexValue;
|
||||
@ -469,51 +469,51 @@ void TypeParseIdentPart(struct ParseState *Parser, struct ValueType *BasicTyp, s
|
||||
*Typ = BasicTyp;
|
||||
*Identifier = StrEmpty;
|
||||
while (!Done) {
|
||||
ParserCopy(&Before, Parser);
|
||||
Token = LexGetToken(Parser, &LexValue, TRUE);
|
||||
ParserCopy(&Before, _parser);
|
||||
Token = LexGetToken(_parser, &LexValue, TRUE);
|
||||
switch (Token) {
|
||||
case TokenOpenBracket:
|
||||
if (*Typ != NULL) {
|
||||
ProgramFail(Parser, "bad type declaration");
|
||||
ProgramFail(_parser, "bad type declaration");
|
||||
}
|
||||
TypeParse(Parser, Typ, Identifier, NULL);
|
||||
if (LexGetToken(Parser, NULL, TRUE) != TokenCloseBracket) {
|
||||
ProgramFail(Parser, "')' expected");
|
||||
TypeParse(_parser, Typ, Identifier, NULL);
|
||||
if (LexGetToken(_parser, NULL, TRUE) != TokenCloseBracket) {
|
||||
ProgramFail(_parser, "')' expected");
|
||||
}
|
||||
break;
|
||||
case TokenAsterisk:
|
||||
if (*Typ == NULL) {
|
||||
ProgramFail(Parser, "bad type declaration");
|
||||
ProgramFail(_parser, "bad type declaration");
|
||||
}
|
||||
*Typ = TypeGetMatching(Parser, *Typ, TypePointer, 0, StrEmpty, TRUE);
|
||||
*Typ = TypeGetMatching(_parser, *Typ, TypePointer, 0, StrEmpty, TRUE);
|
||||
break;
|
||||
case TokenIdentifier:
|
||||
if ( *Typ == NULL
|
||||
|| *Identifier != StrEmpty) {
|
||||
ProgramFail(Parser, "bad type declaration");
|
||||
ProgramFail(_parser, "bad type declaration");
|
||||
}
|
||||
*Identifier = LexValue->Val->Identifier;
|
||||
Done = TRUE;
|
||||
break;
|
||||
default:
|
||||
ParserCopy(Parser, &Before);
|
||||
ParserCopy(_parser, &Before);
|
||||
Done = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (*Typ == NULL) {
|
||||
ProgramFail(Parser, "bad type declaration");
|
||||
ProgramFail(_parser, "bad type declaration");
|
||||
}
|
||||
if (*Identifier != StrEmpty) {
|
||||
/* parse stuff after the identifier */
|
||||
*Typ = TypeParseBack(Parser, *Typ);
|
||||
*Typ = TypeParseBack(_parser, *Typ);
|
||||
}
|
||||
}
|
||||
|
||||
/* parse a type - a complete declaration including identifier */
|
||||
void TypeParse(struct ParseState *Parser, struct ValueType **Typ, char **Identifier, int *IsStatic) {
|
||||
void TypeParse(struct ParseState *_parser, struct ValueType **Typ, char **Identifier, int *IsStatic) {
|
||||
struct ValueType *BasicType;
|
||||
TypeParseFront(Parser, &BasicType, IsStatic);
|
||||
TypeParseIdentPart(Parser, BasicType, Typ, Identifier);
|
||||
TypeParseFront(_parser, &BasicType, IsStatic);
|
||||
TypeParseIdentPart(_parser, BasicType, Typ, Identifier);
|
||||
}
|
||||
|
||||
|
24
eci/type.h
Normal file
24
eci/type.h
Normal file
@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ECI_TYPE_H__
|
||||
#define __ECI_TYPE_H__
|
||||
|
||||
void TypeInit();
|
||||
void TypeCleanup();
|
||||
int TypeSize(struct ValueType *_type, int _arraySize, int _compact);
|
||||
int TypeSizeValue(struct Value *_value, int _compact);
|
||||
int TypeStackSizeValue(struct Value *_value);
|
||||
int TypeLastAccessibleOffset(struct Value *_value);
|
||||
int TypeParseFront(struct ParseState *_parser, struct ValueType **_type, int *_isStatic);
|
||||
void TypeParseIdentPart(struct ParseState *_parser, struct ValueType *_basicTyp, struct ValueType **_type, char **_identifier);
|
||||
void TypeParse(struct ParseState *_parser, struct ValueType **_type, char **_identifier, int *_isStatic);
|
||||
struct ValueType *TypeGetMatching(struct ParseState *_parser, struct ValueType *_parentType, enum BaseType _base, int _arraySize, const char *_identifier, int _allowDuplicates);
|
||||
struct ValueType *TypeCreateOpaqueStruct(struct ParseState *_parser, const char *_structName, int _size);
|
||||
|
||||
#endif
|
35
eci/variable.h
Normal file
35
eci/variable.h
Normal file
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ECI_VARIABLE_H__
|
||||
#define __ECI_VARIABLE_H__
|
||||
|
||||
|
||||
void VariableInit();
|
||||
void VariableCleanup();
|
||||
void VariableFree(struct Value* _value);
|
||||
void VariableTableCleanup(struct Table* _hashTable);
|
||||
void *VariableAlloc(struct ParseState* _parser, int _size, int _onHeap);
|
||||
void VariableStackPop(struct ParseState *_parser, struct Value *_value);
|
||||
struct Value *VariableAllocValueAndData(struct ParseState* _parser, int _dataSize, int _isLValue, struct Value *_lValueFrom, int _onHeap);
|
||||
struct Value *VariableAllocValueAndCopy(struct ParseState* _parser, struct Value *_fromValue, int _onHeap);
|
||||
struct Value *VariableAllocValueFromType(struct ParseState *_parser, struct ValueType *_type, int _isLValue, struct Value *_lValueFrom, int _onHeap);
|
||||
struct Value *VariableAllocValueFromExistingData(struct ParseState *_parser, struct ValueType *_type, union AnyValue *_fromValue, int _isLValue, struct Value *_lValueFrom);
|
||||
struct Value *VariableAllocValueShared(struct ParseState *_parser, struct Value *_fromValue);
|
||||
struct Value *VariableDefine(struct ParseState *_parser, char *_ident, struct Value *_initValue, struct ValueType *_type, int _makeWritable);
|
||||
struct Value *VariableDefineButIgnoreIdentical(struct ParseState *_parser, char *_ident, struct ValueType *_type, int _isStatic, int *_firstVisit);
|
||||
int VariableDefined(const char *Ident);
|
||||
void VariableGet(struct ParseState *_parser, const char *_ident, struct Value **_lVal);
|
||||
void VariableDefinePlatformVar(struct ParseState *_parser, char *_ident, struct ValueType *_type, union AnyValue *_fromValue, int _isWritable);
|
||||
void VariableStackFrameAdd(struct ParseState *_parser, const char *_funcName, int _numParams);
|
||||
void VariableStackFramePop(struct ParseState *_parser);
|
||||
struct Value *VariableStringLiteralGet(char *_ident);
|
||||
void VariableStringLiteralDefine(char *_ident, struct Value *_value);
|
||||
void *VariableDereferencePointer(struct ParseState *_parser, struct Value *_pointerValue, struct Value **_dereferenceVal, int *_dereferenceOffset, struct ValueType **_dereferenceType, int *_derefIsLValue);
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user