remove NO_FP checks; assume at least softfp, remove NO_MODULUS
This commit is contained in:
parent
c063462464
commit
b2d468537e
|
@ -61,9 +61,7 @@ void PrintType(struct ValueType *Typ, IOFILE *Stream)
|
|||
case TypeUnsignedShort: PrintStr("unsigned short", Stream); break;
|
||||
case TypeUnsignedLong: PrintStr("unsigned long", Stream); break;
|
||||
case TypeUnsignedChar: PrintStr("unsigned char", Stream); break;
|
||||
#ifndef NO_FP
|
||||
case TypeFP: PrintStr("double", Stream); break;
|
||||
#endif
|
||||
case TypeFunction: PrintStr("function", Stream); break;
|
||||
case TypeMacro: PrintStr("macro", Stream); break;
|
||||
case TypePointer: if (Typ->FromType) PrintType(Typ->FromType, Stream); PrintCh('*', Stream); break;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
/* stdio.h library for large systems - small embedded systems use clibrary.c instead */
|
||||
#include "../interpreter.h"
|
||||
|
||||
#ifndef NO_FP
|
||||
|
||||
static double M_EValue = 2.7182818284590452354; /* e */
|
||||
static double M_LOG2EValue = 1.4426950408889634074; /* log_2 e */
|
||||
|
@ -181,5 +180,3 @@ void MathSetupFunc(Picoc *pc)
|
|||
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);
|
||||
}
|
||||
|
||||
#endif /* !NO_FP */
|
||||
|
|
|
@ -189,11 +189,9 @@ int StdioBasePrintf(struct ParseState *Parser, FILE *Stream, char *StrOut, int S
|
|||
switch (*FPos) {
|
||||
case 'd': case 'i': ShowType = &pc->IntType; break; /* integer decimal */
|
||||
case 'o': case 'u': case 'x': case 'X': ShowType = &pc->IntType; break; /* integer base conversions */
|
||||
#ifndef NO_FP
|
||||
case 'e': case 'E': ShowType = &pc->FPType; break; /* double, exponent form */
|
||||
case 'f': case 'F': ShowType = &pc->FPType; break; /* double, fixed-point */
|
||||
case 'g': case 'G': ShowType = &pc->FPType; break; /* double, flexible format */
|
||||
#endif
|
||||
case 'a': case 'A': ShowType = &pc->IntType; break; /* hexadecimal, 0x- format */
|
||||
case 'c': ShowType = &pc->IntType; break; /* character */
|
||||
case 's': ShowType = pc->CharPtrType; break; /* string */
|
||||
|
@ -241,17 +239,13 @@ int StdioBasePrintf(struct ParseState *Parser, FILE *Stream, char *StrOut, int S
|
|||
StdioFprintfWord(&SOStream, OneFormatBuf, ExpressionCoerceUnsignedInteger(ThisArg));
|
||||
else
|
||||
StdioOutPuts("XXX", &SOStream);
|
||||
}
|
||||
#ifndef NO_FP
|
||||
else if (ShowType == &pc->FPType) {
|
||||
} else if (ShowType == &pc->FPType) {
|
||||
/* show a floating point number */
|
||||
if (IS_NUMERIC_COERCIBLE(ThisArg))
|
||||
StdioFprintfFP(&SOStream, OneFormatBuf, ExpressionCoerceFP(ThisArg));
|
||||
else
|
||||
StdioOutPuts("XXX", &SOStream);
|
||||
}
|
||||
#endif
|
||||
else if (ShowType == pc->CharPtrType) {
|
||||
} else if (ShowType == pc->CharPtrType) {
|
||||
if (ThisArg->Typ->Base == TypePointer)
|
||||
StdioFprintfPointer(&SOStream, OneFormatBuf, ThisArg->Val->Pointer);
|
||||
else if (ThisArg->Typ->Base == TypeArray && ThisArg->Typ->FromType->Base == TypeChar)
|
||||
|
|
|
@ -4,12 +4,11 @@
|
|||
|
||||
static int Stdlib_ZeroValue = 0;
|
||||
|
||||
#ifndef NO_FP
|
||||
|
||||
void StdlibAtof(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
ReturnValue->Val->FP = atof(Param[0]->Val->Pointer);
|
||||
}
|
||||
#endif
|
||||
|
||||
void StdlibAtoi(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
|
@ -21,12 +20,10 @@ void StdlibAtol(struct ParseState *Parser, struct Value *ReturnValue, struct Val
|
|||
ReturnValue->Val->Integer = atol(Param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
#ifndef NO_FP
|
||||
void StdlibStrtod(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
ReturnValue->Val->FP = strtod(Param[0]->Val->Pointer, Param[1]->Val->Pointer);
|
||||
}
|
||||
#endif
|
||||
|
||||
void StdlibStrtol(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
|
@ -133,10 +130,8 @@ typedef struct { \
|
|||
/* all stdlib.h functions */
|
||||
struct LibraryFunction StdlibFunctions[] =
|
||||
{
|
||||
#ifndef NO_FP
|
||||
{StdlibAtof, "float atof(char *);"},
|
||||
{StdlibStrtod, "float strtod(char *,char **);"},
|
||||
#endif
|
||||
{StdlibAtoi, "int atoi(char *);"},
|
||||
{StdlibAtol, "int atol(char *);"},
|
||||
{StdlibStrtol, "int strtol(char *,char **,int);"},
|
||||
|
|
|
@ -28,12 +28,10 @@ void StdCtime(struct ParseState *Parser, struct Value *ReturnValue, struct Value
|
|||
ReturnValue->Val->Pointer = ctime(Param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
#ifndef NO_FP
|
||||
void StdDifftime(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
ReturnValue->Val->FP = difftime((time_t)Param[0]->Val->Integer, Param[1]->Val->Integer);
|
||||
}
|
||||
#endif
|
||||
|
||||
void StdGmtime(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
|
@ -91,9 +89,7 @@ struct LibraryFunction StdTimeFunctions[] =
|
|||
{StdAsctime, "char *asctime(struct tm *);"},
|
||||
{StdClock, "time_t clock();"},
|
||||
{StdCtime, "char *ctime(int *);"},
|
||||
#ifndef NO_FP
|
||||
{StdDifftime, "double difftime(int, int);"},
|
||||
#endif
|
||||
{StdGmtime, "struct tm *gmtime(int *);"},
|
||||
{StdLocaltime, "struct tm *localtime(int *);"},
|
||||
{StdMktime, "int mktime(struct tm *ptm);"},
|
||||
|
|
40
expression.c
40
expression.c
|
@ -183,9 +183,7 @@ long ExpressionCoerceInteger(struct Value *Val)
|
|||
case TypeUnsignedLong: return (long)Val->Val->UnsignedLongInteger;
|
||||
case TypeUnsignedChar: return (long)Val->Val->UnsignedCharacter;
|
||||
case TypePointer: return (long)Val->Val->Pointer;
|
||||
#ifndef NO_FP
|
||||
case TypeFP: return (long)Val->Val->FP;
|
||||
#endif
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
@ -202,14 +200,11 @@ unsigned long ExpressionCoerceUnsignedInteger(struct Value *Val)
|
|||
case TypeUnsignedLong: return (unsigned long)Val->Val->UnsignedLongInteger;
|
||||
case TypeUnsignedChar: return (unsigned long)Val->Val->UnsignedCharacter;
|
||||
case TypePointer: return (unsigned long)Val->Val->Pointer;
|
||||
#ifndef NO_FP
|
||||
case TypeFP: return (unsigned long)Val->Val->FP;
|
||||
#endif
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NO_FP
|
||||
double ExpressionCoerceFP(struct Value *Val)
|
||||
{
|
||||
#ifndef BROKEN_FLOAT_CASTS
|
||||
|
@ -243,7 +238,6 @@ double ExpressionCoerceFP(struct Value *Val)
|
|||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/* assign an integer value */
|
||||
long ExpressionAssignInt(struct ParseState *Parser, struct Value *DestValue, long FromInt, int After)
|
||||
|
@ -272,7 +266,6 @@ long ExpressionAssignInt(struct ParseState *Parser, struct Value *DestValue, lon
|
|||
return Result;
|
||||
}
|
||||
|
||||
#ifndef NO_FP
|
||||
/* assign a floating point value */
|
||||
double ExpressionAssignFP(struct ParseState *Parser, struct Value *DestValue, double FromFP)
|
||||
{
|
||||
|
@ -282,7 +275,6 @@ double ExpressionAssignFP(struct ParseState *Parser, struct Value *DestValue, do
|
|||
DestValue->Val->FP = FromFP;
|
||||
return FromFP;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* push a node on to the expression stack */
|
||||
void ExpressionStackPushValueNode(struct ParseState *Parser, struct ExpressionStack **StackTop, struct Value *ValueLoc)
|
||||
|
@ -345,14 +337,12 @@ void ExpressionPushInt(struct ParseState *Parser, struct ExpressionStack **Stack
|
|||
ExpressionStackPushValueNode(Parser, StackTop, ValueLoc);
|
||||
}
|
||||
|
||||
#ifndef NO_FP
|
||||
void ExpressionPushFP(struct ParseState *Parser, struct ExpressionStack **StackTop, double FPValue)
|
||||
{
|
||||
struct Value *ValueLoc = VariableAllocValueFromType(Parser->pc, Parser, &Parser->pc->FPType, FALSE, NULL, FALSE);
|
||||
ValueLoc->Val->FP = FPValue;
|
||||
ExpressionStackPushValueNode(Parser, StackTop, ValueLoc);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* assign to a pointer */
|
||||
void ExpressionAssignToPointer(struct ParseState *Parser, struct Value *ToValue, struct Value *FromValue, const char *FuncName, int ParamNo, int AllowPointerCoercion)
|
||||
|
@ -399,14 +389,12 @@ void ExpressionAssign(struct ParseState *Parser, struct Value *DestValue, struct
|
|||
case TypeUnsignedShort: DestValue->Val->UnsignedShortInteger = (unsigned short)ExpressionCoerceUnsignedInteger(SourceValue); break;
|
||||
case TypeUnsignedLong: DestValue->Val->UnsignedLongInteger = ExpressionCoerceUnsignedInteger(SourceValue); break;
|
||||
case TypeUnsignedChar: DestValue->Val->UnsignedCharacter = (unsigned char)ExpressionCoerceUnsignedInteger(SourceValue); break;
|
||||
#ifndef NO_FP
|
||||
case TypeFP:
|
||||
if (!IS_NUMERIC_COERCIBLE_PLUS_POINTERS(SourceValue, AllowPointerCoercion))
|
||||
AssignFail(Parser, "%t from %t", DestValue->Typ, SourceValue->Typ, 0, 0, FuncName, ParamNo);
|
||||
|
||||
DestValue->Val->FP = ExpressionCoerceFP(SourceValue);
|
||||
break;
|
||||
#endif
|
||||
case TypePointer:
|
||||
ExpressionAssignToPointer(Parser, DestValue, SourceValue, FuncName, ParamNo, AllowPointerCoercion);
|
||||
break;
|
||||
|
@ -530,7 +518,6 @@ void ExpressionPrefixOperator(struct ParseState *Parser, struct ExpressionStack
|
|||
|
||||
default:
|
||||
/* an arithmetic operator */
|
||||
#ifndef NO_FP
|
||||
if (TopValue->Typ == &Parser->pc->FPType) {
|
||||
/* floating point prefix arithmetic */
|
||||
double ResultFP = 0.0;
|
||||
|
@ -545,9 +532,7 @@ void ExpressionPrefixOperator(struct ParseState *Parser, struct ExpressionStack
|
|||
}
|
||||
|
||||
ExpressionPushFP(Parser, StackTop, ResultFP);
|
||||
} else
|
||||
#endif
|
||||
if (IS_NUMERIC_COERCIBLE(TopValue)) {
|
||||
} else if (IS_NUMERIC_COERCIBLE(TopValue)) {
|
||||
/* integer prefix arithmetic */
|
||||
long ResultInt = 0;
|
||||
long TopInt = ExpressionCoerceInteger(TopValue);
|
||||
|
@ -595,7 +580,7 @@ void ExpressionPostfixOperator(struct ParseState *Parser, struct ExpressionStack
|
|||
#ifdef DEBUG_EXPRESSIONS
|
||||
printf("ExpressionPostfixOperator()\n");
|
||||
#endif
|
||||
#ifndef NO_FP
|
||||
|
||||
if (TopValue->Typ == &Parser->pc->FPType) {
|
||||
/* floating point prefix arithmetic */
|
||||
double ResultFP = 0.0;
|
||||
|
@ -608,9 +593,7 @@ void ExpressionPostfixOperator(struct ParseState *Parser, struct ExpressionStack
|
|||
|
||||
ExpressionPushFP(Parser, StackTop, ResultFP);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (IS_NUMERIC_COERCIBLE(TopValue)) {
|
||||
else if (IS_NUMERIC_COERCIBLE(TopValue)) {
|
||||
long ResultInt = 0;
|
||||
long TopInt = ExpressionCoerceInteger(TopValue);
|
||||
switch (Op) {
|
||||
|
@ -679,13 +662,10 @@ void ExpressionInfixOperator(struct ParseState *Parser, struct ExpressionStack *
|
|||
}
|
||||
|
||||
ExpressionStackPushValueNode(Parser, StackTop, Result);
|
||||
}
|
||||
else if (Op == TokenQuestionMark)
|
||||
} else if (Op == TokenQuestionMark)
|
||||
ExpressionQuestionMarkOperator(Parser, StackTop, TopValue, BottomValue);
|
||||
|
||||
else if (Op == TokenColon)
|
||||
ExpressionColonOperator(Parser, StackTop, TopValue, BottomValue);
|
||||
#ifndef NO_FP
|
||||
else if ( (TopValue->Typ == &Parser->pc->FPType && BottomValue->Typ == &Parser->pc->FPType) ||
|
||||
(TopValue->Typ == &Parser->pc->FPType && IS_NUMERIC_COERCIBLE(BottomValue)) ||
|
||||
(IS_NUMERIC_COERCIBLE(TopValue) && BottomValue->Typ == &Parser->pc->FPType) ) {
|
||||
|
@ -718,9 +698,7 @@ void ExpressionInfixOperator(struct ParseState *Parser, struct ExpressionStack *
|
|||
ExpressionPushInt(Parser, StackTop, ResultInt);
|
||||
else
|
||||
ExpressionPushFP(Parser, StackTop, ResultFP);
|
||||
}
|
||||
#endif
|
||||
else if (IS_NUMERIC_COERCIBLE(TopValue) && IS_NUMERIC_COERCIBLE(BottomValue)) {
|
||||
} else if (IS_NUMERIC_COERCIBLE(TopValue) && IS_NUMERIC_COERCIBLE(BottomValue)) {
|
||||
/* integer operation */
|
||||
long TopInt = ExpressionCoerceInteger(TopValue);
|
||||
long BottomInt = ExpressionCoerceInteger(BottomValue);
|
||||
|
@ -730,9 +708,7 @@ void ExpressionInfixOperator(struct ParseState *Parser, struct ExpressionStack *
|
|||
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;
|
||||
#ifndef NO_MODULUS
|
||||
case TokenModulusAssign: ResultInt = ExpressionAssignInt(Parser, BottomValue, BottomInt % TopInt, FALSE); break;
|
||||
#endif
|
||||
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;
|
||||
|
@ -755,9 +731,7 @@ void ExpressionInfixOperator(struct ParseState *Parser, struct ExpressionStack *
|
|||
case TokenMinus: ResultInt = BottomInt - TopInt; break;
|
||||
case TokenAsterisk: ResultInt = BottomInt * TopInt; break;
|
||||
case TokenSlash: ResultInt = BottomInt / TopInt; break;
|
||||
#ifndef NO_MODULUS
|
||||
case TokenModulus: ResultInt = BottomInt % TopInt; break;
|
||||
#endif
|
||||
default: ProgramFail(Parser, "invalid operation"); break;
|
||||
}
|
||||
|
||||
|
@ -1266,11 +1240,7 @@ void ExpressionParseMacroCall(struct ParseState *Parser, struct ExpressionStack
|
|||
|
||||
if (Parser->Mode == RunModeRun) {
|
||||
/* create a stack frame for this macro */
|
||||
#ifndef NO_FP
|
||||
ExpressionStackPushValueByType(Parser, StackTop, &Parser->pc->FPType); /* largest return type there is */
|
||||
#else
|
||||
ExpressionStackPushValueByType(Parser, StackTop, &Parser->pc->IntType); /* largest return type there is */
|
||||
#endif
|
||||
ReturnValue = (*StackTop)->Val;
|
||||
HeapPushStackFrame(Parser->pc);
|
||||
ParamArray = HeapAllocStack(Parser->pc, sizeof(struct Value *) * MDef->NumParams);
|
||||
|
|
|
@ -38,13 +38,8 @@
|
|||
typedef FILE IOFILE;
|
||||
|
||||
/* coercion of numeric types to other numeric types */
|
||||
#ifndef NO_FP
|
||||
#define IS_FP(v) ((v)->Typ->Base == TypeFP)
|
||||
#define FP_VAL(v) ((v)->Val->FP)
|
||||
#else
|
||||
#define IS_FP(v) (0)
|
||||
#define FP_VAL(v) (0)
|
||||
#endif
|
||||
|
||||
#define IS_POINTER_COERCIBLE(v, ap) ((ap) ? ((v)->Typ->Base == TypePointer) : 0)
|
||||
#define POINTER_COERCE(v) ((int)(v)->Val->Pointer)
|
||||
|
@ -142,9 +137,7 @@ enum BaseType
|
|||
TypeUnsignedShort, /* unsigned short integer */
|
||||
TypeUnsignedChar, /* unsigned 8-bit number */ /* must be before unsigned long */
|
||||
TypeUnsignedLong, /* unsigned long integer */
|
||||
#ifndef NO_FP
|
||||
TypeFP, /* floating point */
|
||||
#endif
|
||||
TypeFunction, /* a function */
|
||||
TypeMacro, /* a macro */
|
||||
TypePointer, /* a pointer */
|
||||
|
@ -208,9 +201,7 @@ union AnyValue
|
|||
struct ValueType *Typ;
|
||||
struct FuncDef FuncDef;
|
||||
struct MacroDef MacroDef;
|
||||
#ifndef NO_FP
|
||||
double FP;
|
||||
#endif
|
||||
void *Pointer; /* unsafe native pointers */
|
||||
};
|
||||
|
||||
|
@ -409,9 +400,7 @@ struct Picoc_Struct
|
|||
struct ValueType UnsignedShortType;
|
||||
struct ValueType UnsignedLongType;
|
||||
struct ValueType UnsignedCharType;
|
||||
#ifndef NO_FP
|
||||
struct ValueType FPType;
|
||||
#endif
|
||||
struct ValueType VoidType;
|
||||
struct ValueType TypeType;
|
||||
struct ValueType FunctionType;
|
||||
|
@ -491,9 +480,7 @@ extern long ExpressionParseInt(struct ParseState *Parser);
|
|||
extern void ExpressionAssign(struct ParseState *Parser, struct Value *DestValue, struct Value *SourceValue, int Force, const char *FuncName, int ParamNo, int AllowPointerCoercion);
|
||||
extern long ExpressionCoerceInteger(struct Value *Val);
|
||||
extern unsigned long ExpressionCoerceUnsignedInteger(struct Value *Val);
|
||||
#ifndef NO_FP
|
||||
extern double ExpressionCoerceFP(struct Value *Val);
|
||||
#endif
|
||||
|
||||
/* type.c */
|
||||
extern void TypeInit(Picoc *pc);
|
||||
|
|
12
lex.c
12
lex.c
|
@ -47,15 +47,11 @@ static struct ReservedWord ReservedWords[] =
|
|||
{"default", TokenDefault},
|
||||
{"delete", TokenDelete},
|
||||
{"do", TokenDo},
|
||||
#ifndef NO_FP
|
||||
{"double", TokenDoubleType},
|
||||
#endif
|
||||
{"else", TokenElse},
|
||||
{"enum", TokenEnumType},
|
||||
{"extern", TokenExternType},
|
||||
#ifndef NO_FP
|
||||
{"float", TokenFloatType},
|
||||
#endif
|
||||
{"for", TokenFor},
|
||||
{"goto", TokenGoto},
|
||||
{"if", TokenIf},
|
||||
|
@ -127,10 +123,8 @@ enum LexToken LexGetNumber(Picoc *pc, struct LexState *Lexer, struct Value *Valu
|
|||
long Result = 0;
|
||||
long Base = 10;
|
||||
enum LexToken ResultToken;
|
||||
#ifndef NO_FP
|
||||
double FPResult;
|
||||
double FPDiv;
|
||||
#endif
|
||||
/* long/unsigned flags */
|
||||
#if 0 /* unused for now */
|
||||
char IsLong = 0;
|
||||
|
@ -171,7 +165,6 @@ enum LexToken LexGetNumber(Picoc *pc, struct LexState *Lexer, struct Value *Valu
|
|||
if (Lexer->Pos == Lexer->End)
|
||||
return ResultToken;
|
||||
|
||||
#ifndef NO_FP
|
||||
if (Lexer->Pos == Lexer->End) {
|
||||
return ResultToken;
|
||||
}
|
||||
|
@ -214,9 +207,6 @@ enum LexToken LexGetNumber(Picoc *pc, struct LexState *Lexer, struct Value *Valu
|
|||
LEXER_INC(Lexer);
|
||||
|
||||
return TokenFPConstant;
|
||||
#else
|
||||
return ResultToken;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* get a reserved word or identifier - used while scanning */
|
||||
|
@ -668,9 +658,7 @@ enum LexToken LexGetRawToken(struct ParseState *Parser, struct Value **Value, in
|
|||
case TokenIdentifier: pc->LexValue.Typ = NULL; break;
|
||||
case TokenIntegerConstant: pc->LexValue.Typ = &pc->LongType; break;
|
||||
case TokenCharacterConstant: pc->LexValue.Typ = &pc->CharType; break;
|
||||
#ifndef NO_FP
|
||||
case TokenFPConstant: pc->LexValue.Typ = &pc->FPType; break;
|
||||
#endif
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
|
|
@ -202,9 +202,7 @@ void PlatformVPrintf(IOFILE *Stream, const char *Format, va_list Args)
|
|||
case 'd': PrintSimpleInt(va_arg(Args, int), Stream); break;
|
||||
case 'c': PrintCh(va_arg(Args, int), Stream); break;
|
||||
case 't': PrintType(va_arg(Args, struct ValueType *), Stream); break;
|
||||
#ifndef NO_FP
|
||||
case 'f': PrintFP(va_arg(Args, double), Stream); break;
|
||||
#endif
|
||||
case '%': PrintCh('%', Stream); break;
|
||||
case '\0': FPos--; break;
|
||||
}
|
||||
|
|
12
platform.h
12
platform.h
|
@ -4,13 +4,13 @@
|
|||
|
||||
/* configurable options */
|
||||
/* select your host type (or do it in the Makefile):
|
||||
* #define UNIX_HOST
|
||||
* #define WIN32 (predefined on MSVC)
|
||||
* #define DEBUGGER
|
||||
* #define USE_READLINE (defined by default for UNIX_HOST)
|
||||
* #define NO_FP
|
||||
#define UNIX_HOST
|
||||
#define WIN32 (predefined on MSVC)
|
||||
#define DEBUGGER
|
||||
#define USE_READLINE (defined by default for UNIX_HOST)
|
||||
*/
|
||||
|
||||
|
||||
#define LARGE_INT_POWER_OF_TEN (1000000000) /* the largest power of ten which fits in an int on this architecture */
|
||||
#if defined(__hppa__) || defined(__sparc__)
|
||||
#define ALIGN_TYPE double /* the default data type to use for alignment */
|
||||
|
@ -58,7 +58,7 @@
|
|||
#ifdef UNIX_HOST
|
||||
# include <stdint.h>
|
||||
# include <unistd.h>
|
||||
# ifndef NO_FP
|
||||
# ifdef HAVE_FP
|
||||
# include <math.h>
|
||||
# define USE_READLINE
|
||||
# if defined(__powerpc__) || defined(__hppa__) || defined(__sparc__)
|
||||
|
|
8
type.c
8
type.c
|
@ -108,9 +108,7 @@ void TypeInit(Picoc *pc)
|
|||
struct ShortAlign {char x; short y;} sa;
|
||||
struct CharAlign {char x; char y;} ca;
|
||||
struct LongAlign {char x; long y;} la;
|
||||
#ifndef NO_FP
|
||||
struct DoubleAlign {char x; double y;} da;
|
||||
#endif
|
||||
struct PointerAlign {char x; void *y;} pa;
|
||||
|
||||
IntAlignBytes = (char*)&ia.y - &ia.x;
|
||||
|
@ -129,12 +127,8 @@ void TypeInit(Picoc *pc)
|
|||
TypeAddBaseType(pc, &pc->FunctionType, TypeFunction, sizeof(int), IntAlignBytes);
|
||||
TypeAddBaseType(pc, &pc->MacroType, TypeMacro, sizeof(int), IntAlignBytes);
|
||||
TypeAddBaseType(pc, &pc->GotoLabelType, TypeGotoLabel, 0, 1);
|
||||
#ifndef NO_FP
|
||||
TypeAddBaseType(pc, &pc->FPType, TypeFP, sizeof(double), (char*)&da.y - &da.x);
|
||||
TypeAddBaseType(pc, &pc->TypeType, Type_Type, sizeof(double), (char*)&da.y - &da.x); /* must be large enough to cast to a double */
|
||||
#else
|
||||
TypeAddBaseType(pc, &pc->TypeType, Type_Type, sizeof(struct ValueType *), PointerAlignBytes);
|
||||
#endif
|
||||
pc->CharArrayType = TypeAdd(pc, NULL, &pc->CharType, TypeArray, 0, pc->StrEmpty, sizeof(char), (char*)&ca.y - &ca.x);
|
||||
pc->CharPtrType = TypeAdd(pc, NULL, &pc->CharType, TypePointer, 0, pc->StrEmpty, sizeof(void*), PointerAlignBytes);
|
||||
pc->CharPtrPtrType = TypeAdd(pc, NULL, pc->CharPtrType, TypePointer, 0, pc->StrEmpty, sizeof(void*), PointerAlignBytes);
|
||||
|
@ -375,9 +369,7 @@ int TypeParseFront(struct ParseState *Parser, struct ValueType **Typ, int *IsSta
|
|||
case TokenShortType: *Typ = Unsigned ? &pc->UnsignedShortType : &pc->ShortType; break;
|
||||
case TokenCharType: *Typ = Unsigned ? &pc->UnsignedCharType : &pc->CharType; break;
|
||||
case TokenLongType: *Typ = Unsigned ? &pc->UnsignedLongType : &pc->LongType; break;
|
||||
#ifndef NO_FP
|
||||
case TokenFloatType: case TokenDoubleType: *Typ = &pc->FPType; break;
|
||||
#endif
|
||||
case TokenVoidType: *Typ = &pc->VoidType; break;
|
||||
case TokenStructType: case TokenUnionType:
|
||||
if (*Typ != NULL)
|
||||
|
|
Loading…
Reference in a new issue