changes after simple analysis, added FIXMEs
This commit is contained in:
parent
df817a54fc
commit
463f086a33
|
@ -29,6 +29,7 @@ void LibraryInit(Picoc *pc)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add a library */
|
/* add a library */
|
||||||
|
// FIXME: GlobalTable never used
|
||||||
void LibraryAdd(Picoc *pc, struct Table *GlobalTable,
|
void LibraryAdd(Picoc *pc, struct Table *GlobalTable,
|
||||||
struct LibraryFunction *FuncList)
|
struct LibraryFunction *FuncList)
|
||||||
{
|
{
|
||||||
|
|
26
expression.c
26
expression.c
|
@ -35,7 +35,7 @@ struct ExpressionStack
|
||||||
struct ExpressionStack *Next; /* the next lower item on the stack */
|
struct ExpressionStack *Next; /* the next lower item on the stack */
|
||||||
struct Value *Val; /* the value for this stack node */
|
struct Value *Val; /* the value for this stack node */
|
||||||
enum LexToken Op; /* the operator */
|
enum LexToken Op; /* the operator */
|
||||||
short unsigned int Precedence; /* the operator precedence of this node */
|
unsigned short Precedence; /* the operator precedence of this node */
|
||||||
unsigned char Order; /* the evaluation order of this operator */
|
unsigned char Order; /* the evaluation order of this operator */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -506,18 +506,14 @@ void ExpressionAssign(struct ParseState *Parser, struct Value *DestValue,
|
||||||
if (!IS_NUMERIC_COERCIBLE_PLUS_POINTERS(SourceValue, AllowPointerCoercion))
|
if (!IS_NUMERIC_COERCIBLE_PLUS_POINTERS(SourceValue, AllowPointerCoercion))
|
||||||
AssignFail(Parser, "%t from %t", DestValue->Typ, SourceValue->Typ,
|
AssignFail(Parser, "%t from %t", DestValue->Typ, SourceValue->Typ,
|
||||||
0, 0, FuncName, ParamNo);
|
0, 0, FuncName, ParamNo);
|
||||||
|
|
||||||
DestValue->Val->FP = ExpressionCoerceFP(SourceValue);
|
DestValue->Val->FP = ExpressionCoerceFP(SourceValue);
|
||||||
break;
|
break;
|
||||||
case TypePointer:
|
case TypePointer:
|
||||||
ExpressionAssignToPointer(Parser, DestValue, SourceValue, FuncName,
|
ExpressionAssignToPointer(Parser, DestValue, SourceValue, FuncName,
|
||||||
ParamNo, AllowPointerCoercion);
|
ParamNo, AllowPointerCoercion);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TypeArray:
|
case TypeArray:
|
||||||
if (SourceValue->Typ->Base == TypeArray &&
|
if (SourceValue->Typ->Base == TypeArray && DestValue->Typ->ArraySize == 0) {
|
||||||
DestValue->Typ->FromType == DestValue->Typ->FromType &&
|
|
||||||
DestValue->Typ->ArraySize == 0) {
|
|
||||||
/* destination array is unsized - need to resize the destination
|
/* destination array is unsized - need to resize the destination
|
||||||
array to the same size as the source array */
|
array to the same size as the source array */
|
||||||
DestValue->Typ = SourceValue->Typ;
|
DestValue->Typ = SourceValue->Typ;
|
||||||
|
@ -529,7 +525,6 @@ void ExpressionAssign(struct ParseState *Parser, struct Value *DestValue,
|
||||||
DestValue->LValueFrom->AnyValOnHeap = DestValue->AnyValOnHeap;
|
DestValue->LValueFrom->AnyValOnHeap = DestValue->AnyValOnHeap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* char array = "abcd" */
|
/* char array = "abcd" */
|
||||||
if (DestValue->Typ->FromType->Base == TypeChar &&
|
if (DestValue->Typ->FromType->Base == TypeChar &&
|
||||||
SourceValue->Typ->Base == TypePointer &&
|
SourceValue->Typ->Base == TypePointer &&
|
||||||
|
@ -571,17 +566,14 @@ void ExpressionAssign(struct ParseState *Parser, struct Value *DestValue,
|
||||||
memcpy((void *)DestValue->Val, (void *)SourceValue->Val,
|
memcpy((void *)DestValue->Val, (void *)SourceValue->Val,
|
||||||
TypeSizeValue(DestValue, false));
|
TypeSizeValue(DestValue, false));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TypeStruct:
|
case TypeStruct:
|
||||||
case TypeUnion:
|
case TypeUnion:
|
||||||
if (DestValue->Typ != SourceValue->Typ)
|
if (DestValue->Typ != SourceValue->Typ)
|
||||||
AssignFail(Parser, "%t from %t", DestValue->Typ, SourceValue->Typ,
|
AssignFail(Parser, "%t from %t", DestValue->Typ, SourceValue->Typ,
|
||||||
0, 0, FuncName, ParamNo);
|
0, 0, FuncName, ParamNo);
|
||||||
|
|
||||||
memcpy((void *)DestValue->Val, (void *)SourceValue->Val,
|
memcpy((void *)DestValue->Val, (void *)SourceValue->Val,
|
||||||
TypeSizeValue(SourceValue, false));
|
TypeSizeValue(SourceValue, false));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
AssignFail(Parser, "%t", DestValue->Typ, NULL, 0, 0, FuncName, ParamNo);
|
AssignFail(Parser, "%t", DestValue->Typ, NULL, 0, 0, FuncName, ParamNo);
|
||||||
break;
|
break;
|
||||||
|
@ -1211,7 +1203,6 @@ void ExpressionStackCollapse(struct ParseState *Parser,
|
||||||
ExpressionPushInt(Parser, StackTop, 0);
|
ExpressionPushInt(Parser, StackTop, 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OrderPostfix:
|
case OrderPostfix:
|
||||||
/* postfix evaluation */
|
/* postfix evaluation */
|
||||||
#ifdef DEBUG_EXPRESSIONS
|
#ifdef DEBUG_EXPRESSIONS
|
||||||
|
@ -1237,7 +1228,6 @@ void ExpressionStackCollapse(struct ParseState *Parser,
|
||||||
ExpressionPushInt(Parser, StackTop, 0);
|
ExpressionPushInt(Parser, StackTop, 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OrderInfix:
|
case OrderInfix:
|
||||||
/* infix evaluation */
|
/* infix evaluation */
|
||||||
#ifdef DEBUG_EXPRESSIONS
|
#ifdef DEBUG_EXPRESSIONS
|
||||||
|
@ -1274,8 +1264,8 @@ void ExpressionStackCollapse(struct ParseState *Parser,
|
||||||
else
|
else
|
||||||
FoundPrecedence = -1;
|
FoundPrecedence = -1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OrderNone:
|
case OrderNone:
|
||||||
|
default:
|
||||||
/* this should never happen */
|
/* this should never happen */
|
||||||
assert(TopOperatorNode->Order != OrderNone);
|
assert(TopOperatorNode->Order != OrderNone);
|
||||||
break;
|
break;
|
||||||
|
@ -1652,7 +1642,7 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result)
|
||||||
return StackTop != NULL;
|
return StackTop != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* do a parameterised macro call */
|
/* do a parameterized macro call */
|
||||||
void ExpressionParseMacroCall(struct ParseState *Parser,
|
void ExpressionParseMacroCall(struct ParseState *Parser,
|
||||||
struct ExpressionStack **StackTop, const char *MacroName,
|
struct ExpressionStack **StackTop, const char *MacroName,
|
||||||
struct MacroDef *MDef)
|
struct MacroDef *MDef)
|
||||||
|
@ -1693,7 +1683,7 @@ void ExpressionParseMacroCall(struct ParseState *Parser,
|
||||||
} else {
|
} else {
|
||||||
/* end of argument list? */
|
/* end of argument list? */
|
||||||
Token = LexGetToken(Parser, NULL, true);
|
Token = LexGetToken(Parser, NULL, true);
|
||||||
if (!TokenCloseBracket)
|
if (Token != TokenCloseBracket)
|
||||||
ProgramFail(Parser, "bad argument");
|
ProgramFail(Parser, "bad argument");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1795,7 +1785,7 @@ void ExpressionParseFunctionCall(struct ParseState *Parser,
|
||||||
} else {
|
} else {
|
||||||
/* end of argument list? */
|
/* end of argument list? */
|
||||||
Token = LexGetToken(Parser, NULL, true);
|
Token = LexGetToken(Parser, NULL, true);
|
||||||
if (!TokenCloseBracket)
|
if (Token != TokenCloseBracket)
|
||||||
ProgramFail(Parser, "bad argument");
|
ProgramFail(Parser, "bad argument");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1847,9 +1837,11 @@ void ExpressionParseFunctionCall(struct ParseState *Parser,
|
||||||
}
|
}
|
||||||
|
|
||||||
VariableStackFramePop(Parser);
|
VariableStackFramePop(Parser);
|
||||||
} else
|
} else {
|
||||||
|
// FIXME: too many parameters?
|
||||||
FuncValue->Val->FuncDef.Intrinsic(Parser, ReturnValue, ParamArray,
|
FuncValue->Val->FuncDef.Intrinsic(Parser, ReturnValue, ParamArray,
|
||||||
ArgCount);
|
ArgCount);
|
||||||
|
}
|
||||||
|
|
||||||
HeapPopStackFrame(Parser->pc);
|
HeapPopStackFrame(Parser->pc);
|
||||||
}
|
}
|
||||||
|
|
1
lex.c
1
lex.c
|
@ -244,6 +244,7 @@ enum LexToken LexGetWord(Picoc *pc, struct LexState *Lexer, struct Value *Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* unescape a character from an octal character constant */
|
/* unescape a character from an octal character constant */
|
||||||
|
// FIXME: End not used
|
||||||
unsigned char LexUnEscapeCharacterConstant(const char **From, const char *End,
|
unsigned char LexUnEscapeCharacterConstant(const char **From, const char *End,
|
||||||
unsigned char FirstChar, int Base)
|
unsigned char FirstChar, int Base)
|
||||||
{
|
{
|
||||||
|
|
4
parse.c
4
parse.c
|
@ -35,7 +35,7 @@ enum ParseResult ParseStatementMaybeRun(struct ParseState *Parser,
|
||||||
Parser->Mode = RunModeSkip;
|
Parser->Mode = RunModeSkip;
|
||||||
Result = ParseStatement(Parser, CheckTrailingSemicolon);
|
Result = ParseStatement(Parser, CheckTrailingSemicolon);
|
||||||
Parser->Mode = OldMode;
|
Parser->Mode = OldMode;
|
||||||
return Result;
|
return (enum ParseResult)Result;
|
||||||
} else
|
} else
|
||||||
return ParseStatement(Parser, CheckTrailingSemicolon);
|
return ParseStatement(Parser, CheckTrailingSemicolon);
|
||||||
}
|
}
|
||||||
|
@ -559,7 +559,7 @@ void ParseTypedef(struct ParseState *Parser)
|
||||||
if (Parser->Mode == RunModeRun) {
|
if (Parser->Mode == RunModeRun) {
|
||||||
TypPtr = &Typ;
|
TypPtr = &Typ;
|
||||||
InitValue.Typ = &Parser->pc->TypeType;
|
InitValue.Typ = &Parser->pc->TypeType;
|
||||||
InitValue.Val = (union AnyValue *)TypPtr;
|
InitValue.Val = (union AnyValue*)TypPtr;
|
||||||
VariableDefine(Parser->pc, Parser, TypeName, &InitValue, NULL, false);
|
VariableDefine(Parser->pc, Parser, TypeName, &InitValue, NULL, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -228,6 +228,7 @@ void PlatformVPrintf(IOFILE *Stream, const char *Format, va_list Args)
|
||||||
case 'f': PrintFP(va_arg(Args, double), Stream); break;
|
case 'f': PrintFP(va_arg(Args, double), Stream); break;
|
||||||
case '%': PrintCh('%', Stream); break;
|
case '%': PrintCh('%', Stream); break;
|
||||||
case '\0': FPos--; break;
|
case '\0': FPos--; break;
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "../interpreter.h"
|
#include "../interpreter.h"
|
||||||
|
|
||||||
void UnixSetupFunc()
|
void UnixSetupFunc(Picoc *pc)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
type.c
2
type.c
|
@ -350,7 +350,7 @@ void TypeParseEnum(struct ParseState *Parser, struct ValueType **Typ)
|
||||||
(*Typ)->Members = &pc->GlobalTable;
|
(*Typ)->Members = &pc->GlobalTable;
|
||||||
memset((void *)&InitValue, '\0', sizeof(struct Value));
|
memset((void *)&InitValue, '\0', sizeof(struct Value));
|
||||||
InitValue.Typ = &pc->IntType;
|
InitValue.Typ = &pc->IntType;
|
||||||
InitValue.Val = (union AnyValue *)&EnumValue;
|
InitValue.Val = (union AnyValue*)&EnumValue;
|
||||||
do {
|
do {
|
||||||
if (LexGetToken(Parser, &LexValue, true) != TokenIdentifier)
|
if (LexGetToken(Parser, &LexValue, true) != TokenIdentifier)
|
||||||
ProgramFail(Parser, "identifier expected");
|
ProgramFail(Parser, "identifier expected");
|
||||||
|
|
|
@ -507,6 +507,7 @@ void VariableStringLiteralDefine(Picoc *pc, char *Ident, struct Value *Val)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check a pointer for validity and dereference it for use */
|
/* check a pointer for validity and dereference it for use */
|
||||||
|
// FIXME: Parser unused
|
||||||
void *VariableDereferencePointer(struct ParseState *Parser,
|
void *VariableDereferencePointer(struct ParseState *Parser,
|
||||||
struct Value *PointerValue, struct Value **DerefVal, int *DerefOffset,
|
struct Value *PointerValue, struct Value **DerefVal, int *DerefOffset,
|
||||||
struct ValueType **DerefType, int *DerefIsLValue)
|
struct ValueType **DerefType, int *DerefIsLValue)
|
||||||
|
|
Loading…
Reference in a new issue