formatting
This commit is contained in:
parent
6e1c3aa71d
commit
f551e28a49
47
expression.c
47
expression.c
|
@ -319,7 +319,7 @@ double ExpressionCoerceFP(struct Value *Val)
|
|||
|
||||
/* assign an integer value */
|
||||
long ExpressionAssignInt(struct ParseState *Parser, struct Value *DestValue,
|
||||
long FromInt, int After)
|
||||
long FromInt, int After)
|
||||
{
|
||||
long Result;
|
||||
|
||||
|
@ -375,7 +375,7 @@ double ExpressionAssignFP(struct ParseState *Parser, struct Value *DestValue,
|
|||
|
||||
/* push a node on to the expression stack */
|
||||
void ExpressionStackPushValueNode(struct ParseState *Parser,
|
||||
struct ExpressionStack **StackTop, struct Value *ValueLoc)
|
||||
struct ExpressionStack **StackTop, struct Value *ValueLoc)
|
||||
{
|
||||
struct ExpressionStack *StackNode = VariableAlloc(Parser->pc, Parser,
|
||||
sizeof(*StackNode), false);
|
||||
|
@ -393,7 +393,7 @@ void ExpressionStackPushValueNode(struct ParseState *Parser,
|
|||
|
||||
/* push a blank value on to the expression stack by type */
|
||||
struct Value *ExpressionStackPushValueByType(struct ParseState *Parser,
|
||||
struct ExpressionStack **StackTop, struct ValueType *PushType)
|
||||
struct ExpressionStack **StackTop, struct ValueType *PushType)
|
||||
{
|
||||
struct Value *ValueLoc = VariableAllocValueFromType(Parser->pc, Parser,
|
||||
PushType, false, NULL, false);
|
||||
|
@ -404,7 +404,7 @@ struct Value *ExpressionStackPushValueByType(struct ParseState *Parser,
|
|||
|
||||
/* push a value on to the expression stack */
|
||||
void ExpressionStackPushValue(struct ParseState *Parser,
|
||||
struct ExpressionStack **StackTop, struct Value *PushValue)
|
||||
struct ExpressionStack **StackTop, struct Value *PushValue)
|
||||
{
|
||||
struct Value *ValueLoc = VariableAllocValueAndCopy(Parser->pc, Parser,
|
||||
PushValue, false);
|
||||
|
@ -412,7 +412,7 @@ void ExpressionStackPushValue(struct ParseState *Parser,
|
|||
}
|
||||
|
||||
void ExpressionStackPushLValue(struct ParseState *Parser,
|
||||
struct ExpressionStack **StackTop, struct Value *PushValue, int Offset)
|
||||
struct ExpressionStack **StackTop, struct Value *PushValue, int Offset)
|
||||
{
|
||||
struct Value *ValueLoc = VariableAllocValueShared(Parser, PushValue);
|
||||
ValueLoc->Val = (void *)((char *)ValueLoc->Val + Offset);
|
||||
|
@ -457,8 +457,8 @@ void ExpressionPushFP(struct ParseState *Parser,
|
|||
|
||||
/* assign to a pointer */
|
||||
void ExpressionAssignToPointer(struct ParseState *Parser, struct Value *ToValue,
|
||||
struct Value *FromValue, const char *FuncName, int ParamNo,
|
||||
int AllowPointerCoercion)
|
||||
struct Value *FromValue, const char *FuncName, int ParamNo,
|
||||
int AllowPointerCoercion)
|
||||
{
|
||||
struct ValueType *PointedToType = ToValue->Typ->FromType;
|
||||
|
||||
|
@ -497,8 +497,8 @@ void ExpressionAssignToPointer(struct ParseState *Parser, struct Value *ToValue,
|
|||
|
||||
/* assign any kind of value */
|
||||
void ExpressionAssign(struct ParseState *Parser, struct Value *DestValue,
|
||||
struct Value *SourceValue, int Force, const char *FuncName, int ParamNo,
|
||||
int AllowPointerCoercion)
|
||||
struct Value *SourceValue, int Force, const char *FuncName, int ParamNo,
|
||||
int AllowPointerCoercion)
|
||||
{
|
||||
if (!DestValue->IsLValue && !Force)
|
||||
AssignFail(Parser, "not an lvalue", NULL, NULL, 0, 0, FuncName, ParamNo);
|
||||
|
@ -617,8 +617,8 @@ void ExpressionAssign(struct ParseState *Parser, struct Value *DestValue,
|
|||
|
||||
/* evaluate the first half of a ternary operator x ? y : z */
|
||||
void ExpressionQuestionMarkOperator(struct ParseState *Parser,
|
||||
struct ExpressionStack **StackTop, struct Value *BottomValue,
|
||||
struct Value *TopValue)
|
||||
struct ExpressionStack **StackTop, struct Value *BottomValue,
|
||||
struct Value *TopValue)
|
||||
{
|
||||
if (!IS_NUMERIC_COERCIBLE(TopValue))
|
||||
ProgramFail(Parser, "first argument to '?' should be a number");
|
||||
|
@ -634,8 +634,8 @@ void ExpressionQuestionMarkOperator(struct ParseState *Parser,
|
|||
|
||||
/* evaluate the second half of a ternary operator x ? y : z */
|
||||
void ExpressionColonOperator(struct ParseState *Parser,
|
||||
struct ExpressionStack **StackTop, struct Value *BottomValue,
|
||||
struct Value *TopValue)
|
||||
struct ExpressionStack **StackTop, struct Value *BottomValue,
|
||||
struct Value *TopValue)
|
||||
{
|
||||
if (TopValue->Typ->Base == TypeVoid) {
|
||||
/* invoke the "else" part - return the BottomValue */
|
||||
|
@ -863,8 +863,8 @@ void ExpressionPostfixOperator(struct ParseState *Parser,
|
|||
|
||||
/* evaluate an infix operator */
|
||||
void ExpressionInfixOperator(struct ParseState *Parser,
|
||||
struct ExpressionStack **StackTop, enum LexToken Op,
|
||||
struct Value *BottomValue, struct Value *TopValue)
|
||||
struct ExpressionStack **StackTop, enum LexToken Op,
|
||||
struct Value *BottomValue, struct Value *TopValue)
|
||||
{
|
||||
long ResultInt = 0;
|
||||
struct Value *StackValue;
|
||||
|
@ -1192,7 +1192,7 @@ void ExpressionInfixOperator(struct ParseState *Parser,
|
|||
/* take the contents of the expression stack and compute the top until
|
||||
there's nothing greater than the given precedence */
|
||||
void ExpressionStackCollapse(struct ParseState *Parser,
|
||||
struct ExpressionStack **StackTop, int Precedence, int *IgnorePrecedence)
|
||||
struct ExpressionStack **StackTop, int Precedence, int *IgnorePrecedence)
|
||||
{
|
||||
int FoundPrecedence = Precedence;
|
||||
struct Value *TopValue;
|
||||
|
@ -1303,8 +1303,7 @@ void ExpressionStackCollapse(struct ParseState *Parser,
|
|||
/* we're not running it so just return 0 */
|
||||
ExpressionPushInt(Parser, StackTop, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
FoundPrecedence = -1;
|
||||
break;
|
||||
case OrderNone:
|
||||
|
@ -1332,8 +1331,8 @@ void ExpressionStackCollapse(struct ParseState *Parser,
|
|||
|
||||
/* 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 **StackTop, enum OperatorOrder Order,
|
||||
enum LexToken Token, int Precedence)
|
||||
{
|
||||
struct ExpressionStack *StackNode = VariableAlloc(Parser->pc, Parser,
|
||||
sizeof(*StackNode), false);
|
||||
|
@ -1356,7 +1355,7 @@ void ExpressionStackPushOperator(struct ParseState *Parser,
|
|||
|
||||
/* do the '.' and '->' operators */
|
||||
void ExpressionGetStructElement(struct ParseState *Parser,
|
||||
struct ExpressionStack **StackTop, enum LexToken Token)
|
||||
struct ExpressionStack **StackTop, enum LexToken Token)
|
||||
{
|
||||
struct Value *Ident;
|
||||
|
||||
|
@ -1693,8 +1692,8 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result)
|
|||
|
||||
/* do a parameterized macro call */
|
||||
void ExpressionParseMacroCall(struct ParseState *Parser,
|
||||
struct ExpressionStack **StackTop, const char *MacroName,
|
||||
struct MacroDef *MDef)
|
||||
struct ExpressionStack **StackTop, const char *MacroName,
|
||||
struct MacroDef *MDef)
|
||||
{
|
||||
int ArgCount;
|
||||
enum LexToken Token;
|
||||
|
@ -1771,7 +1770,7 @@ void ExpressionParseMacroCall(struct ParseState *Parser,
|
|||
|
||||
/* do a function call */
|
||||
void ExpressionParseFunctionCall(struct ParseState *Parser,
|
||||
struct ExpressionStack **StackTop, const char *FuncName, int RunIt)
|
||||
struct ExpressionStack **StackTop, const char *FuncName, int RunIt)
|
||||
{
|
||||
int ArgCount;
|
||||
enum LexToken Token = LexGetToken(Parser, NULL, true); /* open bracket */
|
||||
|
|
4
parse.c
4
parse.c
|
@ -41,7 +41,7 @@ void ParseCleanup(Picoc *pc)
|
|||
|
||||
/* parse a statement, but only run it if Condition is true */
|
||||
enum ParseResult ParseStatementMaybeRun(struct ParseState *Parser,
|
||||
int Condition, int CheckTrailingSemicolon)
|
||||
int Condition, int CheckTrailingSemicolon)
|
||||
{
|
||||
if (Parser->Mode != RunModeSkip && !Condition) {
|
||||
enum RunMode OldMode = Parser->Mode;
|
||||
|
@ -75,7 +75,7 @@ int ParseCountParams(struct ParseState *Parser)
|
|||
|
||||
/* parse a function definition and store it for later */
|
||||
struct Value *ParseFunctionDefinition(struct ParseState *Parser,
|
||||
struct ValueType *ReturnType, char *Identifier)
|
||||
struct ValueType *ReturnType, char *Identifier)
|
||||
{
|
||||
int ParamCount = 0;
|
||||
char *ParamIdentifier;
|
||||
|
|
|
@ -104,7 +104,7 @@ void PicocCallMain(Picoc *pc, int argc, char **argv)
|
|||
#endif
|
||||
|
||||
void PrintSourceTextErrorLine(IOFILE *Stream, const char *FileName,
|
||||
const char *SourceText, int Line, int CharacterPos)
|
||||
const char *SourceText, int Line, int CharacterPos)
|
||||
{
|
||||
int LineCount;
|
||||
int CCount;
|
||||
|
@ -171,8 +171,8 @@ void ProgramFailNoParser(Picoc *pc, const char *Message, ...)
|
|||
|
||||
/* like ProgramFail() but gives descriptive error messages for assignment */
|
||||
void AssignFail(struct ParseState *Parser, const char *Format,
|
||||
struct ValueType *Type1, struct ValueType *Type2, int Num1, int Num2,
|
||||
const char *FuncName, int ParamNo)
|
||||
struct ValueType *Type1, struct ValueType *Type2, int Num1, int Num2,
|
||||
const char *FuncName, int ParamNo)
|
||||
{
|
||||
IOFILE *Stream = Parser->pc->CStdOut;
|
||||
|
||||
|
|
8
table.c
8
table.c
|
@ -37,7 +37,7 @@ unsigned int TableHash(const char *Key, int Len)
|
|||
|
||||
/* initialize a table */
|
||||
void TableInitTable(struct Table *Tbl, struct TableEntry **HashTable, int Size,
|
||||
int OnHeap)
|
||||
int OnHeap)
|
||||
{
|
||||
Tbl->Size = Size;
|
||||
Tbl->OnHeap = OnHeap;
|
||||
|
@ -65,7 +65,7 @@ struct TableEntry *TableSearch(struct Table *Tbl, const char *Key,
|
|||
/* set an identifier to a value. returns FALSE if it already exists.
|
||||
* Key must be a shared string from TableStrRegister() */
|
||||
int TableSet(Picoc *pc, struct Table *Tbl, char *Key, struct Value *Val,
|
||||
const char *DeclFileName, int DeclLine, int DeclColumn)
|
||||
const char *DeclFileName, int DeclLine, int DeclColumn)
|
||||
{
|
||||
int AddAt;
|
||||
struct TableEntry *FoundEntry = TableSearch(Tbl, Key, &AddAt);
|
||||
|
@ -89,7 +89,7 @@ int TableSet(Picoc *pc, struct Table *Tbl, char *Key, struct Value *Val,
|
|||
/* find a value in a table. returns FALSE if not found.
|
||||
* Key must be a shared string from TableStrRegister() */
|
||||
int TableGet(struct Table *Tbl, const char *Key, struct Value **Val,
|
||||
const char **DeclFileName, int *DeclLine, int *DeclColumn)
|
||||
const char **DeclFileName, int *DeclLine, int *DeclColumn)
|
||||
{
|
||||
int AddAt;
|
||||
struct TableEntry *FoundEntry = TableSearch(Tbl, Key, &AddAt);
|
||||
|
@ -131,7 +131,7 @@ struct Value *TableDelete(Picoc *pc, struct Table *Tbl, const char *Key)
|
|||
|
||||
/* check a hash table entry for an identifier */
|
||||
struct TableEntry *TableSearchIdentifier(struct Table *Tbl,
|
||||
const char *Key, int Len, int *AddAt)
|
||||
const char *Key, int Len, int *AddAt)
|
||||
{
|
||||
int HashValue = TableHash(Key, Len) % Tbl->Size;
|
||||
struct TableEntry *Entry;
|
||||
|
|
4
type.c
4
type.c
|
@ -313,7 +313,7 @@ void TypeParseStruct(struct ParseState *Parser, struct ValueType **Typ,
|
|||
|
||||
/* create a system struct which has no user-visible members */
|
||||
struct ValueType *TypeCreateOpaqueStruct(Picoc *pc, struct ParseState *Parser,
|
||||
const char *StructName, int Size)
|
||||
const char *StructName, int Size)
|
||||
{
|
||||
struct ValueType *Typ = TypeGetMatching(pc, Parser, &pc->UberType,
|
||||
TypeStruct, 0, StructName, false);
|
||||
|
@ -577,7 +577,7 @@ void TypeParseIdentPart(struct ParseState *Parser, struct ValueType *BasicTyp,
|
|||
|
||||
/* parse a type - a complete declaration including identifier */
|
||||
void TypeParse(struct ParseState *Parser, struct ValueType **Typ,
|
||||
char **Identifier, int *IsStatic)
|
||||
char **Identifier, int *IsStatic)
|
||||
{
|
||||
struct ValueType *BasicType;
|
||||
|
||||
|
|
|
@ -147,8 +147,8 @@ struct Value *VariableAllocValueAndCopy(Picoc *pc, struct ParseState *Parser,
|
|||
/* 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 ValueType *Typ, union AnyValue *FromValue, int IsLValue,
|
||||
struct Value *LValueFrom)
|
||||
{
|
||||
struct Value *NewValue = VariableAlloc(Parser->pc, Parser,
|
||||
sizeof(struct Value), false);
|
||||
|
@ -166,7 +166,7 @@ struct Value *VariableAllocValueFromExistingData(struct ParseState *Parser,
|
|||
/* allocate a value either on the heap or the stack from an
|
||||
existing Value, sharing the value */
|
||||
struct Value *VariableAllocValueShared(struct ParseState *Parser,
|
||||
struct Value *FromValue)
|
||||
struct Value *FromValue)
|
||||
{
|
||||
return VariableAllocValueFromExistingData(Parser, FromValue->Typ,
|
||||
FromValue->Val, FromValue->IsLValue,
|
||||
|
@ -459,7 +459,7 @@ void VariableStackPop(struct ParseState *Parser, struct Value *Var)
|
|||
|
||||
/* add a stack frame when doing a function call */
|
||||
void VariableStackFrameAdd(struct ParseState *Parser, const char *FuncName,
|
||||
int NumParams)
|
||||
int NumParams)
|
||||
{
|
||||
struct StackFrame *NewFrame;
|
||||
|
||||
|
|
Loading…
Reference in a new issue