use stdbool.h and convert TRUE/FALSE to true/false
This commit is contained in:
parent
24e1166a55
commit
9293ed0443
|
@ -16,14 +16,14 @@ void LibraryInit(Picoc *pc)
|
|||
|
||||
/* define the version number macro */
|
||||
pc->VersionString = TableStrRegister(pc, PICOC_VERSION);
|
||||
VariableDefinePlatformVar(pc, NULL, "PICOC_VERSION", pc->CharPtrType, (union AnyValue *)&pc->VersionString, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "PICOC_VERSION", pc->CharPtrType, (union AnyValue *)&pc->VersionString, false);
|
||||
|
||||
/* define endian-ness macros */
|
||||
BigEndian = ((*(char*)&__ENDIAN_CHECK__) == 0);
|
||||
LittleEndian = ((*(char*)&__ENDIAN_CHECK__) == 1);
|
||||
|
||||
VariableDefinePlatformVar(pc, NULL, "BIG_ENDIAN", &pc->IntType, (union AnyValue *)&BigEndian, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "LITTLE_ENDIAN", &pc->IntType, (union AnyValue *)&LittleEndian, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "BIG_ENDIAN", &pc->IntType, (union AnyValue *)&BigEndian, false);
|
||||
VariableDefinePlatformVar(pc, NULL, "LITTLE_ENDIAN", &pc->IntType, (union AnyValue *)&LittleEndian, false);
|
||||
}
|
||||
|
||||
/* add a library */
|
||||
|
@ -40,7 +40,7 @@ void LibraryAdd(Picoc *pc, struct Table *GlobalTable, struct LibraryFunction *Fu
|
|||
/* read all the library definitions */
|
||||
for (Count = 0; FuncList[Count].Prototype != NULL; Count++) {
|
||||
Tokens = LexAnalyse(pc, (const char*)IntrinsicName, FuncList[Count].Prototype, strlen((char*)FuncList[Count].Prototype), NULL);
|
||||
LexInitParser(&Parser, pc, FuncList[Count].Prototype, Tokens, IntrinsicName, TRUE, FALSE);
|
||||
LexInitParser(&Parser, pc, FuncList[Count].Prototype, Tokens, IntrinsicName, true, false);
|
||||
TypeParse(&Parser, &ReturnType, &Identifier, NULL);
|
||||
NewValue = ParseFunctionDefinition(&Parser, ReturnType, Identifier);
|
||||
NewValue->Val->FuncDef.Intrinsic = FuncList[Count].Func;
|
||||
|
|
162
cstdlib/errno.c
162
cstdlib/errno.c
|
@ -329,325 +329,325 @@ void StdErrnoSetupFunc(Picoc *pc)
|
|||
{
|
||||
/* defines */
|
||||
#ifdef EACCES
|
||||
VariableDefinePlatformVar(pc, NULL, "EACCES", &pc->IntType, (union AnyValue *)&EACCESValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EACCES", &pc->IntType, (union AnyValue *)&EACCESValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EADDRINUSE
|
||||
VariableDefinePlatformVar(pc, NULL, "EADDRINUSE", &pc->IntType, (union AnyValue *)&EADDRINUSEValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EADDRINUSE", &pc->IntType, (union AnyValue *)&EADDRINUSEValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EADDRNOTAVAIL
|
||||
VariableDefinePlatformVar(pc, NULL, "EADDRNOTAVAIL", &pc->IntType, (union AnyValue *)&EADDRNOTAVAILValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EADDRNOTAVAIL", &pc->IntType, (union AnyValue *)&EADDRNOTAVAILValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EAFNOSUPPORT
|
||||
VariableDefinePlatformVar(pc, NULL, "EAFNOSUPPORT", &pc->IntType, (union AnyValue *)&EAFNOSUPPORTValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EAFNOSUPPORT", &pc->IntType, (union AnyValue *)&EAFNOSUPPORTValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EAGAIN
|
||||
VariableDefinePlatformVar(pc, NULL, "EAGAIN", &pc->IntType, (union AnyValue *)&EAGAINValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EAGAIN", &pc->IntType, (union AnyValue *)&EAGAINValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EALREADY
|
||||
VariableDefinePlatformVar(pc, NULL, "EALREADY", &pc->IntType, (union AnyValue *)&EALREADYValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EALREADY", &pc->IntType, (union AnyValue *)&EALREADYValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EBADF
|
||||
VariableDefinePlatformVar(pc, NULL, "EBADF", &pc->IntType, (union AnyValue *)&EBADFValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EBADF", &pc->IntType, (union AnyValue *)&EBADFValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EBADMSG
|
||||
VariableDefinePlatformVar(pc, NULL, "EBADMSG", &pc->IntType, (union AnyValue *)&EBADMSGValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EBADMSG", &pc->IntType, (union AnyValue *)&EBADMSGValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EBUSY
|
||||
VariableDefinePlatformVar(pc, NULL, "EBUSY", &pc->IntType, (union AnyValue *)&EBUSYValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EBUSY", &pc->IntType, (union AnyValue *)&EBUSYValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ECANCELED
|
||||
VariableDefinePlatformVar(pc, NULL, "ECANCELED", &pc->IntType, (union AnyValue *)&ECANCELEDValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ECANCELED", &pc->IntType, (union AnyValue *)&ECANCELEDValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ECHILD
|
||||
VariableDefinePlatformVar(pc, NULL, "ECHILD", &pc->IntType, (union AnyValue *)&ECHILDValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ECHILD", &pc->IntType, (union AnyValue *)&ECHILDValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ECONNABORTED
|
||||
VariableDefinePlatformVar(pc, NULL, "ECONNABORTED", &pc->IntType, (union AnyValue *)&ECONNABORTEDValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ECONNABORTED", &pc->IntType, (union AnyValue *)&ECONNABORTEDValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ECONNREFUSED
|
||||
VariableDefinePlatformVar(pc, NULL, "ECONNREFUSED", &pc->IntType, (union AnyValue *)&ECONNREFUSEDValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ECONNREFUSED", &pc->IntType, (union AnyValue *)&ECONNREFUSEDValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ECONNRESET
|
||||
VariableDefinePlatformVar(pc, NULL, "ECONNRESET", &pc->IntType, (union AnyValue *)&ECONNRESETValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ECONNRESET", &pc->IntType, (union AnyValue *)&ECONNRESETValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EDEADLK
|
||||
VariableDefinePlatformVar(pc, NULL, "EDEADLK", &pc->IntType, (union AnyValue *)&EDEADLKValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EDEADLK", &pc->IntType, (union AnyValue *)&EDEADLKValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EDESTADDRREQ
|
||||
VariableDefinePlatformVar(pc, NULL, "EDESTADDRREQ", &pc->IntType, (union AnyValue *)&EDESTADDRREQValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EDESTADDRREQ", &pc->IntType, (union AnyValue *)&EDESTADDRREQValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EDOM
|
||||
VariableDefinePlatformVar(pc, NULL, "EDOM", &pc->IntType, (union AnyValue *)&EDOMValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EDOM", &pc->IntType, (union AnyValue *)&EDOMValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EDQUOT
|
||||
VariableDefinePlatformVar(pc, NULL, "EDQUOT", &pc->IntType, (union AnyValue *)&EDQUOTValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EDQUOT", &pc->IntType, (union AnyValue *)&EDQUOTValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EEXIST
|
||||
VariableDefinePlatformVar(pc, NULL, "EEXIST", &pc->IntType, (union AnyValue *)&EEXISTValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EEXIST", &pc->IntType, (union AnyValue *)&EEXISTValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EFAULT
|
||||
VariableDefinePlatformVar(pc, NULL, "EFAULT", &pc->IntType, (union AnyValue *)&EFAULTValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EFAULT", &pc->IntType, (union AnyValue *)&EFAULTValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EFBIG
|
||||
VariableDefinePlatformVar(pc, NULL, "EFBIG", &pc->IntType, (union AnyValue *)&EFBIGValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EFBIG", &pc->IntType, (union AnyValue *)&EFBIGValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EHOSTUNREACH
|
||||
VariableDefinePlatformVar(pc, NULL, "EHOSTUNREACH", &pc->IntType, (union AnyValue *)&EHOSTUNREACHValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EHOSTUNREACH", &pc->IntType, (union AnyValue *)&EHOSTUNREACHValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EIDRM
|
||||
VariableDefinePlatformVar(pc, NULL, "EIDRM", &pc->IntType, (union AnyValue *)&EIDRMValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EIDRM", &pc->IntType, (union AnyValue *)&EIDRMValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EILSEQ
|
||||
VariableDefinePlatformVar(pc, NULL, "EILSEQ", &pc->IntType, (union AnyValue *)&EILSEQValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EILSEQ", &pc->IntType, (union AnyValue *)&EILSEQValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EINPROGRESS
|
||||
VariableDefinePlatformVar(pc, NULL, "EINPROGRESS", &pc->IntType, (union AnyValue *)&EINPROGRESSValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EINPROGRESS", &pc->IntType, (union AnyValue *)&EINPROGRESSValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EINTR
|
||||
VariableDefinePlatformVar(pc, NULL, "EINTR", &pc->IntType, (union AnyValue *)&EINTRValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EINTR", &pc->IntType, (union AnyValue *)&EINTRValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EINVAL
|
||||
VariableDefinePlatformVar(pc, NULL, "EINVAL", &pc->IntType, (union AnyValue *)&EINVALValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EINVAL", &pc->IntType, (union AnyValue *)&EINVALValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EIO
|
||||
VariableDefinePlatformVar(pc, NULL, "EIO", &pc->IntType, (union AnyValue *)&EIOValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EIO", &pc->IntType, (union AnyValue *)&EIOValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EISCONN
|
||||
VariableDefinePlatformVar(pc, NULL, "EISCONN", &pc->IntType, (union AnyValue *)&EISCONNValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EISCONN", &pc->IntType, (union AnyValue *)&EISCONNValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EISDIR
|
||||
VariableDefinePlatformVar(pc, NULL, "EISDIR", &pc->IntType, (union AnyValue *)&EISDIRValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EISDIR", &pc->IntType, (union AnyValue *)&EISDIRValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ELOOP
|
||||
VariableDefinePlatformVar(pc, NULL, "ELOOP", &pc->IntType, (union AnyValue *)&ELOOPValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ELOOP", &pc->IntType, (union AnyValue *)&ELOOPValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EMFILE
|
||||
VariableDefinePlatformVar(pc, NULL, "EMFILE", &pc->IntType, (union AnyValue *)&EMFILEValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EMFILE", &pc->IntType, (union AnyValue *)&EMFILEValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EMLINK
|
||||
VariableDefinePlatformVar(pc, NULL, "EMLINK", &pc->IntType, (union AnyValue *)&EMLINKValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EMLINK", &pc->IntType, (union AnyValue *)&EMLINKValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EMSGSIZE
|
||||
VariableDefinePlatformVar(pc, NULL, "EMSGSIZE", &pc->IntType, (union AnyValue *)&EMSGSIZEValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EMSGSIZE", &pc->IntType, (union AnyValue *)&EMSGSIZEValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EMULTIHOP
|
||||
VariableDefinePlatformVar(pc, NULL, "EMULTIHOP", &pc->IntType, (union AnyValue *)&EMULTIHOPValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EMULTIHOP", &pc->IntType, (union AnyValue *)&EMULTIHOPValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ENAMETOOLONG
|
||||
VariableDefinePlatformVar(pc, NULL, "ENAMETOOLONG", &pc->IntType, (union AnyValue *)&ENAMETOOLONGValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ENAMETOOLONG", &pc->IntType, (union AnyValue *)&ENAMETOOLONGValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ENETDOWN
|
||||
VariableDefinePlatformVar(pc, NULL, "ENETDOWN", &pc->IntType, (union AnyValue *)&ENETDOWNValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ENETDOWN", &pc->IntType, (union AnyValue *)&ENETDOWNValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ENETRESET
|
||||
VariableDefinePlatformVar(pc, NULL, "ENETRESET", &pc->IntType, (union AnyValue *)&ENETRESETValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ENETRESET", &pc->IntType, (union AnyValue *)&ENETRESETValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ENETUNREACH
|
||||
VariableDefinePlatformVar(pc, NULL, "ENETUNREACH", &pc->IntType, (union AnyValue *)&ENETUNREACHValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ENETUNREACH", &pc->IntType, (union AnyValue *)&ENETUNREACHValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ENFILE
|
||||
VariableDefinePlatformVar(pc, NULL, "ENFILE", &pc->IntType, (union AnyValue *)&ENFILEValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ENFILE", &pc->IntType, (union AnyValue *)&ENFILEValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ENOBUFS
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOBUFS", &pc->IntType, (union AnyValue *)&ENOBUFSValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOBUFS", &pc->IntType, (union AnyValue *)&ENOBUFSValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ENODATA
|
||||
VariableDefinePlatformVar(pc, NULL, "ENODATA", &pc->IntType, (union AnyValue *)&ENODATAValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ENODATA", &pc->IntType, (union AnyValue *)&ENODATAValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ENODEV
|
||||
VariableDefinePlatformVar(pc, NULL, "ENODEV", &pc->IntType, (union AnyValue *)&ENODEVValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ENODEV", &pc->IntType, (union AnyValue *)&ENODEVValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ENOENT
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOENT", &pc->IntType, (union AnyValue *)&ENOENTValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOENT", &pc->IntType, (union AnyValue *)&ENOENTValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ENOEXEC
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOEXEC", &pc->IntType, (union AnyValue *)&ENOEXECValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOEXEC", &pc->IntType, (union AnyValue *)&ENOEXECValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ENOLCK
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOLCK", &pc->IntType, (union AnyValue *)&ENOLCKValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOLCK", &pc->IntType, (union AnyValue *)&ENOLCKValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ENOLINK
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOLINK", &pc->IntType, (union AnyValue *)&ENOLINKValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOLINK", &pc->IntType, (union AnyValue *)&ENOLINKValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ENOMEM
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOMEM", &pc->IntType, (union AnyValue *)&ENOMEMValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOMEM", &pc->IntType, (union AnyValue *)&ENOMEMValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ENOMSG
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOMSG", &pc->IntType, (union AnyValue *)&ENOMSGValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOMSG", &pc->IntType, (union AnyValue *)&ENOMSGValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ENOPROTOOPT
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOPROTOOPT", &pc->IntType, (union AnyValue *)&ENOPROTOOPTValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOPROTOOPT", &pc->IntType, (union AnyValue *)&ENOPROTOOPTValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ENOSPC
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOSPC", &pc->IntType, (union AnyValue *)&ENOSPCValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOSPC", &pc->IntType, (union AnyValue *)&ENOSPCValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ENOSR
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOSR", &pc->IntType, (union AnyValue *)&ENOSRValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOSR", &pc->IntType, (union AnyValue *)&ENOSRValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ENOSTR
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOSTR", &pc->IntType, (union AnyValue *)&ENOSTRValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOSTR", &pc->IntType, (union AnyValue *)&ENOSTRValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ENOSYS
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOSYS", &pc->IntType, (union AnyValue *)&ENOSYSValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOSYS", &pc->IntType, (union AnyValue *)&ENOSYSValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ENOTCONN
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOTCONN", &pc->IntType, (union AnyValue *)&ENOTCONNValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOTCONN", &pc->IntType, (union AnyValue *)&ENOTCONNValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ENOTDIR
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOTDIR", &pc->IntType, (union AnyValue *)&ENOTDIRValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOTDIR", &pc->IntType, (union AnyValue *)&ENOTDIRValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ENOTEMPTY
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOTEMPTY", &pc->IntType, (union AnyValue *)&ENOTEMPTYValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOTEMPTY", &pc->IntType, (union AnyValue *)&ENOTEMPTYValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ENOTRECOVERABLE
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOTRECOVERABLE", &pc->IntType, (union AnyValue *)&ENOTRECOVERABLEValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOTRECOVERABLE", &pc->IntType, (union AnyValue *)&ENOTRECOVERABLEValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ENOTSOCK
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOTSOCK", &pc->IntType, (union AnyValue *)&ENOTSOCKValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOTSOCK", &pc->IntType, (union AnyValue *)&ENOTSOCKValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ENOTSUP
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOTSUP", &pc->IntType, (union AnyValue *)&ENOTSUPValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOTSUP", &pc->IntType, (union AnyValue *)&ENOTSUPValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ENOTTY
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOTTY", &pc->IntType, (union AnyValue *)&ENOTTYValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ENOTTY", &pc->IntType, (union AnyValue *)&ENOTTYValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ENXIO
|
||||
VariableDefinePlatformVar(pc, NULL, "ENXIO", &pc->IntType, (union AnyValue *)&ENXIOValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ENXIO", &pc->IntType, (union AnyValue *)&ENXIOValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EOPNOTSUPP
|
||||
VariableDefinePlatformVar(pc, NULL, "EOPNOTSUPP", &pc->IntType, (union AnyValue *)&EOPNOTSUPPValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EOPNOTSUPP", &pc->IntType, (union AnyValue *)&EOPNOTSUPPValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EOVERFLOW
|
||||
VariableDefinePlatformVar(pc, NULL, "EOVERFLOW", &pc->IntType, (union AnyValue *)&EOVERFLOWValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EOVERFLOW", &pc->IntType, (union AnyValue *)&EOVERFLOWValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EOWNERDEAD
|
||||
VariableDefinePlatformVar(pc, NULL, "EOWNERDEAD", &pc->IntType, (union AnyValue *)&EOWNERDEADValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EOWNERDEAD", &pc->IntType, (union AnyValue *)&EOWNERDEADValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EPERM
|
||||
VariableDefinePlatformVar(pc, NULL, "EPERM", &pc->IntType, (union AnyValue *)&EPERMValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EPERM", &pc->IntType, (union AnyValue *)&EPERMValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EPIPE
|
||||
VariableDefinePlatformVar(pc, NULL, "EPIPE", &pc->IntType, (union AnyValue *)&EPIPEValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EPIPE", &pc->IntType, (union AnyValue *)&EPIPEValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EPROTO
|
||||
VariableDefinePlatformVar(pc, NULL, "EPROTO", &pc->IntType, (union AnyValue *)&EPROTOValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EPROTO", &pc->IntType, (union AnyValue *)&EPROTOValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EPROTONOSUPPORT
|
||||
VariableDefinePlatformVar(pc, NULL, "EPROTONOSUPPORT", &pc->IntType, (union AnyValue *)&EPROTONOSUPPORTValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EPROTONOSUPPORT", &pc->IntType, (union AnyValue *)&EPROTONOSUPPORTValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EPROTOTYPE
|
||||
VariableDefinePlatformVar(pc, NULL, "EPROTOTYPE", &pc->IntType, (union AnyValue *)&EPROTOTYPEValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EPROTOTYPE", &pc->IntType, (union AnyValue *)&EPROTOTYPEValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ERANGE
|
||||
VariableDefinePlatformVar(pc, NULL, "ERANGE", &pc->IntType, (union AnyValue *)&ERANGEValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ERANGE", &pc->IntType, (union AnyValue *)&ERANGEValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EROFS
|
||||
VariableDefinePlatformVar(pc, NULL, "EROFS", &pc->IntType, (union AnyValue *)&EROFSValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EROFS", &pc->IntType, (union AnyValue *)&EROFSValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ESPIPE
|
||||
VariableDefinePlatformVar(pc, NULL, "ESPIPE", &pc->IntType, (union AnyValue *)&ESPIPEValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ESPIPE", &pc->IntType, (union AnyValue *)&ESPIPEValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ESRCH
|
||||
VariableDefinePlatformVar(pc, NULL, "ESRCH", &pc->IntType, (union AnyValue *)&ESRCHValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ESRCH", &pc->IntType, (union AnyValue *)&ESRCHValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ESTALE
|
||||
VariableDefinePlatformVar(pc, NULL, "ESTALE", &pc->IntType, (union AnyValue *)&ESTALEValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ESTALE", &pc->IntType, (union AnyValue *)&ESTALEValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ETIME
|
||||
VariableDefinePlatformVar(pc, NULL, "ETIME", &pc->IntType, (union AnyValue *)&ETIMEValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ETIME", &pc->IntType, (union AnyValue *)&ETIMEValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ETIMEDOUT
|
||||
VariableDefinePlatformVar(pc, NULL, "ETIMEDOUT", &pc->IntType, (union AnyValue *)&ETIMEDOUTValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ETIMEDOUT", &pc->IntType, (union AnyValue *)&ETIMEDOUTValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef ETXTBSY
|
||||
VariableDefinePlatformVar(pc, NULL, "ETXTBSY", &pc->IntType, (union AnyValue *)&ETXTBSYValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "ETXTBSY", &pc->IntType, (union AnyValue *)&ETXTBSYValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EWOULDBLOCK
|
||||
VariableDefinePlatformVar(pc, NULL, "EWOULDBLOCK", &pc->IntType, (union AnyValue *)&EWOULDBLOCKValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EWOULDBLOCK", &pc->IntType, (union AnyValue *)&EWOULDBLOCKValue, false);
|
||||
#endif
|
||||
|
||||
#ifdef EXDEV
|
||||
VariableDefinePlatformVar(pc, NULL, "EXDEV", &pc->IntType, (union AnyValue *)&EXDEVValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EXDEV", &pc->IntType, (union AnyValue *)&EXDEVValue, false);
|
||||
#endif
|
||||
|
||||
VariableDefinePlatformVar(pc, NULL, "errno", &pc->IntType, (union AnyValue *)&errno, TRUE);
|
||||
VariableDefinePlatformVar(pc, NULL, "errno", &pc->IntType, (union AnyValue *)&errno, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -166,17 +166,17 @@ struct LibraryFunction MathFunctions[] =
|
|||
/* creates various system-dependent definitions */
|
||||
void MathSetupFunc(Picoc *pc)
|
||||
{
|
||||
VariableDefinePlatformVar(pc, NULL, "M_E", &pc->FPType, (union AnyValue *)&M_EValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "M_LOG2E", &pc->FPType, (union AnyValue *)&M_LOG2EValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "M_LOG10E", &pc->FPType, (union AnyValue *)&M_LOG10EValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "M_LN2", &pc->FPType, (union AnyValue *)&M_LN2Value, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "M_LN10", &pc->FPType, (union AnyValue *)&M_LN10Value, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "M_PI", &pc->FPType, (union AnyValue *)&M_PIValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "M_PI_2", &pc->FPType, (union AnyValue *)&M_PI_2Value, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "M_PI_4", &pc->FPType, (union AnyValue *)&M_PI_4Value, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "M_1_PI", &pc->FPType, (union AnyValue *)&M_1_PIValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "M_2_PI", &pc->FPType, (union AnyValue *)&M_2_PIValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "M_2_SQRTPI", &pc->FPType, (union AnyValue *)&M_2_SQRTPIValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "M_SQRT2", &pc->FPType, (union AnyValue *)&M_SQRT2Value, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "M_SQRT1_2", &pc->FPType, (union AnyValue *)&M_SQRT1_2Value, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "M_E", &pc->FPType, (union AnyValue *)&M_EValue, false);
|
||||
VariableDefinePlatformVar(pc, NULL, "M_LOG2E", &pc->FPType, (union AnyValue *)&M_LOG2EValue, false);
|
||||
VariableDefinePlatformVar(pc, NULL, "M_LOG10E", &pc->FPType, (union AnyValue *)&M_LOG10EValue, false);
|
||||
VariableDefinePlatformVar(pc, NULL, "M_LN2", &pc->FPType, (union AnyValue *)&M_LN2Value, false);
|
||||
VariableDefinePlatformVar(pc, NULL, "M_LN10", &pc->FPType, (union AnyValue *)&M_LN10Value, false);
|
||||
VariableDefinePlatformVar(pc, NULL, "M_PI", &pc->FPType, (union AnyValue *)&M_PIValue, false);
|
||||
VariableDefinePlatformVar(pc, NULL, "M_PI_2", &pc->FPType, (union AnyValue *)&M_PI_2Value, false);
|
||||
VariableDefinePlatformVar(pc, NULL, "M_PI_4", &pc->FPType, (union AnyValue *)&M_PI_4Value, false);
|
||||
VariableDefinePlatformVar(pc, NULL, "M_1_PI", &pc->FPType, (union AnyValue *)&M_1_PIValue, false);
|
||||
VariableDefinePlatformVar(pc, NULL, "M_2_PI", &pc->FPType, (union AnyValue *)&M_2_PIValue, false);
|
||||
VariableDefinePlatformVar(pc, NULL, "M_2_SQRTPI", &pc->FPType, (union AnyValue *)&M_2_SQRTPIValue, false);
|
||||
VariableDefinePlatformVar(pc, NULL, "M_SQRT2", &pc->FPType, (union AnyValue *)&M_SQRT2Value, false);
|
||||
VariableDefinePlatformVar(pc, NULL, "M_SQRT1_2", &pc->FPType, (union AnyValue *)&M_SQRT1_2Value, false);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ const char StdboolDefs[] = "typedef int bool;";
|
|||
void StdboolSetupFunc(Picoc *pc)
|
||||
{
|
||||
/* defines */
|
||||
VariableDefinePlatformVar(pc, NULL, "true", &pc->IntType, (union AnyValue *)&trueValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "false", &pc->IntType, (union AnyValue *)&falseValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "__bool_true_false_are_defined", &pc->IntType, (union AnyValue *)&trueValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "true", &pc->IntType, (union AnyValue *)&trueValue, false);
|
||||
VariableDefinePlatformVar(pc, NULL, "false", &pc->IntType, (union AnyValue *)&falseValue, false);
|
||||
VariableDefinePlatformVar(pc, NULL, "__bool_true_false_are_defined", &pc->IntType, (union AnyValue *)&trueValue, false);
|
||||
}
|
||||
|
|
|
@ -637,32 +637,32 @@ void StdioSetupFunc(Picoc *pc)
|
|||
StructFileType = TypeCreateOpaqueStruct(pc, NULL, TableStrRegister(pc, "__FILEStruct"), sizeof(FILE));
|
||||
|
||||
/* get a FILE * type */
|
||||
FilePtrType = TypeGetMatching(pc, NULL, StructFileType, TypePointer, 0, pc->StrEmpty, TRUE);
|
||||
FilePtrType = TypeGetMatching(pc, NULL, StructFileType, TypePointer, 0, pc->StrEmpty, true);
|
||||
|
||||
/* make a "struct __va_listStruct" which is the same size as our struct StdVararg */
|
||||
TypeCreateOpaqueStruct(pc, NULL, TableStrRegister(pc, "__va_listStruct"), sizeof(FILE));
|
||||
|
||||
/* define EOF equal to the system EOF */
|
||||
VariableDefinePlatformVar(pc, NULL, "EOF", &pc->IntType, (union AnyValue *)&EOFValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "SEEK_SET", &pc->IntType, (union AnyValue *)&SEEK_SETValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "SEEK_CUR", &pc->IntType, (union AnyValue *)&SEEK_CURValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "SEEK_END", &pc->IntType, (union AnyValue *)&SEEK_ENDValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "BUFSIZ", &pc->IntType, (union AnyValue *)&BUFSIZValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "FILENAME_MAX", &pc->IntType, (union AnyValue *)&FILENAME_MAXValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "_IOFBF", &pc->IntType, (union AnyValue *)&_IOFBFValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "_IOLBF", &pc->IntType, (union AnyValue *)&_IOLBFValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "_IONBF", &pc->IntType, (union AnyValue *)&_IONBFValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "L_tmpnam", &pc->IntType, (union AnyValue *)&L_tmpnamValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "GETS_MAX", &pc->IntType, (union AnyValue *)&GETS_MAXValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "EOF", &pc->IntType, (union AnyValue *)&EOFValue, false);
|
||||
VariableDefinePlatformVar(pc, NULL, "SEEK_SET", &pc->IntType, (union AnyValue *)&SEEK_SETValue, false);
|
||||
VariableDefinePlatformVar(pc, NULL, "SEEK_CUR", &pc->IntType, (union AnyValue *)&SEEK_CURValue, false);
|
||||
VariableDefinePlatformVar(pc, NULL, "SEEK_END", &pc->IntType, (union AnyValue *)&SEEK_ENDValue, false);
|
||||
VariableDefinePlatformVar(pc, NULL, "BUFSIZ", &pc->IntType, (union AnyValue *)&BUFSIZValue, false);
|
||||
VariableDefinePlatformVar(pc, NULL, "FILENAME_MAX", &pc->IntType, (union AnyValue *)&FILENAME_MAXValue, false);
|
||||
VariableDefinePlatformVar(pc, NULL, "_IOFBF", &pc->IntType, (union AnyValue *)&_IOFBFValue, false);
|
||||
VariableDefinePlatformVar(pc, NULL, "_IOLBF", &pc->IntType, (union AnyValue *)&_IOLBFValue, false);
|
||||
VariableDefinePlatformVar(pc, NULL, "_IONBF", &pc->IntType, (union AnyValue *)&_IONBFValue, false);
|
||||
VariableDefinePlatformVar(pc, NULL, "L_tmpnam", &pc->IntType, (union AnyValue *)&L_tmpnamValue, false);
|
||||
VariableDefinePlatformVar(pc, NULL, "GETS_MAX", &pc->IntType, (union AnyValue *)&GETS_MAXValue, false);
|
||||
|
||||
/* define stdin, stdout and stderr */
|
||||
VariableDefinePlatformVar(pc, NULL, "stdin", FilePtrType, (union AnyValue *)&stdinValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "stdout", FilePtrType, (union AnyValue *)&stdoutValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "stderr", FilePtrType, (union AnyValue *)&stderrValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "stdin", FilePtrType, (union AnyValue *)&stdinValue, false);
|
||||
VariableDefinePlatformVar(pc, NULL, "stdout", FilePtrType, (union AnyValue *)&stdoutValue, false);
|
||||
VariableDefinePlatformVar(pc, NULL, "stderr", FilePtrType, (union AnyValue *)&stderrValue, false);
|
||||
|
||||
/* define NULL, TRUE and FALSE */
|
||||
/* define NULL, true and false */
|
||||
if (!VariableDefined(pc, TableStrRegister(pc, "NULL")))
|
||||
VariableDefinePlatformVar(pc, NULL, "NULL", &pc->IntType, (union AnyValue *)&Stdio_ZeroValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "NULL", &pc->IntType, (union AnyValue *)&Stdio_ZeroValue, false);
|
||||
}
|
||||
|
||||
/* portability-related I/O calls */
|
||||
|
|
|
@ -162,6 +162,6 @@ void StdlibSetupFunc(Picoc *pc)
|
|||
{
|
||||
/* define NULL, TRUE and FALSE */
|
||||
if (!VariableDefined(pc, TableStrRegister(pc, "NULL")))
|
||||
VariableDefinePlatformVar(pc, NULL, "NULL", &pc->IntType, (union AnyValue *)&Stdlib_ZeroValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "NULL", &pc->IntType, (union AnyValue *)&Stdlib_ZeroValue, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -179,6 +179,6 @@ void StringSetupFunc(Picoc *pc)
|
|||
{
|
||||
/* define NULL */
|
||||
if (!VariableDefined(pc, TableStrRegister(pc, "NULL")))
|
||||
VariableDefinePlatformVar(pc, NULL, "NULL", &pc->IntType, (union AnyValue *)&String_ZeroValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "NULL", &pc->IntType, (union AnyValue *)&String_ZeroValue, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -111,12 +111,12 @@ void StdTimeSetupFunc(Picoc *pc)
|
|||
TypeCreateOpaqueStruct(pc, NULL, TableStrRegister(pc, "tm"), sizeof(struct tm));
|
||||
|
||||
/* define CLK_PER_SEC etc. */
|
||||
VariableDefinePlatformVar(pc, NULL, "CLOCKS_PER_SEC", &pc->IntType, (union AnyValue *)&CLOCKS_PER_SECValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "CLOCKS_PER_SEC", &pc->IntType, (union AnyValue *)&CLOCKS_PER_SECValue, false);
|
||||
#ifdef CLK_PER_SEC
|
||||
VariableDefinePlatformVar(pc, NULL, "CLK_PER_SEC", &pc->IntType, (union AnyValue *)&CLK_PER_SECValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "CLK_PER_SEC", &pc->IntType, (union AnyValue *)&CLK_PER_SECValue, false);
|
||||
#endif
|
||||
#ifdef CLK_TCK
|
||||
VariableDefinePlatformVar(pc, NULL, "CLK_TCK", &pc->IntType, (union AnyValue *)&CLK_TCKValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "CLK_TCK", &pc->IntType, (union AnyValue *)&CLK_TCKValue, false);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -493,12 +493,12 @@ void UnistdSetupFunc(Picoc *pc)
|
|||
{
|
||||
/* define NULL */
|
||||
if (!VariableDefined(pc, TableStrRegister(pc, "NULL")))
|
||||
VariableDefinePlatformVar(pc, NULL, "NULL", &pc->IntType, (union AnyValue *)&ZeroValue, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "NULL", &pc->IntType, (union AnyValue *)&ZeroValue, false);
|
||||
|
||||
/* define optarg and friends */
|
||||
VariableDefinePlatformVar(pc, NULL, "optarg", pc->CharPtrType, (union AnyValue *)&optarg, TRUE);
|
||||
VariableDefinePlatformVar(pc, NULL, "optind", &pc->IntType, (union AnyValue *)&optind, TRUE);
|
||||
VariableDefinePlatformVar(pc, NULL, "opterr", &pc->IntType, (union AnyValue *)&opterr, TRUE);
|
||||
VariableDefinePlatformVar(pc, NULL, "optopt", &pc->IntType, (union AnyValue *)&optopt, TRUE);
|
||||
VariableDefinePlatformVar(pc, NULL, "optarg", pc->CharPtrType, (union AnyValue *)&optarg, true);
|
||||
VariableDefinePlatformVar(pc, NULL, "optind", &pc->IntType, (union AnyValue *)&optind, true);
|
||||
VariableDefinePlatformVar(pc, NULL, "opterr", &pc->IntType, (union AnyValue *)&opterr, true);
|
||||
VariableDefinePlatformVar(pc, NULL, "optopt", &pc->IntType, (union AnyValue *)&optopt, true);
|
||||
}
|
||||
|
||||
|
|
16
debug.c
16
debug.c
|
@ -7,7 +7,7 @@
|
|||
/* initialise the debugger by clearing the breakpoint table */
|
||||
void DebugInit(Picoc *pc)
|
||||
{
|
||||
TableInitTable(&pc->BreakpointTable, &pc->BreakpointHashTable[0], BREAKPOINT_TABLE_SIZE, TRUE);
|
||||
TableInitTable(&pc->BreakpointTable, &pc->BreakpointHashTable[0], BREAKPOINT_TABLE_SIZE, true);
|
||||
pc->BreakpointCount = 0;
|
||||
}
|
||||
|
||||
|
@ -78,35 +78,35 @@ int DebugClearBreakpoint(struct ParseState *Parser)
|
|||
HeapFreeMem(pc, DeleteEntry);
|
||||
pc->BreakpointCount--;
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* before we run a statement, check if there's anything we have to do with the debugger here */
|
||||
void DebugCheckStatement(struct ParseState *Parser)
|
||||
{
|
||||
int DoBreak = FALSE;
|
||||
int DoBreak = false;
|
||||
int AddAt;
|
||||
Picoc *pc = Parser->pc;
|
||||
|
||||
/* has the user manually pressed break? */
|
||||
if (pc->DebugManualBreak) {
|
||||
PlatformPrintf(pc->CStdOut, "break\n");
|
||||
DoBreak = TRUE;
|
||||
pc->DebugManualBreak = FALSE;
|
||||
DoBreak = true;
|
||||
pc->DebugManualBreak = false;
|
||||
}
|
||||
|
||||
/* is this a breakpoint location? */
|
||||
if (Parser->pc->BreakpointCount != 0 && DebugTableSearchBreakpoint(Parser, &AddAt) != NULL)
|
||||
DoBreak = TRUE;
|
||||
DoBreak = true;
|
||||
|
||||
/* handle a break */
|
||||
if (DoBreak) {
|
||||
PlatformPrintf(pc->CStdOut, "Handling a break\n");
|
||||
PicocParseInteractiveNoStartPrompt(pc, FALSE);
|
||||
PicocParseInteractiveNoStartPrompt(pc, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
152
expression.c
152
expression.c
|
@ -10,7 +10,7 @@
|
|||
/* If the destination is not float, we can't assign a floating value to it, we need to convert it to integer instead */
|
||||
#define ASSIGN_FP_OR_INT(value) \
|
||||
if (IS_FP(BottomValue)) { ResultFP = ExpressionAssignFP(Parser, BottomValue, value); } \
|
||||
else { ResultInt = ExpressionAssignInt(Parser, BottomValue, (long)(value), FALSE); ResultIsInt = TRUE; } \
|
||||
else { ResultInt = ExpressionAssignInt(Parser, BottomValue, (long)(value), false); ResultIsInt = true; } \
|
||||
|
||||
#define DEEP_PRECEDENCE (BRACKET_PRECEDENCE*1000)
|
||||
|
||||
|
@ -264,7 +264,7 @@ double ExpressionAssignFP(struct ParseState *Parser, struct Value *DestValue, do
|
|||
/* push a node on to the expression stack */
|
||||
void ExpressionStackPushValueNode(struct ParseState *Parser, struct ExpressionStack **StackTop, struct Value *ValueLoc)
|
||||
{
|
||||
struct ExpressionStack *StackNode = VariableAlloc(Parser->pc, Parser, sizeof(struct ExpressionStack), FALSE);
|
||||
struct ExpressionStack *StackNode = VariableAlloc(Parser->pc, Parser, sizeof(struct ExpressionStack), false);
|
||||
StackNode->Next = *StackTop;
|
||||
StackNode->Val = ValueLoc;
|
||||
*StackTop = StackNode;
|
||||
|
@ -280,7 +280,7 @@ void ExpressionStackPushValueNode(struct ParseState *Parser, struct ExpressionSt
|
|||
/* push a blank value on to the expression stack by type */
|
||||
struct Value *ExpressionStackPushValueByType(struct ParseState *Parser, struct ExpressionStack **StackTop, struct ValueType *PushType)
|
||||
{
|
||||
struct Value *ValueLoc = VariableAllocValueFromType(Parser->pc, Parser, PushType, FALSE, NULL, FALSE);
|
||||
struct Value *ValueLoc = VariableAllocValueFromType(Parser->pc, Parser, PushType, false, NULL, false);
|
||||
ExpressionStackPushValueNode(Parser, StackTop, ValueLoc);
|
||||
|
||||
return ValueLoc;
|
||||
|
@ -289,7 +289,7 @@ struct Value *ExpressionStackPushValueByType(struct ParseState *Parser, struct E
|
|||
/* push a value on to the expression stack */
|
||||
void ExpressionStackPushValue(struct ParseState *Parser, struct ExpressionStack **StackTop, struct Value *PushValue)
|
||||
{
|
||||
struct Value *ValueLoc = VariableAllocValueAndCopy(Parser->pc, Parser, PushValue, FALSE);
|
||||
struct Value *ValueLoc = VariableAllocValueAndCopy(Parser->pc, Parser, PushValue, false);
|
||||
ExpressionStackPushValueNode(Parser, StackTop, ValueLoc);
|
||||
}
|
||||
|
||||
|
@ -317,14 +317,14 @@ void ExpressionStackPushDereference(struct ParseState *Parser, struct Expression
|
|||
|
||||
void ExpressionPushInt(struct ParseState *Parser, struct ExpressionStack **StackTop, long IntValue)
|
||||
{
|
||||
struct Value *ValueLoc = VariableAllocValueFromType(Parser->pc, Parser, &Parser->pc->IntType, FALSE, NULL, FALSE);
|
||||
struct Value *ValueLoc = VariableAllocValueFromType(Parser->pc, Parser, &Parser->pc->IntType, false, NULL, false);
|
||||
ValueLoc->Val->Integer = IntValue;
|
||||
ExpressionStackPushValueNode(Parser, StackTop, ValueLoc);
|
||||
}
|
||||
|
||||
void ExpressionPushFP(struct ParseState *Parser, struct ExpressionStack **StackTop, double FPValue)
|
||||
{
|
||||
struct Value *ValueLoc = VariableAllocValueFromType(Parser->pc, Parser, &Parser->pc->FPType, FALSE, NULL, FALSE);
|
||||
struct Value *ValueLoc = VariableAllocValueFromType(Parser->pc, Parser, &Parser->pc->FPType, false, NULL, false);
|
||||
ValueLoc->Val->FP = FPValue;
|
||||
ExpressionStackPushValueNode(Parser, StackTop, ValueLoc);
|
||||
}
|
||||
|
@ -388,7 +388,7 @@ void ExpressionAssign(struct ParseState *Parser, struct Value *DestValue, struct
|
|||
if (SourceValue->Typ->Base == TypeArray && DestValue->Typ->FromType == DestValue->Typ->FromType && DestValue->Typ->ArraySize == 0) {
|
||||
/* destination array is unsized - need to resize the destination array to the same size as the source array */
|
||||
DestValue->Typ = SourceValue->Typ;
|
||||
VariableRealloc(Parser, DestValue, TypeSizeValue(DestValue, FALSE));
|
||||
VariableRealloc(Parser, DestValue, TypeSizeValue(DestValue, false));
|
||||
|
||||
if (DestValue->LValueFrom != NULL) {
|
||||
/* copy the resized value back to the LValue */
|
||||
|
@ -405,8 +405,8 @@ void ExpressionAssign(struct ParseState *Parser, struct Value *DestValue, struct
|
|||
PRINT_SOURCE_POS();
|
||||
fprintf(stderr, "str size: %d\n", Size);
|
||||
#endif
|
||||
DestValue->Typ = TypeGetMatching(Parser->pc, Parser, DestValue->Typ->FromType, DestValue->Typ->Base, Size, DestValue->Typ->Identifier, TRUE);
|
||||
VariableRealloc(Parser, DestValue, TypeSizeValue(DestValue, FALSE));
|
||||
DestValue->Typ = TypeGetMatching(Parser->pc, Parser, DestValue->Typ->FromType, DestValue->Typ->Base, Size, DestValue->Typ->Identifier, true);
|
||||
VariableRealloc(Parser, DestValue, TypeSizeValue(DestValue, false));
|
||||
}
|
||||
/* else, it's char x[10] = "abcd" */
|
||||
|
||||
|
@ -414,7 +414,7 @@ void ExpressionAssign(struct ParseState *Parser, struct Value *DestValue, struct
|
|||
PRINT_SOURCE_POS();
|
||||
fprintf(stderr, "char[%d] from char* (len=%d)\n", DestValue->Typ->ArraySize, strlen(SourceValue->Val->Pointer));
|
||||
#endif
|
||||
memcpy((void *)DestValue->Val, SourceValue->Val->Pointer, TypeSizeValue(DestValue, FALSE));
|
||||
memcpy((void *)DestValue->Val, SourceValue->Val->Pointer, TypeSizeValue(DestValue, false));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -424,7 +424,7 @@ void ExpressionAssign(struct ParseState *Parser, struct Value *DestValue, struct
|
|||
if (DestValue->Typ->ArraySize != SourceValue->Typ->ArraySize)
|
||||
AssignFail(Parser, "from an array of size %d to one of size %d", NULL, NULL, DestValue->Typ->ArraySize, SourceValue->Typ->ArraySize, FuncName, ParamNo);
|
||||
|
||||
memcpy((void *)DestValue->Val, (void *)SourceValue->Val, TypeSizeValue(DestValue, FALSE));
|
||||
memcpy((void *)DestValue->Val, (void *)SourceValue->Val, TypeSizeValue(DestValue, false));
|
||||
break;
|
||||
|
||||
case TypeStruct:
|
||||
|
@ -432,7 +432,7 @@ void ExpressionAssign(struct ParseState *Parser, struct Value *DestValue, struct
|
|||
if (DestValue->Typ != SourceValue->Typ)
|
||||
AssignFail(Parser, "%t from %t", DestValue->Typ, SourceValue->Typ, 0, 0, FuncName, ParamNo);
|
||||
|
||||
memcpy((void *)DestValue->Val, (void *)SourceValue->Val, TypeSizeValue(SourceValue, FALSE));
|
||||
memcpy((void *)DestValue->Val, (void *)SourceValue->Val, TypeSizeValue(SourceValue, false));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -484,7 +484,7 @@ void ExpressionPrefixOperator(struct ParseState *Parser, struct ExpressionStack
|
|||
ProgramFail(Parser, "can't get the address of this");
|
||||
|
||||
ValPtr = TopValue->Val;
|
||||
Result = VariableAllocValueFromType(Parser->pc, Parser, TypeGetMatching(Parser->pc, Parser, TopValue->Typ, TypePointer, 0, Parser->pc->StrEmpty, TRUE), FALSE, NULL, FALSE);
|
||||
Result = VariableAllocValueFromType(Parser->pc, Parser, TypeGetMatching(Parser->pc, Parser, TopValue->Typ, TypePointer, 0, Parser->pc->StrEmpty, true), false, NULL, false);
|
||||
Result->Val->Pointer = (void *)ValPtr;
|
||||
ExpressionStackPushValueNode(Parser, StackTop, Result);
|
||||
break;
|
||||
|
@ -496,9 +496,9 @@ void ExpressionPrefixOperator(struct ParseState *Parser, struct ExpressionStack
|
|||
case TokenSizeof:
|
||||
/* return the size of the argument */
|
||||
if (TopValue->Typ == &Parser->pc->TypeType)
|
||||
ExpressionPushInt(Parser, StackTop, TypeSize(TopValue->Val->Typ, TopValue->Val->Typ->ArraySize, TRUE));
|
||||
ExpressionPushInt(Parser, StackTop, TypeSize(TopValue->Val->Typ, TopValue->Val->Typ->ArraySize, true));
|
||||
else
|
||||
ExpressionPushInt(Parser, StackTop, TypeSize(TopValue->Typ, TopValue->Typ->ArraySize, TRUE));
|
||||
ExpressionPushInt(Parser, StackTop, TypeSize(TopValue->Typ, TopValue->Typ->ArraySize, true));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -524,8 +524,8 @@ void ExpressionPrefixOperator(struct ParseState *Parser, struct ExpressionStack
|
|||
switch (Op) {
|
||||
case TokenPlus: ResultInt = TopInt; break;
|
||||
case TokenMinus: ResultInt = -TopInt; break;
|
||||
case TokenIncrement: ResultInt = ExpressionAssignInt(Parser, TopValue, TopInt+1, FALSE); break;
|
||||
case TokenDecrement: ResultInt = ExpressionAssignInt(Parser, TopValue, TopInt-1, FALSE); break;
|
||||
case TokenIncrement: ResultInt = ExpressionAssignInt(Parser, TopValue, TopInt+1, false); break;
|
||||
case TokenDecrement: ResultInt = ExpressionAssignInt(Parser, TopValue, TopInt-1, false); break;
|
||||
case TokenUnaryNot: ResultInt = !TopInt; break;
|
||||
case TokenUnaryExor: ResultInt = ~TopInt; break;
|
||||
default: ProgramFail(Parser, "invalid operation"); break;
|
||||
|
@ -534,7 +534,7 @@ void ExpressionPrefixOperator(struct ParseState *Parser, struct ExpressionStack
|
|||
ExpressionPushInt(Parser, StackTop, ResultInt);
|
||||
} else if (TopValue->Typ->Base == TypePointer) {
|
||||
/* pointer prefix arithmetic */
|
||||
int Size = TypeSize(TopValue->Typ->FromType, 0, TRUE);
|
||||
int Size = TypeSize(TopValue->Typ->FromType, 0, true);
|
||||
struct Value *StackValue;
|
||||
void *ResultPtr;
|
||||
|
||||
|
@ -582,8 +582,8 @@ void ExpressionPostfixOperator(struct ParseState *Parser, struct ExpressionStack
|
|||
long ResultInt = 0;
|
||||
long TopInt = ExpressionCoerceInteger(TopValue);
|
||||
switch (Op) {
|
||||
case TokenIncrement: ResultInt = ExpressionAssignInt(Parser, TopValue, TopInt+1, TRUE); break;
|
||||
case TokenDecrement: ResultInt = ExpressionAssignInt(Parser, TopValue, TopInt-1, TRUE); break;
|
||||
case TokenIncrement: ResultInt = ExpressionAssignInt(Parser, TopValue, TopInt+1, true); break;
|
||||
case TokenDecrement: ResultInt = ExpressionAssignInt(Parser, TopValue, TopInt-1, true); break;
|
||||
case TokenRightSquareBracket: ProgramFail(Parser, "not supported"); break; /* XXX */
|
||||
case TokenCloseBracket: ProgramFail(Parser, "not supported"); break; /* XXX */
|
||||
default: ProgramFail(Parser, "invalid operation"); break;
|
||||
|
@ -592,7 +592,7 @@ void ExpressionPostfixOperator(struct ParseState *Parser, struct ExpressionStack
|
|||
ExpressionPushInt(Parser, StackTop, ResultInt);
|
||||
} else if (TopValue->Typ->Base == TypePointer) {
|
||||
/* pointer postfix arithmetic */
|
||||
int Size = TypeSize(TopValue->Typ->FromType, 0, TRUE);
|
||||
int Size = TypeSize(TopValue->Typ->FromType, 0, true);
|
||||
struct Value *StackValue;
|
||||
void *OrigPointer = TopValue->Val->Pointer;
|
||||
|
||||
|
@ -641,8 +641,8 @@ void ExpressionInfixOperator(struct ParseState *Parser, struct ExpressionStack *
|
|||
|
||||
/* make the array element result */
|
||||
switch (BottomValue->Typ->Base) {
|
||||
case TypeArray: Result = VariableAllocValueFromExistingData(Parser, BottomValue->Typ->FromType, (union AnyValue *)(&BottomValue->Val->ArrayMem[0] + TypeSize(BottomValue->Typ, ArrayIndex, TRUE)), BottomValue->IsLValue, BottomValue->LValueFrom); break;
|
||||
case TypePointer: Result = VariableAllocValueFromExistingData(Parser, BottomValue->Typ->FromType, (union AnyValue *)((char *)BottomValue->Val->Pointer + TypeSize(BottomValue->Typ->FromType, 0, TRUE) * ArrayIndex), BottomValue->IsLValue, BottomValue->LValueFrom); break;
|
||||
case TypeArray: Result = VariableAllocValueFromExistingData(Parser, BottomValue->Typ->FromType, (union AnyValue *)(&BottomValue->Val->ArrayMem[0] + TypeSize(BottomValue->Typ, ArrayIndex, true)), BottomValue->IsLValue, BottomValue->LValueFrom); break;
|
||||
case TypePointer: Result = VariableAllocValueFromExistingData(Parser, BottomValue->Typ->FromType, (union AnyValue *)((char *)BottomValue->Val->Pointer + TypeSize(BottomValue->Typ->FromType, 0, true) * ArrayIndex), BottomValue->IsLValue, BottomValue->LValueFrom); break;
|
||||
default: ProgramFail(Parser, "this %t is not an array", BottomValue->Typ);
|
||||
}
|
||||
|
||||
|
@ -655,7 +655,7 @@ void ExpressionInfixOperator(struct ParseState *Parser, struct ExpressionStack *
|
|||
(TopValue->Typ == &Parser->pc->FPType && IS_NUMERIC_COERCIBLE(BottomValue)) ||
|
||||
(IS_NUMERIC_COERCIBLE(TopValue) && BottomValue->Typ == &Parser->pc->FPType) ) {
|
||||
/* floating point infix arithmetic */
|
||||
int ResultIsInt = FALSE;
|
||||
int ResultIsInt = false;
|
||||
double ResultFP = 0.0;
|
||||
double TopFP = (TopValue->Typ == &Parser->pc->FPType) ? TopValue->Val->FP : (double)ExpressionCoerceInteger(TopValue);
|
||||
double BottomFP = (BottomValue->Typ == &Parser->pc->FPType) ? BottomValue->Val->FP : (double)ExpressionCoerceInteger(BottomValue);
|
||||
|
@ -666,12 +666,12 @@ void ExpressionInfixOperator(struct ParseState *Parser, struct ExpressionStack *
|
|||
case TokenSubtractAssign: ASSIGN_FP_OR_INT(BottomFP - TopFP); break;
|
||||
case TokenMultiplyAssign: ASSIGN_FP_OR_INT(BottomFP * TopFP); break;
|
||||
case TokenDivideAssign: ASSIGN_FP_OR_INT(BottomFP / TopFP); break;
|
||||
case TokenEqual: ResultInt = BottomFP == TopFP; ResultIsInt = TRUE; break;
|
||||
case TokenNotEqual: ResultInt = BottomFP != TopFP; ResultIsInt = TRUE; break;
|
||||
case TokenLessThan: ResultInt = BottomFP < TopFP; ResultIsInt = TRUE; break;
|
||||
case TokenGreaterThan: ResultInt = BottomFP > TopFP; ResultIsInt = TRUE; break;
|
||||
case TokenLessEqual: ResultInt = BottomFP <= TopFP; ResultIsInt = TRUE; break;
|
||||
case TokenGreaterEqual: ResultInt = BottomFP >= TopFP; ResultIsInt = TRUE; break;
|
||||
case TokenEqual: ResultInt = BottomFP == TopFP; ResultIsInt = true; break;
|
||||
case TokenNotEqual: ResultInt = BottomFP != TopFP; ResultIsInt = true; break;
|
||||
case TokenLessThan: ResultInt = BottomFP < TopFP; ResultIsInt = true; break;
|
||||
case TokenGreaterThan: ResultInt = BottomFP > TopFP; ResultIsInt = true; break;
|
||||
case TokenLessEqual: ResultInt = BottomFP <= TopFP; ResultIsInt = true; break;
|
||||
case TokenGreaterEqual: ResultInt = BottomFP >= TopFP; ResultIsInt = true; break;
|
||||
case TokenPlus: ResultFP = BottomFP + TopFP; break;
|
||||
case TokenMinus: ResultFP = BottomFP - TopFP; break;
|
||||
case TokenAsterisk: ResultFP = BottomFP * TopFP; break;
|
||||
|
@ -688,17 +688,17 @@ void ExpressionInfixOperator(struct ParseState *Parser, struct ExpressionStack *
|
|||
long TopInt = ExpressionCoerceInteger(TopValue);
|
||||
long BottomInt = ExpressionCoerceInteger(BottomValue);
|
||||
switch (Op) {
|
||||
case TokenAssign: ResultInt = ExpressionAssignInt(Parser, BottomValue, TopInt, FALSE); break;
|
||||
case TokenAddAssign: ResultInt = ExpressionAssignInt(Parser, BottomValue, BottomInt + TopInt, FALSE); break;
|
||||
case TokenSubtractAssign: ResultInt = ExpressionAssignInt(Parser, BottomValue, BottomInt - TopInt, FALSE); break;
|
||||
case TokenMultiplyAssign: ResultInt = ExpressionAssignInt(Parser, BottomValue, BottomInt * TopInt, FALSE); break;
|
||||
case TokenDivideAssign: ResultInt = ExpressionAssignInt(Parser, BottomValue, BottomInt / TopInt, FALSE); break;
|
||||
case TokenModulusAssign: ResultInt = ExpressionAssignInt(Parser, BottomValue, BottomInt % TopInt, FALSE); break;
|
||||
case TokenShiftLeftAssign: ResultInt = ExpressionAssignInt(Parser, BottomValue, BottomInt << TopInt, FALSE); break;
|
||||
case TokenShiftRightAssign: ResultInt = ExpressionAssignInt(Parser, BottomValue, BottomInt >> TopInt, FALSE); break;
|
||||
case TokenArithmeticAndAssign: ResultInt = ExpressionAssignInt(Parser, BottomValue, BottomInt & TopInt, FALSE); break;
|
||||
case TokenArithmeticOrAssign: ResultInt = ExpressionAssignInt(Parser, BottomValue, BottomInt | TopInt, FALSE); break;
|
||||
case TokenArithmeticExorAssign: ResultInt = ExpressionAssignInt(Parser, BottomValue, BottomInt ^ TopInt, FALSE); break;
|
||||
case TokenAssign: ResultInt = ExpressionAssignInt(Parser, BottomValue, TopInt, false); break;
|
||||
case TokenAddAssign: ResultInt = ExpressionAssignInt(Parser, BottomValue, BottomInt + TopInt, false); break;
|
||||
case TokenSubtractAssign: ResultInt = ExpressionAssignInt(Parser, BottomValue, BottomInt - TopInt, false); break;
|
||||
case TokenMultiplyAssign: ResultInt = ExpressionAssignInt(Parser, BottomValue, BottomInt * TopInt, false); break;
|
||||
case TokenDivideAssign: ResultInt = ExpressionAssignInt(Parser, BottomValue, BottomInt / TopInt, false); break;
|
||||
case TokenModulusAssign: ResultInt = ExpressionAssignInt(Parser, BottomValue, BottomInt % TopInt, false); break;
|
||||
case TokenShiftLeftAssign: ResultInt = ExpressionAssignInt(Parser, BottomValue, BottomInt << TopInt, false); break;
|
||||
case TokenShiftRightAssign: ResultInt = ExpressionAssignInt(Parser, BottomValue, BottomInt >> TopInt, false); break;
|
||||
case TokenArithmeticAndAssign: ResultInt = ExpressionAssignInt(Parser, BottomValue, BottomInt & TopInt, false); break;
|
||||
case TokenArithmeticOrAssign: ResultInt = ExpressionAssignInt(Parser, BottomValue, BottomInt | TopInt, false); break;
|
||||
case TokenArithmeticExorAssign: ResultInt = ExpressionAssignInt(Parser, BottomValue, BottomInt ^ TopInt, false); break;
|
||||
case TokenLogicalOr: ResultInt = BottomInt || TopInt; break;
|
||||
case TokenLogicalAnd: ResultInt = BottomInt && TopInt; break;
|
||||
case TokenArithmeticOr: ResultInt = BottomInt | TopInt; break;
|
||||
|
@ -736,7 +736,7 @@ void ExpressionInfixOperator(struct ParseState *Parser, struct ExpressionStack *
|
|||
ExpressionPushInt(Parser, StackTop, BottomValue->Val->Pointer != NULL);
|
||||
} else if (Op == TokenPlus || Op == TokenMinus) {
|
||||
/* pointer arithmetic */
|
||||
int Size = TypeSize(BottomValue->Typ->FromType, 0, TRUE);
|
||||
int Size = TypeSize(BottomValue->Typ->FromType, 0, true);
|
||||
|
||||
Pointer = BottomValue->Val->Pointer;
|
||||
if (Pointer == NULL)
|
||||
|
@ -752,11 +752,11 @@ void ExpressionInfixOperator(struct ParseState *Parser, struct ExpressionStack *
|
|||
} else if (Op == TokenAssign && TopInt == 0) {
|
||||
/* assign a NULL pointer */
|
||||
HeapUnpopStack(Parser->pc, sizeof(struct Value));
|
||||
ExpressionAssign(Parser, BottomValue, TopValue, FALSE, NULL, 0, FALSE);
|
||||
ExpressionAssign(Parser, BottomValue, TopValue, false, NULL, 0, false);
|
||||
ExpressionStackPushValueNode(Parser, StackTop, BottomValue);
|
||||
} else if (Op == TokenAddAssign || Op == TokenSubtractAssign) {
|
||||
/* pointer arithmetic */
|
||||
int Size = TypeSize(BottomValue->Typ->FromType, 0, TRUE);
|
||||
int Size = TypeSize(BottomValue->Typ->FromType, 0, true);
|
||||
|
||||
Pointer = BottomValue->Val->Pointer;
|
||||
if (Pointer == NULL)
|
||||
|
@ -786,12 +786,12 @@ void ExpressionInfixOperator(struct ParseState *Parser, struct ExpressionStack *
|
|||
} else if (Op == TokenAssign) {
|
||||
/* assign a non-numeric type */
|
||||
HeapUnpopStack(Parser->pc, sizeof(struct Value)); /* XXX - possible bug if lvalue is a temp value and takes more than sizeof(struct Value) */
|
||||
ExpressionAssign(Parser, BottomValue, TopValue, FALSE, NULL, 0, FALSE);
|
||||
ExpressionAssign(Parser, BottomValue, TopValue, false, NULL, 0, false);
|
||||
ExpressionStackPushValueNode(Parser, StackTop, BottomValue);
|
||||
} else if (Op == TokenCast) {
|
||||
/* cast a value to a different type */ /* XXX - possible bug if the destination type takes more than sizeof(struct Value) + sizeof(struct ValueType *) */
|
||||
struct Value *ValueLoc = ExpressionStackPushValueByType(Parser, StackTop, BottomValue->Val->Typ);
|
||||
ExpressionAssign(Parser, ValueLoc, TopValue, TRUE, NULL, 0, TRUE);
|
||||
ExpressionAssign(Parser, ValueLoc, TopValue, true, NULL, 0, true);
|
||||
} else
|
||||
ProgramFail(Parser, "invalid operation");
|
||||
}
|
||||
|
@ -918,7 +918,7 @@ void ExpressionStackCollapse(struct ParseState *Parser, struct ExpressionStack *
|
|||
/* push an operator on to the expression stack */
|
||||
void ExpressionStackPushOperator(struct ParseState *Parser, struct ExpressionStack **StackTop, enum OperatorOrder Order, enum LexToken Token, int Precedence)
|
||||
{
|
||||
struct ExpressionStack *StackNode = VariableAlloc(Parser->pc, Parser, sizeof(struct ExpressionStack), FALSE);
|
||||
struct ExpressionStack *StackNode = VariableAlloc(Parser->pc, Parser, sizeof(struct ExpressionStack), false);
|
||||
StackNode->Next = *StackTop;
|
||||
StackNode->Order = Order;
|
||||
StackNode->Op = Token;
|
||||
|
@ -942,7 +942,7 @@ void ExpressionGetStructElement(struct ParseState *Parser, struct ExpressionStac
|
|||
struct Value *Ident;
|
||||
|
||||
/* get the identifier following the '.' or '->' */
|
||||
if (LexGetToken(Parser, &Ident, TRUE) != TokenIdentifier)
|
||||
if (LexGetToken(Parser, &Ident, true) != TokenIdentifier)
|
||||
ProgramFail(Parser, "need an structure or union member after '%s'", (Token == TokenDot) ? "." : "->");
|
||||
|
||||
if (Parser->Mode == RunModeRun) {
|
||||
|
@ -969,7 +969,7 @@ void ExpressionGetStructElement(struct ParseState *Parser, struct ExpressionStac
|
|||
*StackTop = (*StackTop)->Next;
|
||||
|
||||
/* make the result value for this member only */
|
||||
Result = VariableAllocValueFromExistingData(Parser, MemberValue->Typ, (void *)(DerefDataLoc + MemberValue->Val->Integer), TRUE, (StructVal != NULL) ? StructVal->LValueFrom : NULL);
|
||||
Result = VariableAllocValueFromExistingData(Parser, MemberValue->Typ, (void *)(DerefDataLoc + MemberValue->Val->Integer), true, (StructVal != NULL) ? StructVal->LValueFrom : NULL);
|
||||
ExpressionStackPushValueNode(Parser, StackTop, Result);
|
||||
}
|
||||
}
|
||||
|
@ -977,8 +977,8 @@ void ExpressionGetStructElement(struct ParseState *Parser, struct ExpressionStac
|
|||
/* parse an expression with operator precedence */
|
||||
int ExpressionParse(struct ParseState *Parser, struct Value **Result)
|
||||
{
|
||||
int PrefixState = TRUE;
|
||||
int Done = FALSE;
|
||||
int PrefixState = true;
|
||||
int Done = false;
|
||||
int BracketPrecedence = 0;
|
||||
int LocalPrecedence;
|
||||
int Precedence = 0;
|
||||
|
@ -996,7 +996,7 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result)
|
|||
enum LexToken Token;
|
||||
|
||||
ParserCopy(&PreState, Parser);
|
||||
Token = LexGetToken(Parser, &LexValue, TRUE);
|
||||
Token = LexGetToken(Parser, &LexValue, true);
|
||||
if ( ( ( (int)Token > TokenComma && (int)Token <= (int)TokenOpenBracket) ||
|
||||
(Token == TokenCloseBracket && BracketPrecedence != 0)) &&
|
||||
(Token != TokenColon || TernaryDepth > 0) ) {
|
||||
|
@ -1011,7 +1011,7 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result)
|
|||
|
||||
if (Token == TokenOpenBracket) {
|
||||
/* it's either a new bracket level or a cast */
|
||||
enum LexToken BracketToken = LexGetToken(Parser, &LexValue, FALSE);
|
||||
enum LexToken BracketToken = LexGetToken(Parser, &LexValue, false);
|
||||
if (IsTypeToken(Parser, BracketToken, LexValue) && (StackTop == NULL || StackTop->Op != TokenSizeof)) {
|
||||
/* it's a cast - get the new type */
|
||||
struct ValueType *CastType;
|
||||
|
@ -1019,14 +1019,14 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result)
|
|||
struct Value *CastTypeValue;
|
||||
|
||||
TypeParse(Parser, &CastType, &CastIdentifier, NULL);
|
||||
if (LexGetToken(Parser, &LexValue, TRUE) != TokenCloseBracket)
|
||||
if (LexGetToken(Parser, &LexValue, true) != TokenCloseBracket)
|
||||
ProgramFail(Parser, "brackets not closed");
|
||||
|
||||
/* scan and collapse the stack to the precedence of this infix cast operator, then push */
|
||||
Precedence = BracketPrecedence + OperatorPrecedence[(int)TokenCast].PrefixPrecedence;
|
||||
|
||||
ExpressionStackCollapse(Parser, &StackTop, Precedence+1, &IgnorePrecedence);
|
||||
CastTypeValue = VariableAllocValueFromType(Parser->pc, Parser, &Parser->pc->TypeType, FALSE, NULL, FALSE);
|
||||
CastTypeValue = VariableAllocValueFromType(Parser->pc, Parser, &Parser->pc->TypeType, false, NULL, false);
|
||||
CastTypeValue->Val->Typ = CastType;
|
||||
ExpressionStackPushValueNode(Parser, &StackTop, CastTypeValue);
|
||||
ExpressionStackPushOperator(Parser, &StackTop, OrderInfix, TokenCast, Precedence);
|
||||
|
@ -1038,7 +1038,7 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result)
|
|||
/* scan and collapse the stack to the precedence of this operator, then push */
|
||||
|
||||
/* take some extra care for double prefix operators, e.g. x = - -5, or x = **y */
|
||||
int NextToken = LexGetToken(Parser, NULL, FALSE);
|
||||
int NextToken = LexGetToken(Parser, NULL, false);
|
||||
int TempPrecedenceBoost = 0;
|
||||
if (NextToken > TokenComma && NextToken < TokenOpenBracket) {
|
||||
int NextPrecedence = OperatorPrecedence[(int)NextToken].PrefixPrecedence;
|
||||
|
@ -1061,7 +1061,7 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result)
|
|||
if (BracketPrecedence == 0) {
|
||||
/* assume this bracket is after the end of the expression */
|
||||
ParserCopy(Parser, &PreState);
|
||||
Done = TRUE;
|
||||
Done = true;
|
||||
} else {
|
||||
/* collapse to the bracket precedence */
|
||||
ExpressionStackCollapse(Parser, &StackTop, BracketPrecedence, &IgnorePrecedence);
|
||||
|
@ -1099,7 +1099,7 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result)
|
|||
|
||||
/* push the operator on the stack */
|
||||
ExpressionStackPushOperator(Parser, &StackTop, OrderInfix, Token, Precedence);
|
||||
PrefixState = TRUE;
|
||||
PrefixState = true;
|
||||
|
||||
switch (Token) {
|
||||
case TokenQuestionMark: TernaryDepth++; break;
|
||||
|
@ -1121,7 +1121,7 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result)
|
|||
if (!PrefixState)
|
||||
ProgramFail(Parser, "identifier not expected here");
|
||||
|
||||
if (LexGetToken(Parser, NULL, FALSE) == TokenOpenBracket) {
|
||||
if (LexGetToken(Parser, NULL, false) == TokenOpenBracket) {
|
||||
ExpressionParseFunctionCall(Parser, &StackTop, LexValue->Val->Identifier, Parser->Mode == RunModeRun && Precedence < IgnorePrecedence);
|
||||
} else {
|
||||
if (Parser->Mode == RunModeRun /* && Precedence < IgnorePrecedence */) {
|
||||
|
@ -1138,7 +1138,7 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result)
|
|||
if (VariableValue->Val->MacroDef.NumParams != 0)
|
||||
ProgramFail(&MacroParser, "macro arguments missing");
|
||||
|
||||
if (!ExpressionParse(&MacroParser, &MacroResult) || LexGetToken(&MacroParser, NULL, FALSE) != TokenEndOfFunction)
|
||||
if (!ExpressionParse(&MacroParser, &MacroResult) || LexGetToken(&MacroParser, NULL, false) != TokenEndOfFunction)
|
||||
ProgramFail(&MacroParser, "expression expected");
|
||||
|
||||
ExpressionStackPushValueNode(Parser, &StackTop, MacroResult);
|
||||
|
@ -1155,13 +1155,13 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result)
|
|||
if (Precedence <= IgnorePrecedence)
|
||||
IgnorePrecedence = DEEP_PRECEDENCE;
|
||||
|
||||
PrefixState = FALSE;
|
||||
PrefixState = false;
|
||||
} else if ((int)Token > TokenCloseBracket && (int)Token <= TokenCharacterConstant) {
|
||||
/* it's a value of some sort, push it */
|
||||
if (!PrefixState)
|
||||
ProgramFail(Parser, "value not expected here");
|
||||
|
||||
PrefixState = FALSE;
|
||||
PrefixState = false;
|
||||
ExpressionStackPushValue(Parser, &StackTop, LexValue);
|
||||
} else if (IsTypeToken(Parser, Token, LexValue)) {
|
||||
/* it's a type. push it on the stack like a value. this is used in sizeof() */
|
||||
|
@ -1172,16 +1172,16 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result)
|
|||
if (!PrefixState)
|
||||
ProgramFail(Parser, "type not expected here");
|
||||
|
||||
PrefixState = FALSE;
|
||||
PrefixState = false;
|
||||
ParserCopy(Parser, &PreState);
|
||||
TypeParse(Parser, &Typ, &Identifier, NULL);
|
||||
TypeValue = VariableAllocValueFromType(Parser->pc, Parser, &Parser->pc->TypeType, FALSE, NULL, FALSE);
|
||||
TypeValue = VariableAllocValueFromType(Parser->pc, Parser, &Parser->pc->TypeType, false, NULL, false);
|
||||
TypeValue->Val->Typ = Typ;
|
||||
ExpressionStackPushValueNode(Parser, &StackTop, TypeValue);
|
||||
} else {
|
||||
/* it isn't a token from an expression */
|
||||
ParserCopy(Parser, &PreState);
|
||||
Done = TRUE;
|
||||
Done = true;
|
||||
}
|
||||
|
||||
} while (!Done);
|
||||
|
@ -1246,12 +1246,12 @@ void ExpressionParseMacroCall(struct ParseState *Parser, struct ExpressionStack
|
|||
}
|
||||
|
||||
ArgCount++;
|
||||
Token = LexGetToken(Parser, NULL, TRUE);
|
||||
Token = LexGetToken(Parser, NULL, true);
|
||||
if (Token != TokenComma && Token != TokenCloseBracket)
|
||||
ProgramFail(Parser, "comma expected");
|
||||
} else {
|
||||
/* end of argument list? */
|
||||
Token = LexGetToken(Parser, NULL, TRUE);
|
||||
Token = LexGetToken(Parser, NULL, true);
|
||||
if (!TokenCloseBracket)
|
||||
ProgramFail(Parser, "bad argument");
|
||||
}
|
||||
|
@ -1276,10 +1276,10 @@ void ExpressionParseMacroCall(struct ParseState *Parser, struct ExpressionStack
|
|||
Parser->pc->TopStackFrame->NumParams = ArgCount;
|
||||
Parser->pc->TopStackFrame->ReturnValue = ReturnValue;
|
||||
for (Count = 0; Count < MDef->NumParams; Count++)
|
||||
VariableDefine(Parser->pc, Parser, MDef->ParamName[Count], ParamArray[Count], NULL, TRUE);
|
||||
VariableDefine(Parser->pc, Parser, MDef->ParamName[Count], ParamArray[Count], NULL, true);
|
||||
|
||||
ExpressionParse(&MacroParser, &EvalValue);
|
||||
ExpressionAssign(Parser, ReturnValue, EvalValue, TRUE, MacroName, 0, FALSE);
|
||||
ExpressionAssign(Parser, ReturnValue, EvalValue, true, MacroName, 0, false);
|
||||
VariableStackFramePop(Parser);
|
||||
HeapPopStackFrame(Parser->pc);
|
||||
}
|
||||
|
@ -1289,7 +1289,7 @@ void ExpressionParseMacroCall(struct ParseState *Parser, struct ExpressionStack
|
|||
void ExpressionParseFunctionCall(struct ParseState *Parser, struct ExpressionStack **StackTop, const char *FuncName, int RunIt)
|
||||
{
|
||||
int ArgCount;
|
||||
enum LexToken Token = LexGetToken(Parser, NULL, TRUE); /* open bracket */
|
||||
enum LexToken Token = LexGetToken(Parser, NULL, true); /* open bracket */
|
||||
enum RunMode OldMode = Parser->Mode;
|
||||
struct Value *ReturnValue = NULL;
|
||||
struct Value *FuncValue = NULL;
|
||||
|
@ -1324,12 +1324,12 @@ void ExpressionParseFunctionCall(struct ParseState *Parser, struct ExpressionSta
|
|||
ArgCount = 0;
|
||||
do {
|
||||
if (RunIt && ArgCount < FuncValue->Val->FuncDef.NumParams)
|
||||
ParamArray[ArgCount] = VariableAllocValueFromType(Parser->pc, Parser, FuncValue->Val->FuncDef.ParamType[ArgCount], FALSE, NULL, FALSE);
|
||||
ParamArray[ArgCount] = VariableAllocValueFromType(Parser->pc, Parser, FuncValue->Val->FuncDef.ParamType[ArgCount], false, NULL, false);
|
||||
|
||||
if (ExpressionParse(Parser, &Param)) {
|
||||
if (RunIt) {
|
||||
if (ArgCount < FuncValue->Val->FuncDef.NumParams) {
|
||||
ExpressionAssign(Parser, ParamArray[ArgCount], Param, TRUE, FuncName, ArgCount+1, FALSE);
|
||||
ExpressionAssign(Parser, ParamArray[ArgCount], Param, true, FuncName, ArgCount+1, false);
|
||||
VariableStackPop(Parser, Param);
|
||||
} else {
|
||||
if (!FuncValue->Val->FuncDef.VarArgs)
|
||||
|
@ -1338,12 +1338,12 @@ void ExpressionParseFunctionCall(struct ParseState *Parser, struct ExpressionSta
|
|||
}
|
||||
|
||||
ArgCount++;
|
||||
Token = LexGetToken(Parser, NULL, TRUE);
|
||||
Token = LexGetToken(Parser, NULL, true);
|
||||
if (Token != TokenComma && Token != TokenCloseBracket)
|
||||
ProgramFail(Parser, "comma expected");
|
||||
} else {
|
||||
/* end of argument list? */
|
||||
Token = LexGetToken(Parser, NULL, TRUE);
|
||||
Token = LexGetToken(Parser, NULL, true);
|
||||
if (!TokenCloseBracket)
|
||||
ProgramFail(Parser, "bad argument");
|
||||
}
|
||||
|
@ -1373,11 +1373,11 @@ void ExpressionParseFunctionCall(struct ParseState *Parser, struct ExpressionSta
|
|||
Parser->ScopeID = -1;
|
||||
|
||||
for (Count = 0; Count < FuncValue->Val->FuncDef.NumParams; Count++)
|
||||
VariableDefine(Parser->pc, Parser, FuncValue->Val->FuncDef.ParamName[Count], ParamArray[Count], NULL, TRUE);
|
||||
VariableDefine(Parser->pc, Parser, FuncValue->Val->FuncDef.ParamName[Count], ParamArray[Count], NULL, true);
|
||||
|
||||
Parser->ScopeID = OldScopeID;
|
||||
|
||||
if (ParseStatement(&FuncParser, TRUE) != ParseResultOk)
|
||||
if (ParseStatement(&FuncParser, true) != ParseResultOk)
|
||||
ProgramFail(&FuncParser, "function body expected");
|
||||
|
||||
if (RunIt) {
|
||||
|
|
8
heap.c
8
heap.c
|
@ -76,7 +76,7 @@ int HeapPopStack(Picoc *pc, void *Addr, int Size)
|
|||
{
|
||||
int ToLose = MEM_ALIGN(Size);
|
||||
if (ToLose > ((char*)pc->HeapStackTop - (char*)&(pc->HeapMemory)[0]))
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
#ifdef DEBUG_HEAP
|
||||
printf("HeapPopStack(0x%lx, %ld) back to 0x%lx\n", (unsigned long)Addr,
|
||||
|
@ -85,7 +85,7 @@ int HeapPopStack(Picoc *pc, void *Addr, int Size)
|
|||
pc->HeapStackTop = (void*)((char*)pc->HeapStackTop - ToLose);
|
||||
assert(Addr == NULL || pc->HeapStackTop == Addr);
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* push a new stack frame on to the stack */
|
||||
|
@ -108,9 +108,9 @@ int HeapPopStackFrame(Picoc *pc)
|
|||
#ifdef DEBUG_HEAP
|
||||
printf("Popping stack frame back to 0x%lx\n", (unsigned long)pc->HeapStackTop);
|
||||
#endif
|
||||
return TRUE;
|
||||
return true;
|
||||
} else
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* allocate some dynamically allocated memory. memory is cleared. can return NULL if out of memory */
|
||||
|
|
|
@ -69,7 +69,7 @@ void IncludeFile(Picoc *pc, char *FileName)
|
|||
if (strcmp(LInclude->IncludeName, FileName) == 0) {
|
||||
/* found it - protect against multiple inclusion */
|
||||
if (!VariableDefined(pc, FileName)) {
|
||||
VariableDefine(pc, NULL, FileName, NULL, &pc->VoidType, FALSE);
|
||||
VariableDefine(pc, NULL, FileName, NULL, &pc->VoidType, false);
|
||||
|
||||
/* run an extra startup function if there is one */
|
||||
if (LInclude->SetupFunction != NULL)
|
||||
|
@ -77,7 +77,7 @@ void IncludeFile(Picoc *pc, char *FileName)
|
|||
|
||||
/* parse the setup C source code - may define types etc. */
|
||||
if (LInclude->SetupCSource != NULL)
|
||||
PicocParse(pc, FileName, LInclude->SetupCSource, strlen(LInclude->SetupCSource), TRUE, TRUE, FALSE, FALSE);
|
||||
PicocParse(pc, FileName, LInclude->SetupCSource, strlen(LInclude->SetupCSource), true, true, false, false);
|
||||
|
||||
/* set up the library functions */
|
||||
if (LInclude->FuncList != NULL)
|
||||
|
|
|
@ -7,13 +7,6 @@
|
|||
|
||||
#include "platform.h"
|
||||
|
||||
|
||||
/* handy definitions */
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
@ -24,8 +17,6 @@
|
|||
|
||||
#define MEM_ALIGN(x) (((x) + sizeof(ALIGN_TYPE) - 1) & ~(sizeof(ALIGN_TYPE)-1))
|
||||
|
||||
#define GETS_BUF_MAX (256)
|
||||
|
||||
/* for debugging */
|
||||
#define PRINT_SOURCE_POS() { \
|
||||
PrintSourceTextErrorLine(Parser->pc->CStdOut, \
|
||||
|
|
62
lex.c
62
lex.c
|
@ -7,7 +7,7 @@
|
|||
#define isCident(c) (isalnum(c) || (c)=='_')
|
||||
|
||||
#define IS_HEX_ALPHA_DIGIT(c) (((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
|
||||
#define IS_BASE_DIGIT(c,b) (((c) >= '0' && (c) < '0' + (((b)<10)?(b):10)) || (((b) > 10) ? IS_HEX_ALPHA_DIGIT(c) : FALSE))
|
||||
#define IS_BASE_DIGIT(c,b) (((c) >= '0' && (c) < '0' + (((b)<10)?(b):10)) || (((b) > 10) ? IS_HEX_ALPHA_DIGIT(c) : false))
|
||||
#define GET_BASE_DIGIT(c) (((c) <= '9') ? ((c) - '0') : (((c) <= 'F') ? ((c) - 'A' + 10) : ((c) - 'a' + 10)))
|
||||
|
||||
#define NEXTIS(c,x,y) { if (NextChar == (c)) { LEXER_INC(Lexer); GotToken = (x); } else GotToken = (y); }
|
||||
|
@ -80,7 +80,7 @@ void LexInit(Picoc *pc)
|
|||
{
|
||||
int Count;
|
||||
|
||||
TableInitTable(&pc->ReservedWordTable, &pc->ReservedWordHashTable[0], sizeof(ReservedWords) / sizeof(struct ReservedWord) * 2, TRUE);
|
||||
TableInitTable(&pc->ReservedWordTable, &pc->ReservedWordHashTable[0], sizeof(ReservedWords) / sizeof(struct ReservedWord) * 2, true);
|
||||
|
||||
for (Count = 0; Count < sizeof(ReservedWords) / sizeof(struct ReservedWord); Count++) {
|
||||
TableSet(pc, &pc->ReservedWordTable, TableStrRegister(pc, ReservedWords[Count].Word), (struct Value *)&ReservedWords[Count], NULL, 0, 0);
|
||||
|
@ -88,11 +88,11 @@ void LexInit(Picoc *pc)
|
|||
|
||||
pc->LexValue.Typ = NULL;
|
||||
pc->LexValue.Val = &pc->LexAnyValue;
|
||||
pc->LexValue.LValueFrom = FALSE;
|
||||
pc->LexValue.ValOnHeap = FALSE;
|
||||
pc->LexValue.ValOnStack = FALSE;
|
||||
pc->LexValue.AnyValOnHeap = FALSE;
|
||||
pc->LexValue.IsLValue = FALSE;
|
||||
pc->LexValue.LValueFrom = false;
|
||||
pc->LexValue.ValOnHeap = false;
|
||||
pc->LexValue.ValOnStack = false;
|
||||
pc->LexValue.AnyValOnHeap = false;
|
||||
pc->LexValue.IsLValue = false;
|
||||
}
|
||||
|
||||
/* deallocate */
|
||||
|
@ -295,7 +295,7 @@ unsigned char LexUnEscapeCharacter(const char **From, const char *End)
|
|||
/* get a string constant - used while scanning */
|
||||
enum LexToken LexGetStringConstant(Picoc *pc, struct LexState *Lexer, struct Value *Value, char EndChar)
|
||||
{
|
||||
int Escape = FALSE;
|
||||
int Escape = false;
|
||||
const char *StartPos = Lexer->Pos;
|
||||
const char *EndPos;
|
||||
char *EscBuf;
|
||||
|
@ -316,9 +316,9 @@ enum LexToken LexGetStringConstant(Picoc *pc, struct LexState *Lexer, struct Val
|
|||
Lexer->EmitExtraNewlines++;
|
||||
}
|
||||
|
||||
Escape = FALSE;
|
||||
Escape = false;
|
||||
} else if (*Lexer->Pos == '\\')
|
||||
Escape = TRUE;
|
||||
Escape = true;
|
||||
|
||||
LEXER_INC(Lexer);
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ enum LexToken LexGetStringConstant(Picoc *pc, struct LexState *Lexer, struct Val
|
|||
ArrayValue = VariableStringLiteralGet(pc, RegString);
|
||||
if (ArrayValue == NULL) {
|
||||
/* create and store this string literal */
|
||||
ArrayValue = VariableAllocValueAndData(pc, NULL, 0, FALSE, NULL, TRUE);
|
||||
ArrayValue = VariableAllocValueAndData(pc, NULL, 0, false, NULL, true);
|
||||
ArrayValue->Typ = pc->CharArrayType;
|
||||
ArrayValue->Val = (union AnyValue *)RegString;
|
||||
VariableStringLiteralDefine(pc, RegString, ArrayValue);
|
||||
|
@ -606,7 +606,7 @@ enum LexToken LexGetRawToken(struct ParseState *Parser, struct Value **Value, in
|
|||
/* get interactive input */
|
||||
if (pc->LexUseStatementPrompt) {
|
||||
Prompt = INTERACTIVE_PROMPT_STATEMENT;
|
||||
pc->LexUseStatementPrompt = FALSE;
|
||||
pc->LexUseStatementPrompt = false;
|
||||
} else
|
||||
Prompt = INTERACTIVE_PROMPT_LINE;
|
||||
|
||||
|
@ -615,7 +615,7 @@ enum LexToken LexGetRawToken(struct ParseState *Parser, struct Value **Value, in
|
|||
|
||||
/* put the new line at the end of the linked list of interactive lines */
|
||||
LineTokens = LexAnalyse(pc, pc->StrEmpty, &LineBuffer[0], strlen(LineBuffer), &LineBytes);
|
||||
LineNode = VariableAlloc(pc, Parser, sizeof(struct TokenLine), TRUE);
|
||||
LineNode = VariableAlloc(pc, Parser, sizeof(struct TokenLine), true);
|
||||
LineNode->Tokens = LineTokens;
|
||||
LineNode->NumBytes = LineBytes;
|
||||
if (pc->InteractiveHead == NULL) {
|
||||
|
@ -663,9 +663,9 @@ enum LexToken LexGetRawToken(struct ParseState *Parser, struct Value **Value, in
|
|||
}
|
||||
|
||||
memcpy((void *)pc->LexValue.Val, (void *)((char *)Parser->Pos + TOKEN_DATA_OFFSET), ValueSize);
|
||||
pc->LexValue.ValOnHeap = FALSE;
|
||||
pc->LexValue.ValOnStack = FALSE;
|
||||
pc->LexValue.IsLValue = FALSE;
|
||||
pc->LexValue.ValOnHeap = false;
|
||||
pc->LexValue.ValOnStack = false;
|
||||
pc->LexValue.IsLValue = false;
|
||||
pc->LexValue.LValueFrom = NULL;
|
||||
*Value = &pc->LexValue;
|
||||
}
|
||||
|
@ -688,7 +688,7 @@ enum LexToken LexGetRawToken(struct ParseState *Parser, struct Value **Value, in
|
|||
void LexHashIncPos(struct ParseState *Parser, int IncPos)
|
||||
{
|
||||
if (!IncPos)
|
||||
LexGetRawToken(Parser, NULL, TRUE);
|
||||
LexGetRawToken(Parser, NULL, true);
|
||||
}
|
||||
|
||||
/* handle a #ifdef directive */
|
||||
|
@ -698,7 +698,7 @@ void LexHashIfdef(struct ParseState *Parser, int IfNot)
|
|||
int IsDefined;
|
||||
struct Value *IdentValue;
|
||||
struct Value *SavedValue;
|
||||
enum LexToken Token = LexGetRawToken(Parser, &IdentValue, TRUE);
|
||||
enum LexToken Token = LexGetRawToken(Parser, &IdentValue, true);
|
||||
|
||||
if (Token != TokenIdentifier)
|
||||
ProgramFail(Parser, "identifier expected");
|
||||
|
@ -720,7 +720,7 @@ void LexHashIf(struct ParseState *Parser)
|
|||
struct Value *IdentValue;
|
||||
struct Value *SavedValue = NULL;
|
||||
struct ParseState MacroParser;
|
||||
enum LexToken Token = LexGetRawToken(Parser, &IdentValue, TRUE);
|
||||
enum LexToken Token = LexGetRawToken(Parser, &IdentValue, true);
|
||||
|
||||
if (Token == TokenIdentifier) {
|
||||
/* look up a value from a macro definition */
|
||||
|
@ -731,7 +731,7 @@ void LexHashIf(struct ParseState *Parser)
|
|||
ProgramFail(Parser, "value expected");
|
||||
|
||||
ParserCopy(&MacroParser, &SavedValue->Val->MacroDef.Body);
|
||||
Token = LexGetRawToken(&MacroParser, &IdentValue, TRUE);
|
||||
Token = LexGetRawToken(&MacroParser, &IdentValue, true);
|
||||
}
|
||||
|
||||
if (Token != TokenCharacterConstant && Token != TokenIntegerConstant)
|
||||
|
@ -816,22 +816,22 @@ enum LexToken LexGetToken(struct ParseState *Parser, struct Value **Value, int I
|
|||
|
||||
/* implements the pre-processor #if commands */
|
||||
do {
|
||||
int WasPreProcToken = TRUE;
|
||||
int WasPreProcToken = true;
|
||||
|
||||
Token = LexGetRawToken(Parser, Value, IncPos);
|
||||
switch (Token) {
|
||||
case TokenHashIfdef: LexHashIncPos(Parser, IncPos); LexHashIfdef(Parser, FALSE); break;
|
||||
case TokenHashIfndef: LexHashIncPos(Parser, IncPos); LexHashIfdef(Parser, TRUE); break;
|
||||
case TokenHashIfdef: LexHashIncPos(Parser, IncPos); LexHashIfdef(Parser, false); break;
|
||||
case TokenHashIfndef: LexHashIncPos(Parser, IncPos); LexHashIfdef(Parser, true); break;
|
||||
case TokenHashIf: LexHashIncPos(Parser, IncPos); LexHashIf(Parser); break;
|
||||
case TokenHashElse: LexHashIncPos(Parser, IncPos); LexHashElse(Parser); break;
|
||||
case TokenHashEndif: LexHashIncPos(Parser, IncPos); LexHashEndif(Parser); break;
|
||||
default: WasPreProcToken = FALSE; break;
|
||||
default: WasPreProcToken = false; break;
|
||||
}
|
||||
|
||||
/* if we're going to reject this token, increment the token pointer to the next one */
|
||||
TryNextToken = (Parser->HashIfEvaluateToLevel < Parser->HashIfLevel && Token != TokenEOF) || WasPreProcToken;
|
||||
if (!IncPos && TryNextToken)
|
||||
LexGetRawToken(Parser, NULL, TRUE);
|
||||
LexGetRawToken(Parser, NULL, true);
|
||||
|
||||
} while (TryNextToken);
|
||||
|
||||
|
@ -847,12 +847,12 @@ enum LexToken LexRawPeekToken(struct ParseState *Parser)
|
|||
/* find the end of the line */
|
||||
void LexToEndOfLine(struct ParseState *Parser)
|
||||
{
|
||||
while (TRUE) {
|
||||
while (true) {
|
||||
enum LexToken Token = (enum LexToken)*(unsigned char *)Parser->Pos;
|
||||
if (Token == TokenEndOfLine || Token == TokenEOF)
|
||||
return;
|
||||
else
|
||||
LexGetRawToken(Parser, NULL, TRUE);
|
||||
LexGetRawToken(Parser, NULL, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -870,7 +870,7 @@ void *LexCopyTokens(struct ParseState *StartParser, struct ParseState *EndParser
|
|||
if (pc->InteractiveHead == NULL) {
|
||||
/* non-interactive mode - copy the tokens */
|
||||
MemSize = EndParser->Pos - StartParser->Pos;
|
||||
NewTokens = VariableAlloc(pc, StartParser, MemSize + TOKEN_DATA_OFFSET, TRUE);
|
||||
NewTokens = VariableAlloc(pc, StartParser, MemSize + TOKEN_DATA_OFFSET, true);
|
||||
memcpy(NewTokens, (void *)StartParser->Pos, MemSize);
|
||||
} else {
|
||||
/* we're in interactive mode - add up line by line */
|
||||
|
@ -880,7 +880,7 @@ void *LexCopyTokens(struct ParseState *StartParser, struct ParseState *EndParser
|
|||
if (EndParser->Pos >= StartParser->Pos && EndParser->Pos < &pc->InteractiveCurrentLine->Tokens[pc->InteractiveCurrentLine->NumBytes]) {
|
||||
/* all on a single line */
|
||||
MemSize = EndParser->Pos - StartParser->Pos;
|
||||
NewTokens = VariableAlloc(pc, StartParser, MemSize + TOKEN_DATA_OFFSET, TRUE);
|
||||
NewTokens = VariableAlloc(pc, StartParser, MemSize + TOKEN_DATA_OFFSET, true);
|
||||
memcpy(NewTokens, (void *)StartParser->Pos, MemSize);
|
||||
} else {
|
||||
/* it's spread across multiple lines */
|
||||
|
@ -891,7 +891,7 @@ void *LexCopyTokens(struct ParseState *StartParser, struct ParseState *EndParser
|
|||
|
||||
assert(ILine != NULL);
|
||||
MemSize += EndParser->Pos - &ILine->Tokens[0];
|
||||
NewTokens = VariableAlloc(pc, StartParser, MemSize + TOKEN_DATA_OFFSET, TRUE);
|
||||
NewTokens = VariableAlloc(pc, StartParser, MemSize + TOKEN_DATA_OFFSET, true);
|
||||
|
||||
CopySize = &pc->InteractiveCurrentLine->Tokens[pc->InteractiveCurrentLine->NumBytes-TOKEN_DATA_OFFSET] - Pos;
|
||||
memcpy(NewTokens, Pos, CopySize);
|
||||
|
@ -949,5 +949,5 @@ void LexInteractiveCompleted(Picoc *pc, struct ParseState *Parser)
|
|||
/* the next time we prompt, make it the full statement prompt */
|
||||
void LexInteractiveStatementPrompt(Picoc *pc)
|
||||
{
|
||||
pc->LexUseStatementPrompt = TRUE;
|
||||
pc->LexUseStatementPrompt = true;
|
||||
}
|
||||
|
|
218
parse.c
218
parse.c
|
@ -4,9 +4,9 @@
|
|||
#include "interpreter.h"
|
||||
|
||||
#ifdef DEBUGGER
|
||||
static int gEnableDebugger = TRUE;
|
||||
static int gEnableDebugger = true;
|
||||
#else
|
||||
static int gEnableDebugger = FALSE;
|
||||
static int gEnableDebugger = false;
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -25,7 +25,7 @@ void ParseCleanup(Picoc *pc)
|
|||
}
|
||||
}
|
||||
|
||||
/* parse a statement, but only run it if Condition is TRUE */
|
||||
/* parse a statement, but only run it if Condition is true */
|
||||
enum ParseResult ParseStatementMaybeRun(struct ParseState *Parser, int Condition, int CheckTrailingSemicolon)
|
||||
{
|
||||
if (Parser->Mode != RunModeSkip && !Condition) {
|
||||
|
@ -44,11 +44,11 @@ int ParseCountParams(struct ParseState *Parser)
|
|||
{
|
||||
int ParamCount = 0;
|
||||
|
||||
enum LexToken Token = LexGetToken(Parser, NULL, TRUE);
|
||||
enum LexToken Token = LexGetToken(Parser, NULL, true);
|
||||
if (Token != TokenCloseBracket && Token != TokenEOF) {
|
||||
/* count the number of parameters */
|
||||
ParamCount++;
|
||||
while ((Token = LexGetToken(Parser, NULL, TRUE)) != TokenCloseBracket && Token != TokenEOF) {
|
||||
while ((Token = LexGetToken(Parser, NULL, true)) != TokenCloseBracket && Token != TokenEOF) {
|
||||
if (Token == TokenComma)
|
||||
ParamCount++;
|
||||
}
|
||||
|
@ -73,26 +73,26 @@ struct Value *ParseFunctionDefinition(struct ParseState *Parser, struct ValueTyp
|
|||
if (pc->TopStackFrame != NULL)
|
||||
ProgramFail(Parser, "nested function definitions are not allowed");
|
||||
|
||||
LexGetToken(Parser, NULL, TRUE); /* open bracket */
|
||||
LexGetToken(Parser, NULL, true); /* open bracket */
|
||||
ParserCopy(&ParamParser, Parser);
|
||||
ParamCount = ParseCountParams(Parser);
|
||||
if (ParamCount > PARAMETER_MAX)
|
||||
ProgramFail(Parser, "too many parameters (%d allowed)", PARAMETER_MAX);
|
||||
|
||||
FuncValue = VariableAllocValueAndData(pc, Parser, sizeof(struct FuncDef) + sizeof(struct ValueType *) * ParamCount + sizeof(const char *) * ParamCount, FALSE, NULL, TRUE);
|
||||
FuncValue = VariableAllocValueAndData(pc, Parser, sizeof(struct FuncDef) + sizeof(struct ValueType *) * ParamCount + sizeof(const char *) * ParamCount, false, NULL, true);
|
||||
FuncValue->Typ = &pc->FunctionType;
|
||||
FuncValue->Val->FuncDef.ReturnType = ReturnType;
|
||||
FuncValue->Val->FuncDef.NumParams = ParamCount;
|
||||
FuncValue->Val->FuncDef.VarArgs = FALSE;
|
||||
FuncValue->Val->FuncDef.VarArgs = false;
|
||||
FuncValue->Val->FuncDef.ParamType = (struct ValueType **)((char *)FuncValue->Val + sizeof(struct FuncDef));
|
||||
FuncValue->Val->FuncDef.ParamName = (char **)((char *)FuncValue->Val->FuncDef.ParamType + sizeof(struct ValueType *) * ParamCount);
|
||||
|
||||
for (ParamCount = 0; ParamCount < FuncValue->Val->FuncDef.NumParams; ParamCount++) {
|
||||
/* harvest the parameters into the function definition */
|
||||
if (ParamCount == FuncValue->Val->FuncDef.NumParams-1 && LexGetToken(&ParamParser, NULL, FALSE) == TokenEllipsis) {
|
||||
if (ParamCount == FuncValue->Val->FuncDef.NumParams-1 && LexGetToken(&ParamParser, NULL, false) == TokenEllipsis) {
|
||||
/* ellipsis at end */
|
||||
FuncValue->Val->FuncDef.NumParams--;
|
||||
FuncValue->Val->FuncDef.VarArgs = TRUE;
|
||||
FuncValue->Val->FuncDef.VarArgs = true;
|
||||
break;
|
||||
} else {
|
||||
/* add a parameter */
|
||||
|
@ -107,7 +107,7 @@ struct Value *ParseFunctionDefinition(struct ParseState *Parser, struct ValueTyp
|
|||
}
|
||||
}
|
||||
|
||||
Token = LexGetToken(&ParamParser, NULL, TRUE);
|
||||
Token = LexGetToken(&ParamParser, NULL, true);
|
||||
if (Token != TokenComma && ParamCount < FuncValue->Val->FuncDef.NumParams-1)
|
||||
ProgramFail(&ParamParser, "comma expected");
|
||||
}
|
||||
|
@ -127,16 +127,16 @@ struct Value *ParseFunctionDefinition(struct ParseState *Parser, struct ValueTyp
|
|||
}
|
||||
|
||||
/* look for a function body */
|
||||
Token = LexGetToken(Parser, NULL, FALSE);
|
||||
Token = LexGetToken(Parser, NULL, false);
|
||||
if (Token == TokenSemicolon)
|
||||
LexGetToken(Parser, NULL, TRUE); /* it's a prototype, absorb the trailing semicolon */
|
||||
LexGetToken(Parser, NULL, true); /* it's a prototype, absorb the trailing semicolon */
|
||||
else {
|
||||
/* it's a full function definition with a body */
|
||||
if (Token != TokenLeftBrace)
|
||||
ProgramFail(Parser, "bad function definition");
|
||||
|
||||
ParserCopy(&FuncBody, Parser);
|
||||
if (ParseStatementMaybeRun(Parser, FALSE, TRUE) != ParseResultOk)
|
||||
if (ParseStatementMaybeRun(Parser, false, true) != ParseResultOk)
|
||||
ProgramFail(Parser, "function definition expected");
|
||||
|
||||
FuncValue->Val->FuncDef.Body = FuncBody;
|
||||
|
@ -171,14 +171,14 @@ int ParseArrayInitialiser(struct ParseState *Parser, struct Value *NewVariable,
|
|||
int NumElements;
|
||||
|
||||
ParserCopy(&CountParser, Parser);
|
||||
NumElements = ParseArrayInitialiser(&CountParser, NewVariable, FALSE);
|
||||
NumElements = ParseArrayInitialiser(&CountParser, NewVariable, false);
|
||||
|
||||
if (NewVariable->Typ->Base != TypeArray)
|
||||
AssignFail(Parser, "%t from array initializer", NewVariable->Typ, NULL, 0, 0, NULL, 0);
|
||||
|
||||
if (NewVariable->Typ->ArraySize == 0) {
|
||||
NewVariable->Typ = TypeGetMatching(Parser->pc, Parser, NewVariable->Typ->FromType, NewVariable->Typ->Base, NumElements, NewVariable->Typ->Identifier, TRUE);
|
||||
VariableRealloc(Parser, NewVariable, TypeSizeValue(NewVariable, FALSE));
|
||||
NewVariable->Typ = TypeGetMatching(Parser->pc, Parser, NewVariable->Typ->FromType, NewVariable->Typ->Base, NumElements, NewVariable->Typ->Identifier, true);
|
||||
VariableRealloc(Parser, NewVariable, TypeSizeValue(NewVariable, false));
|
||||
}
|
||||
#ifdef DEBUG_ARRAY_INITIALIZER
|
||||
PRINT_SOURCE_POS();
|
||||
|
@ -187,17 +187,17 @@ int ParseArrayInitialiser(struct ParseState *Parser, struct Value *NewVariable,
|
|||
}
|
||||
|
||||
/* parse the array initialiser */
|
||||
Token = LexGetToken(Parser, NULL, FALSE);
|
||||
Token = LexGetToken(Parser, NULL, false);
|
||||
while (Token != TokenRightBrace) {
|
||||
if (LexGetToken(Parser, NULL, FALSE) == TokenLeftBrace) {
|
||||
if (LexGetToken(Parser, NULL, false) == TokenLeftBrace) {
|
||||
/* this is a sub-array initialiser */
|
||||
int SubArraySize = 0;
|
||||
struct Value *SubArray = NewVariable;
|
||||
if (Parser->Mode == RunModeRun && DoAssignment) {
|
||||
SubArraySize = TypeSize(NewVariable->Typ->FromType, NewVariable->Typ->FromType->ArraySize, TRUE);
|
||||
SubArray = VariableAllocValueFromExistingData(Parser, NewVariable->Typ->FromType, (union AnyValue *)(&NewVariable->Val->ArrayMem[0] + SubArraySize * ArrayIndex), TRUE, NewVariable);
|
||||
SubArraySize = TypeSize(NewVariable->Typ->FromType, NewVariable->Typ->FromType->ArraySize, true);
|
||||
SubArray = VariableAllocValueFromExistingData(Parser, NewVariable->Typ->FromType, (union AnyValue *)(&NewVariable->Val->ArrayMem[0] + SubArraySize * ArrayIndex), true, NewVariable);
|
||||
#ifdef DEBUG_ARRAY_INITIALIZER
|
||||
int FullArraySize = TypeSize(NewVariable->Typ, NewVariable->Typ->ArraySize, TRUE);
|
||||
int FullArraySize = TypeSize(NewVariable->Typ, NewVariable->Typ->ArraySize, true);
|
||||
PRINT_SOURCE_POS();
|
||||
PRINT_TYPE(NewVariable->Typ)
|
||||
printf("[%d] subarray size: %d (full: %d,%d) \n", ArrayIndex, SubArraySize, FullArraySize, NewVariable->Typ->ArraySize);
|
||||
|
@ -205,7 +205,7 @@ int ParseArrayInitialiser(struct ParseState *Parser, struct Value *NewVariable,
|
|||
if (ArrayIndex >= NewVariable->Typ->ArraySize)
|
||||
ProgramFail(Parser, "too many array elements");
|
||||
}
|
||||
LexGetToken(Parser, NULL, TRUE);
|
||||
LexGetToken(Parser, NULL, true);
|
||||
ParseArrayInitialiser(Parser, SubArray, DoAssignment);
|
||||
} else {
|
||||
struct Value *ArrayElement = NULL;
|
||||
|
@ -221,17 +221,17 @@ int ParseArrayInitialiser(struct ParseState *Parser, struct Value *NewVariable,
|
|||
ElementType = ElementType->FromType;
|
||||
|
||||
/* char x[10][10] = {"abc", "def"} => assign "abc" to x[0], "def" to x[1] etc */
|
||||
if (LexGetToken(Parser, NULL, FALSE) == TokenStringConstant && ElementType->FromType->Base == TypeChar)
|
||||
if (LexGetToken(Parser, NULL, false) == TokenStringConstant && ElementType->FromType->Base == TypeChar)
|
||||
break;
|
||||
}
|
||||
ElementSize = TypeSize(ElementType, ElementType->ArraySize, TRUE);
|
||||
ElementSize = TypeSize(ElementType, ElementType->ArraySize, true);
|
||||
#ifdef DEBUG_ARRAY_INITIALIZER
|
||||
PRINT_SOURCE_POS();
|
||||
printf("[%d/%d] element size: %d (x%d) \n", ArrayIndex, TotalSize, ElementSize, ElementType->ArraySize);
|
||||
#endif
|
||||
if (ArrayIndex >= TotalSize)
|
||||
ProgramFail(Parser, "too many array elements");
|
||||
ArrayElement = VariableAllocValueFromExistingData(Parser, ElementType, (union AnyValue *)(&NewVariable->Val->ArrayMem[0] + ElementSize * ArrayIndex), TRUE, NewVariable);
|
||||
ArrayElement = VariableAllocValueFromExistingData(Parser, ElementType, (union AnyValue *)(&NewVariable->Val->ArrayMem[0] + ElementSize * ArrayIndex), true, NewVariable);
|
||||
}
|
||||
|
||||
/* this is a normal expression initialiser */
|
||||
|
@ -239,7 +239,7 @@ int ParseArrayInitialiser(struct ParseState *Parser, struct Value *NewVariable,
|
|||
ProgramFail(Parser, "expression expected");
|
||||
|
||||
if (Parser->Mode == RunModeRun && DoAssignment) {
|
||||
ExpressionAssign(Parser, ArrayElement, CValue, FALSE, NULL, 0, FALSE);
|
||||
ExpressionAssign(Parser, ArrayElement, CValue, false, NULL, 0, false);
|
||||
VariableStackPop(Parser, CValue);
|
||||
VariableStackPop(Parser, ArrayElement);
|
||||
}
|
||||
|
@ -247,16 +247,16 @@ int ParseArrayInitialiser(struct ParseState *Parser, struct Value *NewVariable,
|
|||
|
||||
ArrayIndex++;
|
||||
|
||||
Token = LexGetToken(Parser, NULL, FALSE);
|
||||
Token = LexGetToken(Parser, NULL, false);
|
||||
if (Token == TokenComma) {
|
||||
LexGetToken(Parser, NULL, TRUE);
|
||||
Token = LexGetToken(Parser, NULL, FALSE);
|
||||
LexGetToken(Parser, NULL, true);
|
||||
Token = LexGetToken(Parser, NULL, false);
|
||||
} else if (Token != TokenRightBrace)
|
||||
ProgramFail(Parser, "comma expected");
|
||||
}
|
||||
|
||||
if (Token == TokenRightBrace)
|
||||
LexGetToken(Parser, NULL, TRUE);
|
||||
LexGetToken(Parser, NULL, true);
|
||||
else
|
||||
ProgramFail(Parser, "'}' expected");
|
||||
|
||||
|
@ -268,9 +268,9 @@ void ParseDeclarationAssignment(struct ParseState *Parser, struct Value *NewVari
|
|||
{
|
||||
struct Value *CValue;
|
||||
|
||||
if (LexGetToken(Parser, NULL, FALSE) == TokenLeftBrace) {
|
||||
if (LexGetToken(Parser, NULL, false) == TokenLeftBrace) {
|
||||
/* this is an array initialiser */
|
||||
LexGetToken(Parser, NULL, TRUE);
|
||||
LexGetToken(Parser, NULL, true);
|
||||
ParseArrayInitialiser(Parser, NewVariable, DoAssignment);
|
||||
} else {
|
||||
/* this is a normal expression initialiser */
|
||||
|
@ -278,7 +278,7 @@ void ParseDeclarationAssignment(struct ParseState *Parser, struct Value *NewVari
|
|||
ProgramFail(Parser, "expression expected");
|
||||
|
||||
if (Parser->Mode == RunModeRun && DoAssignment) {
|
||||
ExpressionAssign(Parser, NewVariable, CValue, FALSE, NULL, 0, FALSE);
|
||||
ExpressionAssign(Parser, NewVariable, CValue, false, NULL, 0, false);
|
||||
VariableStackPop(Parser, CValue);
|
||||
}
|
||||
}
|
||||
|
@ -287,8 +287,8 @@ void ParseDeclarationAssignment(struct ParseState *Parser, struct Value *NewVari
|
|||
/* declare a variable or function */
|
||||
int ParseDeclaration(struct ParseState *Parser, enum LexToken Token)
|
||||
{
|
||||
int IsStatic = FALSE;
|
||||
int FirstVisit = FALSE;
|
||||
int IsStatic = false;
|
||||
int FirstVisit = false;
|
||||
char *Identifier;
|
||||
struct ValueType *BasicType;
|
||||
struct ValueType *Typ;
|
||||
|
@ -303,10 +303,10 @@ int ParseDeclaration(struct ParseState *Parser, enum LexToken Token)
|
|||
|
||||
if (Identifier != pc->StrEmpty) {
|
||||
/* handle function definitions */
|
||||
if (LexGetToken(Parser, NULL, FALSE) == TokenOpenBracket)
|
||||
if (LexGetToken(Parser, NULL, false) == TokenOpenBracket)
|
||||
{
|
||||
ParseFunctionDefinition(Parser, Typ, Identifier);
|
||||
return FALSE;
|
||||
return false;
|
||||
} else {
|
||||
if (Typ == &pc->VoidType && Identifier != pc->StrEmpty)
|
||||
ProgramFail(Parser, "can't define a void variable");
|
||||
|
@ -314,21 +314,21 @@ int ParseDeclaration(struct ParseState *Parser, enum LexToken Token)
|
|||
if (Parser->Mode == RunModeRun || Parser->Mode == RunModeGoto)
|
||||
NewVariable = VariableDefineButIgnoreIdentical(Parser, Identifier, Typ, IsStatic, &FirstVisit);
|
||||
|
||||
if (LexGetToken(Parser, NULL, FALSE) == TokenAssign) {
|
||||
if (LexGetToken(Parser, NULL, false) == TokenAssign) {
|
||||
/* we're assigning an initial value */
|
||||
LexGetToken(Parser, NULL, TRUE);
|
||||
LexGetToken(Parser, NULL, true);
|
||||
ParseDeclarationAssignment(Parser, NewVariable, !IsStatic || FirstVisit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Token = LexGetToken(Parser, NULL, FALSE);
|
||||
Token = LexGetToken(Parser, NULL, false);
|
||||
if (Token == TokenComma)
|
||||
LexGetToken(Parser, NULL, TRUE);
|
||||
LexGetToken(Parser, NULL, true);
|
||||
|
||||
} while (Token == TokenComma);
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* parse a #define macro definition and store it for later */
|
||||
|
@ -339,34 +339,34 @@ void ParseMacroDefinition(struct ParseState *Parser)
|
|||
struct Value *ParamName;
|
||||
struct Value *MacroValue;
|
||||
|
||||
if (LexGetToken(Parser, &MacroName, TRUE) != TokenIdentifier)
|
||||
if (LexGetToken(Parser, &MacroName, true) != TokenIdentifier)
|
||||
ProgramFail(Parser, "identifier expected");
|
||||
|
||||
MacroNameStr = MacroName->Val->Identifier;
|
||||
|
||||
if (LexRawPeekToken(Parser) == TokenOpenMacroBracket) {
|
||||
/* it's a parameterised macro, read the parameters */
|
||||
enum LexToken Token = LexGetToken(Parser, NULL, TRUE);
|
||||
enum LexToken Token = LexGetToken(Parser, NULL, true);
|
||||
struct ParseState ParamParser;
|
||||
int NumParams;
|
||||
int ParamCount = 0;
|
||||
|
||||
ParserCopy(&ParamParser, Parser);
|
||||
NumParams = ParseCountParams(&ParamParser);
|
||||
MacroValue = VariableAllocValueAndData(Parser->pc, Parser, sizeof(struct MacroDef) + sizeof(const char *) * NumParams, FALSE, NULL, TRUE);
|
||||
MacroValue = VariableAllocValueAndData(Parser->pc, Parser, sizeof(struct MacroDef) + sizeof(const char *) * NumParams, false, NULL, true);
|
||||
MacroValue->Val->MacroDef.NumParams = NumParams;
|
||||
MacroValue->Val->MacroDef.ParamName = (char **)((char *)MacroValue->Val + sizeof(struct MacroDef));
|
||||
|
||||
Token = LexGetToken(Parser, &ParamName, TRUE);
|
||||
Token = LexGetToken(Parser, &ParamName, true);
|
||||
|
||||
while (Token == TokenIdentifier) {
|
||||
/* store a parameter name */
|
||||
MacroValue->Val->MacroDef.ParamName[ParamCount++] = ParamName->Val->Identifier;
|
||||
|
||||
/* get the trailing comma */
|
||||
Token = LexGetToken(Parser, NULL, TRUE);
|
||||
Token = LexGetToken(Parser, NULL, true);
|
||||
if (Token == TokenComma)
|
||||
Token = LexGetToken(Parser, &ParamName, TRUE);
|
||||
Token = LexGetToken(Parser, &ParamName, true);
|
||||
|
||||
else if (Token != TokenCloseBracket)
|
||||
ProgramFail(Parser, "comma expected");
|
||||
|
@ -376,7 +376,7 @@ void ParseMacroDefinition(struct ParseState *Parser)
|
|||
ProgramFail(Parser, "close bracket expected");
|
||||
} else {
|
||||
/* allocate a simple unparameterised macro */
|
||||
MacroValue = VariableAllocValueAndData(Parser->pc, Parser, sizeof(struct MacroDef), FALSE, NULL, TRUE);
|
||||
MacroValue = VariableAllocValueAndData(Parser->pc, Parser, sizeof(struct MacroDef), false, NULL, true);
|
||||
MacroValue->Val->MacroDef.NumParams = 0;
|
||||
}
|
||||
|
||||
|
@ -420,29 +420,29 @@ void ParseFor(struct ParseState *Parser)
|
|||
int PrevScopeID = 0;
|
||||
int ScopeID = VariableScopeBegin(Parser, &PrevScopeID);
|
||||
|
||||
if (LexGetToken(Parser, NULL, TRUE) != TokenOpenBracket)
|
||||
if (LexGetToken(Parser, NULL, true) != TokenOpenBracket)
|
||||
ProgramFail(Parser, "'(' expected");
|
||||
|
||||
if (ParseStatement(Parser, TRUE) != ParseResultOk)
|
||||
if (ParseStatement(Parser, true) != ParseResultOk)
|
||||
ProgramFail(Parser, "statement expected");
|
||||
|
||||
ParserCopyPos(&PreConditional, Parser);
|
||||
if (LexGetToken(Parser, NULL, FALSE) == TokenSemicolon)
|
||||
Condition = TRUE;
|
||||
if (LexGetToken(Parser, NULL, false) == TokenSemicolon)
|
||||
Condition = true;
|
||||
else
|
||||
Condition = ExpressionParseInt(Parser);
|
||||
|
||||
if (LexGetToken(Parser, NULL, TRUE) != TokenSemicolon)
|
||||
if (LexGetToken(Parser, NULL, true) != TokenSemicolon)
|
||||
ProgramFail(Parser, "';' expected");
|
||||
|
||||
ParserCopyPos(&PreIncrement, Parser);
|
||||
ParseStatementMaybeRun(Parser, FALSE, FALSE);
|
||||
ParseStatementMaybeRun(Parser, false, false);
|
||||
|
||||
if (LexGetToken(Parser, NULL, TRUE) != TokenCloseBracket)
|
||||
if (LexGetToken(Parser, NULL, true) != TokenCloseBracket)
|
||||
ProgramFail(Parser, "')' expected");
|
||||
|
||||
ParserCopyPos(&PreStatement, Parser);
|
||||
if (ParseStatementMaybeRun(Parser, Condition, TRUE) != ParseResultOk)
|
||||
if (ParseStatementMaybeRun(Parser, Condition, true) != ParseResultOk)
|
||||
ProgramFail(Parser, "statement expected");
|
||||
|
||||
if (Parser->Mode == RunModeContinue && OldMode == RunModeRun)
|
||||
|
@ -452,17 +452,17 @@ void ParseFor(struct ParseState *Parser)
|
|||
|
||||
while (Condition && Parser->Mode == RunModeRun) {
|
||||
ParserCopyPos(Parser, &PreIncrement);
|
||||
ParseStatement(Parser, FALSE);
|
||||
ParseStatement(Parser, false);
|
||||
|
||||
ParserCopyPos(Parser, &PreConditional);
|
||||
if (LexGetToken(Parser, NULL, FALSE) == TokenSemicolon)
|
||||
Condition = TRUE;
|
||||
if (LexGetToken(Parser, NULL, false) == TokenSemicolon)
|
||||
Condition = true;
|
||||
else
|
||||
Condition = ExpressionParseInt(Parser);
|
||||
|
||||
if (Condition) {
|
||||
ParserCopyPos(Parser, &PreStatement);
|
||||
ParseStatement(Parser, TRUE);
|
||||
ParseStatement(Parser, true);
|
||||
|
||||
if (Parser->Mode == RunModeContinue)
|
||||
Parser->Mode = RunModeRun;
|
||||
|
@ -483,23 +483,23 @@ enum RunMode ParseBlock(struct ParseState *Parser, int AbsorbOpenBrace, int Cond
|
|||
int PrevScopeID = 0;
|
||||
int ScopeID = VariableScopeBegin(Parser, &PrevScopeID);
|
||||
|
||||
if (AbsorbOpenBrace && LexGetToken(Parser, NULL, TRUE) != TokenLeftBrace)
|
||||
if (AbsorbOpenBrace && LexGetToken(Parser, NULL, true) != TokenLeftBrace)
|
||||
ProgramFail(Parser, "'{' expected");
|
||||
|
||||
if (Parser->Mode == RunModeSkip || !Condition) {
|
||||
/* condition failed - skip this block instead */
|
||||
enum RunMode OldMode = Parser->Mode;
|
||||
Parser->Mode = RunModeSkip;
|
||||
while (ParseStatement(Parser, TRUE) == ParseResultOk) {
|
||||
while (ParseStatement(Parser, true) == ParseResultOk) {
|
||||
}
|
||||
Parser->Mode = OldMode;
|
||||
} else {
|
||||
/* just run it in its current mode */
|
||||
while (ParseStatement(Parser, TRUE) == ParseResultOk) {
|
||||
while (ParseStatement(Parser, true) == ParseResultOk) {
|
||||
}
|
||||
}
|
||||
|
||||
if (LexGetToken(Parser, NULL, TRUE) != TokenRightBrace)
|
||||
if (LexGetToken(Parser, NULL, true) != TokenRightBrace)
|
||||
ProgramFail(Parser, "'}' expected");
|
||||
|
||||
VariableScopeEnd(Parser, ScopeID, PrevScopeID);
|
||||
|
@ -521,7 +521,7 @@ void ParseTypedef(struct ParseState *Parser)
|
|||
TypPtr = &Typ;
|
||||
InitValue.Typ = &Parser->pc->TypeType;
|
||||
InitValue.Val = (union AnyValue *)TypPtr;
|
||||
VariableDefine(Parser->pc, Parser, TypeName, &InitValue, NULL, FALSE);
|
||||
VariableDefine(Parser->pc, Parser, TypeName, &InitValue, NULL, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -545,7 +545,7 @@ enum ParseResult ParseStatement(struct ParseState *Parser, int CheckTrailingSemi
|
|||
|
||||
/* take note of where we are and then grab a token to see what statement we have */
|
||||
ParserCopy(&PreState, Parser);
|
||||
Token = LexGetToken(Parser, &LexerValue, TRUE);
|
||||
Token = LexGetToken(Parser, &LexerValue, true);
|
||||
|
||||
switch (Token) {
|
||||
case TokenEOF:
|
||||
|
@ -561,13 +561,13 @@ enum ParseResult ParseStatement(struct ParseState *Parser, int CheckTrailingSemi
|
|||
}
|
||||
} else {
|
||||
/* it might be a goto label */
|
||||
enum LexToken NextToken = LexGetToken(Parser, NULL, FALSE);
|
||||
enum LexToken NextToken = LexGetToken(Parser, NULL, false);
|
||||
if (NextToken == TokenColon) {
|
||||
/* declare the identifier as a goto label */
|
||||
LexGetToken(Parser, NULL, TRUE);
|
||||
LexGetToken(Parser, NULL, true);
|
||||
if (Parser->Mode == RunModeGoto && LexerValue->Val->Identifier == Parser->SearchGotoLabel)
|
||||
Parser->Mode = RunModeRun;
|
||||
CheckTrailingSemicolon = FALSE;
|
||||
CheckTrailingSemicolon = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -584,44 +584,44 @@ enum ParseResult ParseStatement(struct ParseState *Parser, int CheckTrailingSemi
|
|||
VariableStackPop(Parser, CValue);
|
||||
break;
|
||||
case TokenLeftBrace:
|
||||
ParseBlock(Parser, FALSE, TRUE);
|
||||
CheckTrailingSemicolon = FALSE;
|
||||
ParseBlock(Parser, false, true);
|
||||
CheckTrailingSemicolon = false;
|
||||
break;
|
||||
case TokenIf:
|
||||
if (LexGetToken(Parser, NULL, TRUE) != TokenOpenBracket)
|
||||
if (LexGetToken(Parser, NULL, true) != TokenOpenBracket)
|
||||
ProgramFail(Parser, "'(' expected");
|
||||
Condition = ExpressionParseInt(Parser);
|
||||
if (LexGetToken(Parser, NULL, TRUE) != TokenCloseBracket)
|
||||
if (LexGetToken(Parser, NULL, true) != TokenCloseBracket)
|
||||
ProgramFail(Parser, "')' expected");
|
||||
if (ParseStatementMaybeRun(Parser, Condition, TRUE) != ParseResultOk)
|
||||
if (ParseStatementMaybeRun(Parser, Condition, true) != ParseResultOk)
|
||||
ProgramFail(Parser, "statement expected");
|
||||
if (LexGetToken(Parser, NULL, FALSE) == TokenElse) {
|
||||
LexGetToken(Parser, NULL, TRUE);
|
||||
if (ParseStatementMaybeRun(Parser, !Condition, TRUE) != ParseResultOk)
|
||||
if (LexGetToken(Parser, NULL, false) == TokenElse) {
|
||||
LexGetToken(Parser, NULL, true);
|
||||
if (ParseStatementMaybeRun(Parser, !Condition, true) != ParseResultOk)
|
||||
ProgramFail(Parser, "statement expected");
|
||||
}
|
||||
CheckTrailingSemicolon = FALSE;
|
||||
CheckTrailingSemicolon = false;
|
||||
break;
|
||||
case TokenWhile:
|
||||
{
|
||||
struct ParseState PreConditional;
|
||||
enum RunMode PreMode = Parser->Mode;
|
||||
if (LexGetToken(Parser, NULL, TRUE) != TokenOpenBracket)
|
||||
if (LexGetToken(Parser, NULL, true) != TokenOpenBracket)
|
||||
ProgramFail(Parser, "'(' expected");
|
||||
ParserCopyPos(&PreConditional, Parser);
|
||||
do {
|
||||
ParserCopyPos(Parser, &PreConditional);
|
||||
Condition = ExpressionParseInt(Parser);
|
||||
if (LexGetToken(Parser, NULL, TRUE) != TokenCloseBracket)
|
||||
if (LexGetToken(Parser, NULL, true) != TokenCloseBracket)
|
||||
ProgramFail(Parser, "')' expected");
|
||||
if (ParseStatementMaybeRun(Parser, Condition, TRUE) != ParseResultOk)
|
||||
if (ParseStatementMaybeRun(Parser, Condition, true) != ParseResultOk)
|
||||
ProgramFail(Parser, "statement expected");
|
||||
if (Parser->Mode == RunModeContinue)
|
||||
Parser->Mode = PreMode;
|
||||
} while (Parser->Mode == RunModeRun && Condition);
|
||||
if (Parser->Mode == RunModeBreak)
|
||||
Parser->Mode = PreMode;
|
||||
CheckTrailingSemicolon = FALSE;
|
||||
CheckTrailingSemicolon = false;
|
||||
}
|
||||
break;
|
||||
case TokenDo:
|
||||
|
@ -631,16 +631,16 @@ enum ParseResult ParseStatement(struct ParseState *Parser, int CheckTrailingSemi
|
|||
ParserCopyPos(&PreStatement, Parser);
|
||||
do {
|
||||
ParserCopyPos(Parser, &PreStatement);
|
||||
if (ParseStatement(Parser, TRUE) != ParseResultOk)
|
||||
if (ParseStatement(Parser, true) != ParseResultOk)
|
||||
ProgramFail(Parser, "statement expected");
|
||||
if (Parser->Mode == RunModeContinue)
|
||||
Parser->Mode = PreMode;
|
||||
if (LexGetToken(Parser, NULL, TRUE) != TokenWhile)
|
||||
if (LexGetToken(Parser, NULL, true) != TokenWhile)
|
||||
ProgramFail(Parser, "'while' expected");
|
||||
if (LexGetToken(Parser, NULL, TRUE) != TokenOpenBracket)
|
||||
if (LexGetToken(Parser, NULL, true) != TokenOpenBracket)
|
||||
ProgramFail(Parser, "'(' expected");
|
||||
Condition = ExpressionParseInt(Parser);
|
||||
if (LexGetToken(Parser, NULL, TRUE) != TokenCloseBracket)
|
||||
if (LexGetToken(Parser, NULL, true) != TokenCloseBracket)
|
||||
ProgramFail(Parser, "')' expected");
|
||||
} while (Condition && Parser->Mode == RunModeRun);
|
||||
if (Parser->Mode == RunModeBreak)
|
||||
|
@ -649,10 +649,10 @@ enum ParseResult ParseStatement(struct ParseState *Parser, int CheckTrailingSemi
|
|||
break;
|
||||
case TokenFor:
|
||||
ParseFor(Parser);
|
||||
CheckTrailingSemicolon = FALSE;
|
||||
CheckTrailingSemicolon = false;
|
||||
break;
|
||||
case TokenSemicolon:
|
||||
CheckTrailingSemicolon = FALSE;
|
||||
CheckTrailingSemicolon = false;
|
||||
break;
|
||||
case TokenIntType:
|
||||
case TokenShortType:
|
||||
|
@ -675,21 +675,21 @@ enum ParseResult ParseStatement(struct ParseState *Parser, int CheckTrailingSemi
|
|||
break;
|
||||
case TokenHashDefine:
|
||||
ParseMacroDefinition(Parser);
|
||||
CheckTrailingSemicolon = FALSE;
|
||||
CheckTrailingSemicolon = false;
|
||||
break;
|
||||
case TokenHashInclude:
|
||||
if (LexGetToken(Parser, &LexerValue, TRUE) != TokenStringConstant)
|
||||
if (LexGetToken(Parser, &LexerValue, true) != TokenStringConstant)
|
||||
ProgramFail(Parser, "\"filename.h\" expected");
|
||||
IncludeFile(Parser->pc, (char *)LexerValue->Val->Pointer);
|
||||
CheckTrailingSemicolon = FALSE;
|
||||
CheckTrailingSemicolon = false;
|
||||
break;
|
||||
case TokenSwitch:
|
||||
if (LexGetToken(Parser, NULL, TRUE) != TokenOpenBracket)
|
||||
if (LexGetToken(Parser, NULL, true) != TokenOpenBracket)
|
||||
ProgramFail(Parser, "'(' expected");
|
||||
Condition = ExpressionParseInt(Parser);
|
||||
if (LexGetToken(Parser, NULL, TRUE) != TokenCloseBracket)
|
||||
if (LexGetToken(Parser, NULL, true) != TokenCloseBracket)
|
||||
ProgramFail(Parser, "')' expected");
|
||||
if (LexGetToken(Parser, NULL, FALSE) != TokenLeftBrace)
|
||||
if (LexGetToken(Parser, NULL, false) != TokenLeftBrace)
|
||||
ProgramFail(Parser, "'{' expected");
|
||||
{
|
||||
/* new block so we can store parser state */
|
||||
|
@ -697,12 +697,12 @@ enum ParseResult ParseStatement(struct ParseState *Parser, int CheckTrailingSemi
|
|||
int OldSearchLabel = Parser->SearchLabel;
|
||||
Parser->Mode = RunModeCaseSearch;
|
||||
Parser->SearchLabel = Condition;
|
||||
ParseBlock(Parser, TRUE, (OldMode != RunModeSkip) && (OldMode != RunModeReturn));
|
||||
ParseBlock(Parser, true, (OldMode != RunModeSkip) && (OldMode != RunModeReturn));
|
||||
if (Parser->Mode != RunModeReturn)
|
||||
Parser->Mode = OldMode;
|
||||
Parser->SearchLabel = OldSearchLabel;
|
||||
}
|
||||
CheckTrailingSemicolon = FALSE;
|
||||
CheckTrailingSemicolon = false;
|
||||
break;
|
||||
case TokenCase:
|
||||
if (Parser->Mode == RunModeCaseSearch) {
|
||||
|
@ -711,18 +711,18 @@ enum ParseResult ParseStatement(struct ParseState *Parser, int CheckTrailingSemi
|
|||
Parser->Mode = RunModeCaseSearch;
|
||||
} else
|
||||
Condition = ExpressionParseInt(Parser);
|
||||
if (LexGetToken(Parser, NULL, TRUE) != TokenColon)
|
||||
if (LexGetToken(Parser, NULL, true) != TokenColon)
|
||||
ProgramFail(Parser, "':' expected");
|
||||
if (Parser->Mode == RunModeCaseSearch && Condition == Parser->SearchLabel)
|
||||
Parser->Mode = RunModeRun;
|
||||
CheckTrailingSemicolon = FALSE;
|
||||
CheckTrailingSemicolon = false;
|
||||
break;
|
||||
case TokenDefault:
|
||||
if (LexGetToken(Parser, NULL, TRUE) != TokenColon)
|
||||
if (LexGetToken(Parser, NULL, true) != TokenColon)
|
||||
ProgramFail(Parser, "':' expected");
|
||||
if (Parser->Mode == RunModeCaseSearch)
|
||||
Parser->Mode = RunModeRun;
|
||||
CheckTrailingSemicolon = FALSE;
|
||||
CheckTrailingSemicolon = false;
|
||||
break;
|
||||
case TokenBreak:
|
||||
if (Parser->Mode == RunModeRun)
|
||||
|
@ -740,7 +740,7 @@ enum ParseResult ParseStatement(struct ParseState *Parser, int CheckTrailingSemi
|
|||
if (!Parser->pc->TopStackFrame) /* return from top-level program? */
|
||||
PlatformExit(Parser->pc, ExpressionCoerceInteger(CValue));
|
||||
else
|
||||
ExpressionAssign(Parser, Parser->pc->TopStackFrame->ReturnValue, CValue, TRUE, NULL, 0, FALSE);
|
||||
ExpressionAssign(Parser, Parser->pc->TopStackFrame->ReturnValue, CValue, true, NULL, 0, false);
|
||||
VariableStackPop(Parser, CValue);
|
||||
} else {
|
||||
if (ExpressionParse(Parser, &CValue))
|
||||
|
@ -755,7 +755,7 @@ enum ParseResult ParseStatement(struct ParseState *Parser, int CheckTrailingSemi
|
|||
ParseTypedef(Parser);
|
||||
break;
|
||||
case TokenGoto:
|
||||
if (LexGetToken(Parser, &LexerValue, TRUE) != TokenIdentifier)
|
||||
if (LexGetToken(Parser, &LexerValue, true) != TokenIdentifier)
|
||||
ProgramFail(Parser, "identifier expected");
|
||||
if (Parser->Mode == RunModeRun) {
|
||||
/* start scanning for the goto label */
|
||||
|
@ -766,7 +766,7 @@ enum ParseResult ParseStatement(struct ParseState *Parser, int CheckTrailingSemi
|
|||
case TokenDelete:
|
||||
{
|
||||
/* try it as a function or variable name to delete */
|
||||
if (LexGetToken(Parser, &LexerValue, TRUE) != TokenIdentifier)
|
||||
if (LexGetToken(Parser, &LexerValue, true) != TokenIdentifier)
|
||||
ProgramFail(Parser, "identifier expected");
|
||||
if (Parser->Mode == RunModeRun) {
|
||||
/* delete this variable or function */
|
||||
|
@ -784,7 +784,7 @@ enum ParseResult ParseStatement(struct ParseState *Parser, int CheckTrailingSemi
|
|||
}
|
||||
|
||||
if (CheckTrailingSemicolon) {
|
||||
if (LexGetToken(Parser, NULL, TRUE) != TokenSemicolon)
|
||||
if (LexGetToken(Parser, NULL, true) != TokenSemicolon)
|
||||
ProgramFail(Parser, "';' expected");
|
||||
}
|
||||
|
||||
|
@ -821,7 +821,7 @@ void PicocParse(Picoc *pc, const char *FileName, const char *Source, int SourceL
|
|||
LexInitParser(&Parser, pc, Source, Tokens, RegFileName, RunIt, EnableDebugger);
|
||||
|
||||
do {
|
||||
Ok = ParseStatement(&Parser, TRUE);
|
||||
Ok = ParseStatement(&Parser, true);
|
||||
} while (Ok == ParseResultOk);
|
||||
|
||||
if (Ok == ParseResultError)
|
||||
|
@ -838,13 +838,13 @@ void PicocParseInteractiveNoStartPrompt(Picoc *pc, int EnableDebugger)
|
|||
enum ParseResult Ok;
|
||||
struct ParseState Parser;
|
||||
|
||||
LexInitParser(&Parser, pc, NULL, NULL, pc->StrEmpty, TRUE, EnableDebugger);
|
||||
LexInitParser(&Parser, pc, NULL, NULL, pc->StrEmpty, true, EnableDebugger);
|
||||
PicocPlatformSetExitPoint(pc);
|
||||
LexInteractiveClear(pc, &Parser);
|
||||
|
||||
do {
|
||||
LexInteractiveStatementPrompt(pc);
|
||||
Ok = ParseStatement(&Parser, TRUE);
|
||||
Ok = ParseStatement(&Parser, true);
|
||||
LexInteractiveCompleted(pc, &Parser);
|
||||
|
||||
} while (Ok == ParseResultOk);
|
||||
|
|
4
picoc.c
4
picoc.c
|
@ -17,7 +17,7 @@
|
|||
int main(int argc, char **argv)
|
||||
{
|
||||
int ParamCount = 1;
|
||||
int DontRunMain = FALSE;
|
||||
int DontRunMain = false;
|
||||
int StackSize = getenv("STACKSIZE") ? atoi(getenv("STACKSIZE")) : PICOC_STACK_SIZE;
|
||||
Picoc pc;
|
||||
|
||||
|
@ -32,7 +32,7 @@ int main(int argc, char **argv)
|
|||
PicocInitialise(&pc, StackSize);
|
||||
|
||||
if (strcmp(argv[ParamCount], "-s") == 0 || strcmp(argv[ParamCount], "-m") == 0) {
|
||||
DontRunMain = TRUE;
|
||||
DontRunMain = true;
|
||||
PicocIncludeAllSystemHeaders(&pc);
|
||||
ParamCount++;
|
||||
}
|
||||
|
|
6
picoc.h
6
picoc.h
|
@ -10,12 +10,6 @@
|
|||
#define PICOC_VERSION "v2.2"
|
||||
#endif
|
||||
|
||||
/* handy definitions */
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#include "interpreter.h"
|
||||
|
||||
|
||||
|
|
18
platform.c
18
platform.c
|
@ -5,9 +5,9 @@
|
|||
#include "interpreter.h"
|
||||
|
||||
#ifdef DEBUGGER
|
||||
static int gEnableDebugger = TRUE;
|
||||
static int gEnableDebugger = true;
|
||||
#else
|
||||
static int gEnableDebugger = FALSE;
|
||||
static int gEnableDebugger = false;
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -68,22 +68,22 @@ void PicocCallMain(Picoc *pc, int argc, char **argv)
|
|||
|
||||
if (FuncValue->Val->FuncDef.NumParams != 0) {
|
||||
/* define the arguments */
|
||||
VariableDefinePlatformVar(pc, NULL, "__argc", &pc->IntType, (union AnyValue *)&argc, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "__argv", pc->CharPtrPtrType, (union AnyValue *)&argv, FALSE);
|
||||
VariableDefinePlatformVar(pc, NULL, "__argc", &pc->IntType, (union AnyValue *)&argc, false);
|
||||
VariableDefinePlatformVar(pc, NULL, "__argv", pc->CharPtrPtrType, (union AnyValue *)&argv, false);
|
||||
}
|
||||
|
||||
if (FuncValue->Val->FuncDef.ReturnType == &pc->VoidType) {
|
||||
if (FuncValue->Val->FuncDef.NumParams == 0)
|
||||
PicocParse(pc, "startup", CALL_MAIN_NO_ARGS_RETURN_VOID, strlen(CALL_MAIN_NO_ARGS_RETURN_VOID), TRUE, TRUE, FALSE, gEnableDebugger);
|
||||
PicocParse(pc, "startup", CALL_MAIN_NO_ARGS_RETURN_VOID, strlen(CALL_MAIN_NO_ARGS_RETURN_VOID), true, true, false, gEnableDebugger);
|
||||
else
|
||||
PicocParse(pc, "startup", CALL_MAIN_WITH_ARGS_RETURN_VOID, strlen(CALL_MAIN_WITH_ARGS_RETURN_VOID), TRUE, TRUE, FALSE, gEnableDebugger);
|
||||
PicocParse(pc, "startup", CALL_MAIN_WITH_ARGS_RETURN_VOID, strlen(CALL_MAIN_WITH_ARGS_RETURN_VOID), true, true, false, gEnableDebugger);
|
||||
} else {
|
||||
VariableDefinePlatformVar(pc, NULL, "__exit_value", &pc->IntType, (union AnyValue *)&pc->PicocExitValue, TRUE);
|
||||
VariableDefinePlatformVar(pc, NULL, "__exit_value", &pc->IntType, (union AnyValue *)&pc->PicocExitValue, true);
|
||||
|
||||
if (FuncValue->Val->FuncDef.NumParams == 0)
|
||||
PicocParse(pc, "startup", CALL_MAIN_NO_ARGS_RETURN_INT, strlen(CALL_MAIN_NO_ARGS_RETURN_INT), TRUE, TRUE, FALSE, gEnableDebugger);
|
||||
PicocParse(pc, "startup", CALL_MAIN_NO_ARGS_RETURN_INT, strlen(CALL_MAIN_NO_ARGS_RETURN_INT), true, true, false, gEnableDebugger);
|
||||
else
|
||||
PicocParse(pc, "startup", CALL_MAIN_WITH_ARGS_RETURN_INT, strlen(CALL_MAIN_WITH_ARGS_RETURN_INT), TRUE, TRUE, FALSE, gEnableDebugger);
|
||||
PicocParse(pc, "startup", CALL_MAIN_WITH_ARGS_RETURN_INT, strlen(CALL_MAIN_WITH_ARGS_RETURN_INT), true, true, false, gEnableDebugger);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <stdarg.h>
|
||||
#include <setjmp.h>
|
||||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/* configurable options */
|
||||
/* select your host type (or do it in the Makefile):
|
||||
|
@ -38,9 +39,9 @@
|
|||
#define ALIGN_TYPE void * /* the default data type to use for alignment */
|
||||
#endif
|
||||
|
||||
# if defined(__powerpc__) || defined(__hppa__) || defined(__sparc__)
|
||||
# define BIG_ENDIAN
|
||||
# endif
|
||||
#if defined(__powerpc__) || defined(__hppa__) || defined(__sparc__)
|
||||
#define BIG_ENDIAN
|
||||
#endif
|
||||
|
||||
#define GLOBAL_TABLE_SIZE (97) /* global variable table */
|
||||
#define STRING_TABLE_SIZE (97) /* shared string table size */
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
#include "../interpreter.h"
|
||||
|
||||
#ifdef DEBUGGER
|
||||
static int gEnableDebugger = TRUE;
|
||||
static int gEnableDebugger = true;
|
||||
#else
|
||||
static int gEnableDebugger = FALSE;
|
||||
static int gEnableDebugger = false;
|
||||
#endif
|
||||
|
||||
/* mark where to end the program for platforms which require this */
|
||||
|
@ -81,7 +81,7 @@ char *PlatformReadFile(Picoc *pc, const char *FileName)
|
|||
void PicocPlatformScanFile(Picoc *pc, const char *FileName)
|
||||
{
|
||||
char *SourceStr = PlatformReadFile(pc, FileName);
|
||||
PicocParse(pc, FileName, SourceStr, strlen(SourceStr), TRUE, FALSE, TRUE, gEnableDebugger);
|
||||
PicocParse(pc, FileName, SourceStr, strlen(SourceStr), true, false, true, gEnableDebugger);
|
||||
}
|
||||
|
||||
/* exit the program */
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
#endif
|
||||
|
||||
#ifdef DEBUGGER
|
||||
static int gEnableDebugger = TRUE;
|
||||
static int gEnableDebugger = true;
|
||||
#else
|
||||
static int gEnableDebugger = FALSE;
|
||||
static int gEnableDebugger = false;
|
||||
#endif
|
||||
|
||||
/* mark where to end the program for platforms which require this */
|
||||
|
@ -22,7 +22,7 @@ Picoc *break_pc = NULL;
|
|||
|
||||
static void BreakHandler(int Signal)
|
||||
{
|
||||
break_pc->DebugManualBreak = TRUE;
|
||||
break_pc->DebugManualBreak = true;
|
||||
}
|
||||
|
||||
void PlatformInit(Picoc *pc)
|
||||
|
@ -126,7 +126,7 @@ void PicocPlatformScanFile(Picoc *pc, const char *FileName)
|
|||
SourceStr[1] = '/';
|
||||
}
|
||||
|
||||
PicocParse(pc, FileName, SourceStr, strlen(SourceStr), TRUE, FALSE, TRUE, gEnableDebugger);
|
||||
PicocParse(pc, FileName, SourceStr, strlen(SourceStr), true, false, true, gEnableDebugger);
|
||||
}
|
||||
|
||||
/* exit the program */
|
||||
|
|
10
table.c
10
table.c
|
@ -6,7 +6,7 @@
|
|||
/* initialise the shared string system */
|
||||
void TableInit(Picoc *pc)
|
||||
{
|
||||
TableInitTable(&pc->StringTable, &pc->StringHashTable[0], STRING_TABLE_SIZE, TRUE);
|
||||
TableInitTable(&pc->StringTable, &pc->StringHashTable[0], STRING_TABLE_SIZE, true);
|
||||
pc->StrEmpty = TableStrRegister(pc, "");
|
||||
}
|
||||
|
||||
|
@ -67,10 +67,10 @@ int TableSet(Picoc *pc, struct Table *Tbl, char *Key, struct Value *Val, const c
|
|||
NewEntry->p.v.Val = Val;
|
||||
NewEntry->Next = Tbl->HashTable[AddAt];
|
||||
Tbl->HashTable[AddAt] = NewEntry;
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* find a value in a table. returns FALSE if not found.
|
||||
|
@ -80,7 +80,7 @@ int TableGet(struct Table *Tbl, const char *Key, struct Value **Val, const char
|
|||
int AddAt;
|
||||
struct TableEntry *FoundEntry = TableSearch(Tbl, Key, &AddAt);
|
||||
if (FoundEntry == NULL)
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
*Val = FoundEntry->p.v.Val;
|
||||
|
||||
|
@ -90,7 +90,7 @@ int TableGet(struct Table *Tbl, const char *Key, struct Value **Val, const char
|
|||
*DeclColumn = FoundEntry->DeclColumn;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* remove an entry from the table */
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/* By Terry R. McConnell (12/2/97) */
|
||||
/* Compile: cc -o hanoi hanoi.c */
|
||||
|
||||
/* This program does no error checking. But then, if it's right,
|
||||
/* This program does no error checking. But then, if it's right,
|
||||
it's right ... right ? */
|
||||
|
||||
|
||||
|
@ -19,7 +19,7 @@ of a smaller one. When the disks have been transferred entirely to another
|
|||
spike the Universe will come to an end in a large thunderclap.
|
||||
|
||||
This paraphrases the original legend due to DeParville, La Nature, Paris 1884,
|
||||
Part I, 285-286. For this and further information see: Mathematical
|
||||
Part I, 285-286. For this and further information see: Mathematical
|
||||
Recreations & Essays, W.W. Rouse Ball, MacMillan, NewYork, 11th Ed. 1967,
|
||||
303-305.
|
||||
*
|
||||
|
@ -29,11 +29,8 @@ Recreations & Essays, W.W. Rouse Ball, MacMillan, NewYork, 11th Ed. 1967,
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
#define N 4 /* This is the number of "disks" on tower A initially. */
|
||||
/* Taken to be 64 in the legend. The number of moves
|
||||
/* Taken to be 64 in the legend. The number of moves
|
||||
required, in general, is 2^N - 1. For N = 64, this is
|
||||
18,446,744,073,709,551,615 */
|
||||
|
||||
|
@ -64,7 +61,7 @@ PrintAll()
|
|||
printf("------------------------------------------\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Move the leftmost nonzero element of source to dest, leave behind 0. */
|
||||
/* Returns the value moved (not used.) */
|
||||
|
||||
|
@ -97,7 +94,7 @@ Hanoi(int n,int *source, int *dest, int *spare)
|
|||
|
||||
Hanoi(n-1,source,spare,dest);
|
||||
Move(source,dest);
|
||||
Hanoi(n-1,spare,dest,source);
|
||||
Hanoi(n-1,spare,dest,source);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -111,7 +108,7 @@ main()
|
|||
for(i=0;i<N;i++)A[i]=i+1;
|
||||
for(i=0;i<N;i++)B[i]=0;
|
||||
for(i=0;i<N;i++)C[i]=0;
|
||||
|
||||
|
||||
printf("Solution of Tower of Hanoi Problem with %d Disks\n\n",N);
|
||||
|
||||
/* Print the starting state */
|
||||
|
|
108
type.c
108
type.c
|
@ -11,7 +11,7 @@ static int IntAlignBytes;
|
|||
/* add a new type to the set of types we know about */
|
||||
struct ValueType *TypeAdd(Picoc *pc, struct ParseState *Parser, struct ValueType *ParentType, enum BaseType Base, int ArraySize, const char *Identifier, int Sizeof, int AlignBytes)
|
||||
{
|
||||
struct ValueType *NewType = VariableAlloc(pc, Parser, sizeof(struct ValueType), TRUE);
|
||||
struct ValueType *NewType = VariableAlloc(pc, Parser, sizeof(struct ValueType), true);
|
||||
NewType->Base = Base;
|
||||
NewType->ArraySize = ArraySize;
|
||||
NewType->Sizeof = Sizeof;
|
||||
|
@ -20,7 +20,7 @@ struct ValueType *TypeAdd(Picoc *pc, struct ParseState *Parser, struct ValueType
|
|||
NewType->Members = NULL;
|
||||
NewType->FromType = ParentType;
|
||||
NewType->DerivedTypeList = NULL;
|
||||
NewType->OnHeap = TRUE;
|
||||
NewType->OnHeap = true;
|
||||
NewType->Next = ParentType->DerivedTypeList;
|
||||
ParentType->DerivedTypeList = NewType;
|
||||
|
||||
|
@ -58,7 +58,7 @@ struct ValueType *TypeGetMatching(Picoc *pc, struct ParseState *Parser, struct V
|
|||
int TypeStackSizeValue(struct Value *Val)
|
||||
{
|
||||
if (Val != NULL && Val->ValOnStack)
|
||||
return TypeSizeValue(Val, FALSE);
|
||||
return TypeSizeValue(Val, false);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ void TypeAddBaseType(Picoc *pc, struct ValueType *TypeNode, enum BaseType Base,
|
|||
TypeNode->Members = NULL;
|
||||
TypeNode->FromType = NULL;
|
||||
TypeNode->DerivedTypeList = NULL;
|
||||
TypeNode->OnHeap = FALSE;
|
||||
TypeNode->OnHeap = false;
|
||||
TypeNode->Next = pc->UberType.DerivedTypeList;
|
||||
pc->UberType.DerivedTypeList = TypeNode;
|
||||
}
|
||||
|
@ -175,21 +175,21 @@ void TypeParseStruct(struct ParseState *Parser, struct ValueType **Typ, int IsSt
|
|||
struct Value *LexValue;
|
||||
struct ValueType *MemberType;
|
||||
|
||||
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(pc, TempNameBuf);
|
||||
}
|
||||
|
||||
*Typ = TypeGetMatching(pc, Parser, &Parser->pc->UberType, IsStruct ? TypeStruct : TypeUnion, 0, StructIdentifier, TRUE);
|
||||
*Typ = TypeGetMatching(pc, Parser, &Parser->pc->UberType, IsStruct ? TypeStruct : TypeUnion, 0, StructIdentifier, true);
|
||||
if (Token == TokenLeftBrace && (*Typ)->Members != NULL)
|
||||
ProgramFail(Parser, "data type '%t' is already defined", *Typ);
|
||||
|
||||
Token = LexGetToken(Parser, NULL, FALSE);
|
||||
Token = LexGetToken(Parser, NULL, false);
|
||||
if (Token != TokenLeftBrace) {
|
||||
/* use the already defined structure */
|
||||
#if 0
|
||||
|
@ -202,17 +202,17 @@ void TypeParseStruct(struct ParseState *Parser, struct ValueType **Typ, int IsSt
|
|||
if (pc->TopStackFrame != NULL)
|
||||
ProgramFail(Parser, "struct/union definitions can only be globals");
|
||||
|
||||
LexGetToken(Parser, NULL, TRUE);
|
||||
(*Typ)->Members = VariableAlloc(pc, Parser, sizeof(struct Table) + STRUCT_TABLE_SIZE * sizeof(struct TableEntry), TRUE);
|
||||
LexGetToken(Parser, NULL, true);
|
||||
(*Typ)->Members = VariableAlloc(pc, 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);
|
||||
TableInitTable((*Typ)->Members, (struct TableEntry**)((char*)(*Typ)->Members + sizeof(struct Table)), STRUCT_TABLE_SIZE, true);
|
||||
|
||||
do {
|
||||
TypeParse(Parser, &MemberType, &MemberIdentifier, NULL);
|
||||
if (MemberType == NULL || MemberIdentifier == NULL)
|
||||
ProgramFail(Parser, "invalid type in struct");
|
||||
|
||||
MemberValue = VariableAllocValueAndData(pc, Parser, sizeof(int), FALSE, NULL, TRUE);
|
||||
MemberValue = VariableAllocValueAndData(pc, Parser, sizeof(int), false, NULL, true);
|
||||
MemberValue->Typ = MemberType;
|
||||
if (IsStruct) {
|
||||
/* allocate this member's location in the struct */
|
||||
|
@ -221,12 +221,12 @@ void TypeParseStruct(struct ParseState *Parser, struct ValueType **Typ, int IsSt
|
|||
(*Typ)->Sizeof += AlignBoundary - ((*Typ)->Sizeof & (AlignBoundary-1));
|
||||
|
||||
MemberValue->Val->Integer = (*Typ)->Sizeof;
|
||||
(*Typ)->Sizeof += TypeSizeValue(MemberValue, TRUE);
|
||||
(*Typ)->Sizeof += TypeSizeValue(MemberValue, true);
|
||||
} else {
|
||||
/* union members always start at 0, make sure it's big enough to hold the largest member */
|
||||
MemberValue->Val->Integer = 0;
|
||||
if (MemberValue->Typ->Sizeof > (*Typ)->Sizeof)
|
||||
(*Typ)->Sizeof = TypeSizeValue(MemberValue, TRUE);
|
||||
(*Typ)->Sizeof = TypeSizeValue(MemberValue, true);
|
||||
}
|
||||
|
||||
/* make sure to align to the size of the largest member's alignment */
|
||||
|
@ -237,28 +237,28 @@ void TypeParseStruct(struct ParseState *Parser, struct ValueType **Typ, int IsSt
|
|||
if (!TableSet(pc, (*Typ)->Members, MemberIdentifier, MemberValue, Parser->FileName, Parser->Line, Parser->CharacterPos))
|
||||
ProgramFail(Parser, "member '%s' already defined", &MemberIdentifier);
|
||||
|
||||
if (LexGetToken(Parser, NULL, TRUE) != TokenSemicolon)
|
||||
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(Picoc *pc, struct ParseState *Parser, const char *StructName, int Size)
|
||||
{
|
||||
struct ValueType *Typ = TypeGetMatching(pc, Parser, &pc->UberType, TypeStruct, 0, StructName, FALSE);
|
||||
struct ValueType *Typ = TypeGetMatching(pc, Parser, &pc->UberType, TypeStruct, 0, StructName, false);
|
||||
|
||||
/* create the (empty) table */
|
||||
Typ->Members = VariableAlloc(pc, Parser, sizeof(struct Table) + STRUCT_TABLE_SIZE * sizeof(struct TableEntry), TRUE);
|
||||
Typ->Members = VariableAlloc(pc, 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);
|
||||
TableInitTable(Typ->Members, (struct TableEntry**)((char*)Typ->Members + sizeof(struct Table)), STRUCT_TABLE_SIZE, true);
|
||||
Typ->Sizeof = Size;
|
||||
|
||||
return Typ;
|
||||
|
@ -274,11 +274,11 @@ void TypeParseEnum(struct ParseState *Parser, struct ValueType **Typ)
|
|||
struct Value InitValue;
|
||||
Picoc *pc = Parser->pc;
|
||||
|
||||
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(pc, TempNameBuf);
|
||||
|
@ -297,24 +297,24 @@ void TypeParseEnum(struct ParseState *Parser, struct ValueType **Typ)
|
|||
if (pc->TopStackFrame != NULL)
|
||||
ProgramFail(Parser, "enum definitions can only be globals");
|
||||
|
||||
LexGetToken(Parser, NULL, TRUE);
|
||||
LexGetToken(Parser, NULL, true);
|
||||
(*Typ)->Members = &pc->GlobalTable;
|
||||
memset((void *)&InitValue, '\0', sizeof(struct Value));
|
||||
InitValue.Typ = &pc->IntType;
|
||||
InitValue.Val = (union AnyValue *)&EnumValue;
|
||||
do {
|
||||
if (LexGetToken(Parser, &LexValue, TRUE) != TokenIdentifier)
|
||||
if (LexGetToken(Parser, &LexValue, true) != TokenIdentifier)
|
||||
ProgramFail(Parser, "identifier expected");
|
||||
|
||||
EnumIdentifier = LexValue->Val->Identifier;
|
||||
if (LexGetToken(Parser, NULL, FALSE) == TokenAssign) {
|
||||
LexGetToken(Parser, NULL, TRUE);
|
||||
if (LexGetToken(Parser, NULL, false) == TokenAssign) {
|
||||
LexGetToken(Parser, NULL, true);
|
||||
EnumValue = ExpressionParseInt(Parser);
|
||||
}
|
||||
|
||||
VariableDefine(pc, Parser, EnumIdentifier, &InitValue, NULL, FALSE);
|
||||
VariableDefine(pc, Parser, EnumIdentifier, &InitValue, NULL, false);
|
||||
|
||||
Token = LexGetToken(Parser, NULL, TRUE);
|
||||
Token = LexGetToken(Parser, NULL, true);
|
||||
if (Token != TokenComma && Token != TokenRightBrace)
|
||||
ProgramFail(Parser, "comma expected");
|
||||
|
||||
|
@ -325,8 +325,8 @@ void TypeParseEnum(struct ParseState *Parser, struct ValueType **Typ)
|
|||
/* parse a type - just the basic type */
|
||||
int TypeParseFront(struct ParseState *Parser, struct ValueType **Typ, int *IsStatic)
|
||||
{
|
||||
int Unsigned = FALSE;
|
||||
int StaticQualifier = FALSE;
|
||||
int Unsigned = false;
|
||||
int StaticQualifier = false;
|
||||
enum LexToken Token;
|
||||
struct ParseState Before;
|
||||
struct Value *LexerValue;
|
||||
|
@ -336,12 +336,12 @@ int TypeParseFront(struct ParseState *Parser, struct ValueType **Typ, int *IsSta
|
|||
|
||||
/* ignore leading type qualifiers */
|
||||
ParserCopy(&Before, Parser);
|
||||
Token = LexGetToken(Parser, &LexerValue, TRUE);
|
||||
Token = LexGetToken(Parser, &LexerValue, true);
|
||||
while (Token == TokenStaticType || Token == TokenAutoType || Token == TokenRegisterType || Token == TokenExternType) {
|
||||
if (Token == TokenStaticType)
|
||||
StaticQualifier = TRUE;
|
||||
StaticQualifier = true;
|
||||
|
||||
Token = LexGetToken(Parser, &LexerValue, TRUE);
|
||||
Token = LexGetToken(Parser, &LexerValue, true);
|
||||
}
|
||||
|
||||
if (IsStatic != NULL)
|
||||
|
@ -349,7 +349,7 @@ int TypeParseFront(struct ParseState *Parser, struct ValueType **Typ, int *IsSta
|
|||
|
||||
/* 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 && FollowToken != TokenShortType && FollowToken != TokenCharType) {
|
||||
|
@ -358,10 +358,10 @@ int TypeParseFront(struct ParseState *Parser, struct ValueType **Typ, int *IsSta
|
|||
else
|
||||
*Typ = &pc->IntType;
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
Token = LexGetToken(Parser, &LexerValue, TRUE);
|
||||
Token = LexGetToken(Parser, &LexerValue, true);
|
||||
}
|
||||
|
||||
switch (Token) {
|
||||
|
@ -391,10 +391,10 @@ int TypeParseFront(struct ParseState *Parser, struct ValueType **Typ, int *IsSta
|
|||
*Typ = VarValue->Val->Typ;
|
||||
break;
|
||||
|
||||
default: ParserCopy(Parser, &Before); return FALSE;
|
||||
default: ParserCopy(Parser, &Before); return false;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* parse a type - the part at the end after the identifier. eg. array specifications etc. */
|
||||
|
@ -404,13 +404,13 @@ struct ValueType *TypeParseBack(struct ParseState *Parser, struct ValueType *Fro
|
|||
struct ParseState Before;
|
||||
|
||||
ParserCopy(&Before, Parser);
|
||||
Token = LexGetToken(Parser, NULL, TRUE);
|
||||
Token = LexGetToken(Parser, NULL, true);
|
||||
if (Token == TokenLeftSquareBracket) {
|
||||
/* add another array bound */
|
||||
if (LexGetToken(Parser, NULL, FALSE) == TokenRightSquareBracket) {
|
||||
if (LexGetToken(Parser, NULL, false) == TokenRightSquareBracket) {
|
||||
/* an unsized array */
|
||||
LexGetToken(Parser, NULL, TRUE);
|
||||
return TypeGetMatching(Parser->pc, Parser, TypeParseBack(Parser, FromType), TypeArray, 0, Parser->pc->StrEmpty, TRUE);
|
||||
LexGetToken(Parser, NULL, true);
|
||||
return TypeGetMatching(Parser->pc, Parser, TypeParseBack(Parser, FromType), TypeArray, 0, Parser->pc->StrEmpty, true);
|
||||
} else {
|
||||
/* get a numeric array size */
|
||||
enum RunMode OldMode = Parser->Mode;
|
||||
|
@ -419,10 +419,10 @@ struct ValueType *TypeParseBack(struct ParseState *Parser, struct ValueType *Fro
|
|||
ArraySize = ExpressionParseInt(Parser);
|
||||
Parser->Mode = OldMode;
|
||||
|
||||
if (LexGetToken(Parser, NULL, TRUE) != TokenRightSquareBracket)
|
||||
if (LexGetToken(Parser, NULL, true) != TokenRightSquareBracket)
|
||||
ProgramFail(Parser, "']' expected");
|
||||
|
||||
return TypeGetMatching(Parser->pc, Parser, TypeParseBack(Parser, FromType), TypeArray, ArraySize, Parser->pc->StrEmpty, TRUE);
|
||||
return TypeGetMatching(Parser->pc, Parser, TypeParseBack(Parser, FromType), TypeArray, ArraySize, Parser->pc->StrEmpty, true);
|
||||
}
|
||||
} else {
|
||||
/* the type specification has finished */
|
||||
|
@ -434,7 +434,7 @@ struct ValueType *TypeParseBack(struct ParseState *Parser, struct ValueType *Fro
|
|||
/* 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)
|
||||
{
|
||||
int Done = FALSE;
|
||||
int Done = false;
|
||||
enum LexToken Token;
|
||||
struct Value *LexValue;
|
||||
struct ParseState Before;
|
||||
|
@ -443,14 +443,14 @@ void TypeParseIdentPart(struct ParseState *Parser, struct ValueType *BasicTyp, s
|
|||
|
||||
while (!Done) {
|
||||
ParserCopy(&Before, Parser);
|
||||
Token = LexGetToken(Parser, &LexValue, TRUE);
|
||||
Token = LexGetToken(Parser, &LexValue, true);
|
||||
switch (Token) {
|
||||
case TokenOpenBracket:
|
||||
if (*Typ != NULL)
|
||||
ProgramFail(Parser, "bad type declaration");
|
||||
|
||||
TypeParse(Parser, Typ, Identifier, NULL);
|
||||
if (LexGetToken(Parser, NULL, TRUE) != TokenCloseBracket)
|
||||
if (LexGetToken(Parser, NULL, true) != TokenCloseBracket)
|
||||
ProgramFail(Parser, "')' expected");
|
||||
break;
|
||||
|
||||
|
@ -458,7 +458,7 @@ void TypeParseIdentPart(struct ParseState *Parser, struct ValueType *BasicTyp, s
|
|||
if (*Typ == NULL)
|
||||
ProgramFail(Parser, "bad type declaration");
|
||||
|
||||
*Typ = TypeGetMatching(Parser->pc, Parser, *Typ, TypePointer, 0, Parser->pc->StrEmpty, TRUE);
|
||||
*Typ = TypeGetMatching(Parser->pc, Parser, *Typ, TypePointer, 0, Parser->pc->StrEmpty, true);
|
||||
break;
|
||||
|
||||
case TokenIdentifier:
|
||||
|
@ -466,10 +466,10 @@ void TypeParseIdentPart(struct ParseState *Parser, struct ValueType *BasicTyp, s
|
|||
ProgramFail(Parser, "bad type declaration");
|
||||
|
||||
*Identifier = LexValue->Val->Identifier;
|
||||
Done = TRUE;
|
||||
Done = true;
|
||||
break;
|
||||
|
||||
default: ParserCopy(Parser, &Before); Done = TRUE; break;
|
||||
default: ParserCopy(Parser, &Before); Done = true; break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -498,7 +498,7 @@ int TypeIsForwardDeclared(struct ParseState *Parser, struct ValueType *Typ)
|
|||
return TypeIsForwardDeclared(Parser, Typ->FromType);
|
||||
|
||||
if ( (Typ->Base == TypeStruct || Typ->Base == TypeUnion) && Typ->Members == NULL)
|
||||
return TRUE;
|
||||
return true;
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
|
62
variable.c
62
variable.c
|
@ -10,8 +10,8 @@
|
|||
/* initialise the variable system */
|
||||
void VariableInit(Picoc *pc)
|
||||
{
|
||||
TableInitTable(&(pc->GlobalTable), &(pc->GlobalHashTable)[0], GLOBAL_TABLE_SIZE, TRUE);
|
||||
TableInitTable(&pc->StringLiteralTable, &pc->StringLiteralHashTable[0], STRING_LITERAL_TABLE_SIZE, TRUE);
|
||||
TableInitTable(&(pc->GlobalTable), &(pc->GlobalHashTable)[0], GLOBAL_TABLE_SIZE, true);
|
||||
TableInitTable(&pc->StringLiteralTable, &pc->StringLiteralHashTable[0], STRING_LITERAL_TABLE_SIZE, true);
|
||||
pc->TopStackFrame = NULL;
|
||||
}
|
||||
|
||||
|
@ -88,14 +88,14 @@ struct Value *VariableAllocValueAndData(Picoc *pc, struct ParseState *Parser, in
|
|||
struct Value *NewValue = VariableAlloc(pc, Parser, MEM_ALIGN(sizeof(struct Value)) + DataSize, OnHeap);
|
||||
NewValue->Val = (union AnyValue*)((char*)NewValue + MEM_ALIGN(sizeof(struct Value)));
|
||||
NewValue->ValOnHeap = OnHeap;
|
||||
NewValue->AnyValOnHeap = FALSE;
|
||||
NewValue->AnyValOnHeap = false;
|
||||
NewValue->ValOnStack = !OnHeap;
|
||||
NewValue->IsLValue = IsLValue;
|
||||
NewValue->LValueFrom = LValueFrom;
|
||||
if (Parser)
|
||||
NewValue->ScopeID = Parser->ScopeID;
|
||||
|
||||
NewValue->OutOfScope = FALSE;
|
||||
NewValue->OutOfScope = false;
|
||||
|
||||
return NewValue;
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ struct Value *VariableAllocValueAndData(Picoc *pc, struct ParseState *Parser, in
|
|||
/* allocate a value given its type */
|
||||
struct Value *VariableAllocValueFromType(Picoc *pc, struct ParseState *Parser, struct ValueType *Typ, int IsLValue, struct Value *LValueFrom, int OnHeap)
|
||||
{
|
||||
int Size = TypeSize(Typ, Typ->ArraySize, FALSE);
|
||||
int Size = TypeSize(Typ, Typ->ArraySize, false);
|
||||
struct Value *NewValue = VariableAllocValueAndData(pc, Parser, Size, IsLValue, LValueFrom, OnHeap);
|
||||
assert(Size >= 0 || Typ == &pc->VoidType);
|
||||
NewValue->Typ = Typ;
|
||||
|
@ -114,7 +114,7 @@ struct Value *VariableAllocValueFromType(Picoc *pc, struct ParseState *Parser, s
|
|||
/* allocate a value either on the heap or the stack and copy its value. handles overlapping data */
|
||||
struct Value *VariableAllocValueAndCopy(Picoc *pc, struct ParseState *Parser, struct Value *FromValue, int OnHeap)
|
||||
{
|
||||
int CopySize = TypeSizeValue(FromValue, TRUE);
|
||||
int CopySize = TypeSizeValue(FromValue, true);
|
||||
char TmpBuf[MAX_TMP_COPY_BUF];
|
||||
struct ValueType *DType = FromValue->Typ;
|
||||
struct Value *NewValue;
|
||||
|
@ -131,12 +131,12 @@ struct Value *VariableAllocValueAndCopy(Picoc *pc, struct ParseState *Parser, st
|
|||
/* allocate a value either on the heap or the stack from an existing AnyValue and type */
|
||||
struct Value *VariableAllocValueFromExistingData(struct ParseState *Parser, struct ValueType *Typ, union AnyValue *FromValue, int IsLValue, struct Value *LValueFrom)
|
||||
{
|
||||
struct Value *NewValue = VariableAlloc(Parser->pc, Parser, sizeof(struct Value), FALSE);
|
||||
struct Value *NewValue = VariableAlloc(Parser->pc, Parser, sizeof(struct Value), false);
|
||||
NewValue->Typ = Typ;
|
||||
NewValue->Val = FromValue;
|
||||
NewValue->ValOnHeap = FALSE;
|
||||
NewValue->AnyValOnHeap = FALSE;
|
||||
NewValue->ValOnStack = FALSE;
|
||||
NewValue->ValOnHeap = false;
|
||||
NewValue->AnyValOnHeap = false;
|
||||
NewValue->ValOnStack = false;
|
||||
NewValue->IsLValue = IsLValue;
|
||||
NewValue->LValueFrom = LValueFrom;
|
||||
|
||||
|
@ -155,8 +155,8 @@ void VariableRealloc(struct ParseState *Parser, struct Value *FromValue, int New
|
|||
if (FromValue->AnyValOnHeap)
|
||||
HeapFreeMem(Parser->pc, FromValue->Val);
|
||||
|
||||
FromValue->Val = VariableAlloc(Parser->pc, Parser, NewSize, TRUE);
|
||||
FromValue->AnyValOnHeap = TRUE;
|
||||
FromValue->Val = VariableAlloc(Parser->pc, Parser, NewSize, true);
|
||||
FromValue->AnyValOnHeap = true;
|
||||
}
|
||||
|
||||
int VariableScopeBegin(struct ParseState *Parser, int* OldScopeID)
|
||||
|
@ -182,8 +182,8 @@ int VariableScopeBegin(struct ParseState *Parser, int* OldScopeID)
|
|||
for (Count = 0; Count < HashTable->Size; Count++) {
|
||||
for (Entry = HashTable->HashTable[Count]; Entry != NULL; Entry = NextEntry) {
|
||||
NextEntry = Entry->Next;
|
||||
if (Entry->p.v.Val->ScopeID == Parser->ScopeID && Entry->p.v.Val->OutOfScope == TRUE) {
|
||||
Entry->p.v.Val->OutOfScope = FALSE;
|
||||
if (Entry->p.v.Val->ScopeID == Parser->ScopeID && Entry->p.v.Val->OutOfScope == true) {
|
||||
Entry->p.v.Val->OutOfScope = false;
|
||||
Entry->p.v.Key = (char*)((intptr_t)Entry->p.v.Key & ~1);
|
||||
#ifdef DEBUG_VAR_SCOPE
|
||||
if (!FirstPrint) PRINT_SOURCE_POS();
|
||||
|
@ -214,13 +214,13 @@ void VariableScopeEnd(struct ParseState *Parser, int ScopeID, int PrevScopeID)
|
|||
for (Count = 0; Count < HashTable->Size; Count++) {
|
||||
for (Entry = HashTable->HashTable[Count]; Entry != NULL; Entry = NextEntry) {
|
||||
NextEntry = Entry->Next;
|
||||
if ((Entry->p.v.Val->ScopeID == ScopeID) && (Entry->p.v.Val->OutOfScope == FALSE)) {
|
||||
if ((Entry->p.v.Val->ScopeID == ScopeID) && (Entry->p.v.Val->OutOfScope == false)) {
|
||||
#ifdef DEBUG_VAR_SCOPE
|
||||
if (!FirstPrint) PRINT_SOURCE_POS();
|
||||
FirstPrint = 1;
|
||||
printf(">>> out of scope: %s %x %d\n", Entry->p.v.Key, Entry->p.v.Val->ScopeID, Entry->p.v.Val->Val->Integer);
|
||||
#endif
|
||||
Entry->p.v.Val->OutOfScope = TRUE;
|
||||
Entry->p.v.Val->OutOfScope = true;
|
||||
Entry->p.v.Key = (char*)((intptr_t)Entry->p.v.Key | 1); /* alter the key so it won't be found by normal searches */
|
||||
}
|
||||
}
|
||||
|
@ -237,11 +237,11 @@ int VariableDefinedAndOutOfScope(Picoc * pc, const char* Ident)
|
|||
struct Table * HashTable = (pc->TopStackFrame == NULL) ? &(pc->GlobalTable) : &(pc->TopStackFrame)->LocalTable;
|
||||
for (Count = 0; Count < HashTable->Size; Count++) {
|
||||
for (Entry = HashTable->HashTable[Count]; Entry != NULL; Entry = Entry->Next) {
|
||||
if (Entry->p.v.Val->OutOfScope == TRUE && (char*)((intptr_t)Entry->p.v.Key & ~1) == Ident)
|
||||
return TRUE;
|
||||
if (Entry->p.v.Val->OutOfScope == true && (char*)((intptr_t)Entry->p.v.Key & ~1) == Ident)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* define a variable. Ident must be registered */
|
||||
|
@ -262,7 +262,7 @@ struct Value *VariableDefine(Picoc *pc, struct ParseState *Parser, char *Ident,
|
|||
|
||||
AssignValue->IsLValue = MakeWritable;
|
||||
AssignValue->ScopeID = ScopeID;
|
||||
AssignValue->OutOfScope = FALSE;
|
||||
AssignValue->OutOfScope = false;
|
||||
|
||||
if (!TableSet(pc, currentTable, Ident, AssignValue, Parser ? ((char*)Parser->FileName) : NULL, Parser ? Parser->Line : 0, Parser ? Parser->CharacterPos : 0))
|
||||
ProgramFail(Parser, "'%s' is already defined", Ident);
|
||||
|
@ -309,20 +309,20 @@ struct Value *VariableDefineButIgnoreIdentical(struct ParseState *Parser, char *
|
|||
/* is this static already defined? */
|
||||
if (!TableGet(&pc->GlobalTable, RegisteredMangledName, &ExistingValue, &DeclFileName, &DeclLine, &DeclColumn)) {
|
||||
/* define the mangled-named static variable store in the global scope */
|
||||
ExistingValue = VariableAllocValueFromType(Parser->pc, Parser, Typ, TRUE, NULL, TRUE);
|
||||
ExistingValue = VariableAllocValueFromType(Parser->pc, Parser, Typ, true, NULL, true);
|
||||
TableSet(pc, &pc->GlobalTable, (char*)RegisteredMangledName, ExistingValue, (char *)Parser->FileName, Parser->Line, Parser->CharacterPos);
|
||||
*FirstVisit = TRUE;
|
||||
*FirstVisit = true;
|
||||
}
|
||||
|
||||
/* static variable exists in the global scope - now make a mirroring variable in our own scope with the short name */
|
||||
VariableDefinePlatformVar(Parser->pc, Parser, Ident, ExistingValue->Typ, ExistingValue->Val, TRUE);
|
||||
VariableDefinePlatformVar(Parser->pc, Parser, Ident, ExistingValue->Typ, ExistingValue->Val, true);
|
||||
return ExistingValue;
|
||||
} else {
|
||||
if (Parser->Line != 0 && TableGet((pc->TopStackFrame == NULL) ? &pc->GlobalTable : &pc->TopStackFrame->LocalTable, Ident, &ExistingValue, &DeclFileName, &DeclLine, &DeclColumn)
|
||||
&& DeclFileName == Parser->FileName && DeclLine == Parser->Line && DeclColumn == Parser->CharacterPos)
|
||||
return ExistingValue;
|
||||
else
|
||||
return VariableDefine(Parser->pc, Parser, Ident, NULL, Typ, TRUE);
|
||||
return VariableDefine(Parser->pc, Parser, Ident, NULL, Typ, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -333,10 +333,10 @@ int VariableDefined(Picoc *pc, const char *Ident)
|
|||
|
||||
if (pc->TopStackFrame == NULL || !TableGet(&pc->TopStackFrame->LocalTable, Ident, &FoundValue, NULL, NULL, NULL)) {
|
||||
if (!TableGet(&pc->GlobalTable, Ident, &FoundValue, NULL, NULL, NULL))
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* get the value of a variable. must be defined. Ident must be registered */
|
||||
|
@ -355,7 +355,7 @@ void VariableGet(Picoc *pc, struct ParseState *Parser, const char *Ident, struct
|
|||
/* define a global variable shared with a platform global. Ident will be registered */
|
||||
void VariableDefinePlatformVar(Picoc *pc, struct ParseState *Parser, char *Ident, struct ValueType *Typ, union AnyValue *FromValue, int IsWritable)
|
||||
{
|
||||
struct Value *SomeValue = VariableAllocValueAndData(pc, NULL, 0, IsWritable, NULL, TRUE);
|
||||
struct Value *SomeValue = VariableAllocValueAndData(pc, NULL, 0, IsWritable, NULL, true);
|
||||
SomeValue->Typ = Typ;
|
||||
SomeValue->Val = FromValue;
|
||||
|
||||
|
@ -370,7 +370,7 @@ void VariableStackPop(struct ParseState *Parser, struct Value *Var)
|
|||
|
||||
#ifdef DEBUG_HEAP
|
||||
if (Var->ValOnStack)
|
||||
printf("popping %ld at 0x%lx\n", (unsigned long)(sizeof(struct Value) + TypeSizeValue(Var, FALSE)), (unsigned long)Var);
|
||||
printf("popping %ld at 0x%lx\n", (unsigned long)(sizeof(struct Value) + TypeSizeValue(Var, false)), (unsigned long)Var);
|
||||
#endif
|
||||
|
||||
if (Var->ValOnHeap) {
|
||||
|
@ -379,7 +379,7 @@ void VariableStackPop(struct ParseState *Parser, struct Value *Var)
|
|||
|
||||
Success = HeapPopStack(Parser->pc, Var, sizeof(struct Value)); /* free from heap */
|
||||
} else if (Var->ValOnStack)
|
||||
Success = HeapPopStack(Parser->pc, Var, sizeof(struct Value) + TypeSizeValue(Var, FALSE)); /* free from stack */
|
||||
Success = HeapPopStack(Parser->pc, Var, sizeof(struct Value) + TypeSizeValue(Var, false)); /* free from stack */
|
||||
else
|
||||
Success = HeapPopStack(Parser->pc, Var, sizeof(struct Value)); /* value isn't our problem */
|
||||
|
||||
|
@ -400,7 +400,7 @@ void VariableStackFrameAdd(struct ParseState *Parser, const char *FuncName, int
|
|||
ParserCopy(&NewFrame->ReturnParser, Parser);
|
||||
NewFrame->FuncName = FuncName;
|
||||
NewFrame->Parameter = (NumParams > 0) ? ((void*)((char *)NewFrame + sizeof(struct StackFrame))) : NULL;
|
||||
TableInitTable(&NewFrame->LocalTable, &NewFrame->LocalHashTable[0], LOCAL_TABLE_SIZE, FALSE);
|
||||
TableInitTable(&NewFrame->LocalTable, &NewFrame->LocalHashTable[0], LOCAL_TABLE_SIZE, false);
|
||||
NewFrame->PreviousStackFrame = Parser->pc->TopStackFrame;
|
||||
Parser->pc->TopStackFrame = NewFrame;
|
||||
}
|
||||
|
@ -446,7 +446,7 @@ void *VariableDereferencePointer(struct ParseState *Parser, struct Value *Pointe
|
|||
*DerefOffset = 0;
|
||||
|
||||
if (DerefIsLValue != NULL)
|
||||
*DerefIsLValue = TRUE;
|
||||
*DerefIsLValue = true;
|
||||
|
||||
return PointerValue->Val->Pointer;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue