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 */
|
||||
// FIXME: GlobalTable never used
|
||||
void LibraryAdd(Picoc *pc, struct Table *GlobalTable,
|
||||
struct LibraryFunction *FuncList)
|
||||
{
|
||||
|
|
28
expression.c
28
expression.c
|
@ -35,7 +35,7 @@ struct ExpressionStack
|
|||
struct ExpressionStack *Next; /* the next lower item on the stack */
|
||||
struct Value *Val; /* the value for this stack node */
|
||||
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 */
|
||||
};
|
||||
|
||||
|
@ -506,18 +506,14 @@ void ExpressionAssign(struct ParseState *Parser, struct Value *DestValue,
|
|||
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;
|
||||
case TypePointer:
|
||||
ExpressionAssignToPointer(Parser, DestValue, SourceValue, FuncName,
|
||||
ParamNo, AllowPointerCoercion);
|
||||
break;
|
||||
|
||||
case TypeArray:
|
||||
if (SourceValue->Typ->Base == TypeArray &&
|
||||
DestValue->Typ->FromType == DestValue->Typ->FromType &&
|
||||
DestValue->Typ->ArraySize == 0) {
|
||||
if (SourceValue->Typ->Base == TypeArray && 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;
|
||||
|
@ -529,7 +525,6 @@ void ExpressionAssign(struct ParseState *Parser, struct Value *DestValue,
|
|||
DestValue->LValueFrom->AnyValOnHeap = DestValue->AnyValOnHeap;
|
||||
}
|
||||
}
|
||||
|
||||
/* char array = "abcd" */
|
||||
if (DestValue->Typ->FromType->Base == TypeChar &&
|
||||
SourceValue->Typ->Base == TypePointer &&
|
||||
|
@ -571,17 +566,14 @@ void ExpressionAssign(struct ParseState *Parser, struct Value *DestValue,
|
|||
memcpy((void *)DestValue->Val, (void *)SourceValue->Val,
|
||||
TypeSizeValue(DestValue, false));
|
||||
break;
|
||||
|
||||
case TypeStruct:
|
||||
case TypeUnion:
|
||||
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));
|
||||
break;
|
||||
|
||||
default:
|
||||
AssignFail(Parser, "%t", DestValue->Typ, NULL, 0, 0, FuncName, ParamNo);
|
||||
break;
|
||||
|
@ -1211,7 +1203,6 @@ void ExpressionStackCollapse(struct ParseState *Parser,
|
|||
ExpressionPushInt(Parser, StackTop, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case OrderPostfix:
|
||||
/* postfix evaluation */
|
||||
#ifdef DEBUG_EXPRESSIONS
|
||||
|
@ -1237,7 +1228,6 @@ void ExpressionStackCollapse(struct ParseState *Parser,
|
|||
ExpressionPushInt(Parser, StackTop, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case OrderInfix:
|
||||
/* infix evaluation */
|
||||
#ifdef DEBUG_EXPRESSIONS
|
||||
|
@ -1274,8 +1264,8 @@ void ExpressionStackCollapse(struct ParseState *Parser,
|
|||
else
|
||||
FoundPrecedence = -1;
|
||||
break;
|
||||
|
||||
case OrderNone:
|
||||
default:
|
||||
/* this should never happen */
|
||||
assert(TopOperatorNode->Order != OrderNone);
|
||||
break;
|
||||
|
@ -1652,7 +1642,7 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result)
|
|||
return StackTop != NULL;
|
||||
}
|
||||
|
||||
/* do a parameterised macro call */
|
||||
/* do a parameterized macro call */
|
||||
void ExpressionParseMacroCall(struct ParseState *Parser,
|
||||
struct ExpressionStack **StackTop, const char *MacroName,
|
||||
struct MacroDef *MDef)
|
||||
|
@ -1693,7 +1683,7 @@ void ExpressionParseMacroCall(struct ParseState *Parser,
|
|||
} else {
|
||||
/* end of argument list? */
|
||||
Token = LexGetToken(Parser, NULL, true);
|
||||
if (!TokenCloseBracket)
|
||||
if (Token != TokenCloseBracket)
|
||||
ProgramFail(Parser, "bad argument");
|
||||
}
|
||||
|
||||
|
@ -1795,7 +1785,7 @@ void ExpressionParseFunctionCall(struct ParseState *Parser,
|
|||
} else {
|
||||
/* end of argument list? */
|
||||
Token = LexGetToken(Parser, NULL, true);
|
||||
if (!TokenCloseBracket)
|
||||
if (Token != TokenCloseBracket)
|
||||
ProgramFail(Parser, "bad argument");
|
||||
}
|
||||
|
||||
|
@ -1847,9 +1837,11 @@ void ExpressionParseFunctionCall(struct ParseState *Parser,
|
|||
}
|
||||
|
||||
VariableStackFramePop(Parser);
|
||||
} else
|
||||
} else {
|
||||
// FIXME: too many parameters?
|
||||
FuncValue->Val->FuncDef.Intrinsic(Parser, ReturnValue, ParamArray,
|
||||
ArgCount);
|
||||
ArgCount);
|
||||
}
|
||||
|
||||
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 */
|
||||
// FIXME: End not used
|
||||
unsigned char LexUnEscapeCharacterConstant(const char **From, const char *End,
|
||||
unsigned char FirstChar, int Base)
|
||||
{
|
||||
|
|
4
parse.c
4
parse.c
|
@ -35,7 +35,7 @@ enum ParseResult ParseStatementMaybeRun(struct ParseState *Parser,
|
|||
Parser->Mode = RunModeSkip;
|
||||
Result = ParseStatement(Parser, CheckTrailingSemicolon);
|
||||
Parser->Mode = OldMode;
|
||||
return Result;
|
||||
return (enum ParseResult)Result;
|
||||
} else
|
||||
return ParseStatement(Parser, CheckTrailingSemicolon);
|
||||
}
|
||||
|
@ -559,7 +559,7 @@ void ParseTypedef(struct ParseState *Parser)
|
|||
if (Parser->Mode == RunModeRun) {
|
||||
TypPtr = &Typ;
|
||||
InitValue.Typ = &Parser->pc->TypeType;
|
||||
InitValue.Val = (union AnyValue *)TypPtr;
|
||||
InitValue.Val = (union AnyValue*)TypPtr;
|
||||
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 '%': PrintCh('%', Stream); break;
|
||||
case '\0': FPos--; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#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;
|
||||
memset((void *)&InitValue, '\0', sizeof(struct Value));
|
||||
InitValue.Typ = &pc->IntType;
|
||||
InitValue.Val = (union AnyValue *)&EnumValue;
|
||||
InitValue.Val = (union AnyValue*)&EnumValue;
|
||||
do {
|
||||
if (LexGetToken(Parser, &LexValue, true) != TokenIdentifier)
|
||||
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 */
|
||||
// FIXME: Parser unused
|
||||
void *VariableDereferencePointer(struct ParseState *Parser,
|
||||
struct Value *PointerValue, struct Value **DerefVal, int *DerefOffset,
|
||||
struct ValueType **DerefType, int *DerefIsLValue)
|
||||
|
|
Loading…
Reference in a new issue