formatting

This commit is contained in:
Joseph Poirier 2015-06-21 20:54:56 -05:00
parent 6e1c3aa71d
commit f551e28a49
6 changed files with 38 additions and 39 deletions

View file

@ -319,7 +319,7 @@ double ExpressionCoerceFP(struct Value *Val)
/* assign an integer value */ /* assign an integer value */
long ExpressionAssignInt(struct ParseState *Parser, struct Value *DestValue, long ExpressionAssignInt(struct ParseState *Parser, struct Value *DestValue,
long FromInt, int After) long FromInt, int After)
{ {
long Result; long Result;
@ -375,7 +375,7 @@ double ExpressionAssignFP(struct ParseState *Parser, struct Value *DestValue,
/* push a node on to the expression stack */ /* push a node on to the expression stack */
void ExpressionStackPushValueNode(struct ParseState *Parser, void ExpressionStackPushValueNode(struct ParseState *Parser,
struct ExpressionStack **StackTop, struct Value *ValueLoc) struct ExpressionStack **StackTop, struct Value *ValueLoc)
{ {
struct ExpressionStack *StackNode = VariableAlloc(Parser->pc, Parser, struct ExpressionStack *StackNode = VariableAlloc(Parser->pc, Parser,
sizeof(*StackNode), false); sizeof(*StackNode), false);
@ -393,7 +393,7 @@ void ExpressionStackPushValueNode(struct ParseState *Parser,
/* push a blank value on to the expression stack by type */ /* push a blank value on to the expression stack by type */
struct Value *ExpressionStackPushValueByType(struct ParseState *Parser, 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, struct Value *ValueLoc = VariableAllocValueFromType(Parser->pc, Parser,
PushType, false, NULL, false); PushType, false, NULL, false);
@ -404,7 +404,7 @@ struct Value *ExpressionStackPushValueByType(struct ParseState *Parser,
/* push a value on to the expression stack */ /* push a value on to the expression stack */
void ExpressionStackPushValue(struct ParseState *Parser, void ExpressionStackPushValue(struct ParseState *Parser,
struct ExpressionStack **StackTop, struct Value *PushValue) struct ExpressionStack **StackTop, struct Value *PushValue)
{ {
struct Value *ValueLoc = VariableAllocValueAndCopy(Parser->pc, Parser, struct Value *ValueLoc = VariableAllocValueAndCopy(Parser->pc, Parser,
PushValue, false); PushValue, false);
@ -412,7 +412,7 @@ void ExpressionStackPushValue(struct ParseState *Parser,
} }
void ExpressionStackPushLValue(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); struct Value *ValueLoc = VariableAllocValueShared(Parser, PushValue);
ValueLoc->Val = (void *)((char *)ValueLoc->Val + Offset); ValueLoc->Val = (void *)((char *)ValueLoc->Val + Offset);
@ -457,8 +457,8 @@ void ExpressionPushFP(struct ParseState *Parser,
/* assign to a pointer */ /* assign to a pointer */
void ExpressionAssignToPointer(struct ParseState *Parser, struct Value *ToValue, void ExpressionAssignToPointer(struct ParseState *Parser, struct Value *ToValue,
struct Value *FromValue, const char *FuncName, int ParamNo, struct Value *FromValue, const char *FuncName, int ParamNo,
int AllowPointerCoercion) int AllowPointerCoercion)
{ {
struct ValueType *PointedToType = ToValue->Typ->FromType; struct ValueType *PointedToType = ToValue->Typ->FromType;
@ -497,8 +497,8 @@ void ExpressionAssignToPointer(struct ParseState *Parser, struct Value *ToValue,
/* assign any kind of value */ /* assign any kind of value */
void ExpressionAssign(struct ParseState *Parser, struct Value *DestValue, void ExpressionAssign(struct ParseState *Parser, struct Value *DestValue,
struct Value *SourceValue, int Force, const char *FuncName, int ParamNo, struct Value *SourceValue, int Force, const char *FuncName, int ParamNo,
int AllowPointerCoercion) int AllowPointerCoercion)
{ {
if (!DestValue->IsLValue && !Force) if (!DestValue->IsLValue && !Force)
AssignFail(Parser, "not an lvalue", NULL, NULL, 0, 0, FuncName, ParamNo); 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 */ /* evaluate the first half of a ternary operator x ? y : z */
void ExpressionQuestionMarkOperator(struct ParseState *Parser, void ExpressionQuestionMarkOperator(struct ParseState *Parser,
struct ExpressionStack **StackTop, struct Value *BottomValue, struct ExpressionStack **StackTop, struct Value *BottomValue,
struct Value *TopValue) struct Value *TopValue)
{ {
if (!IS_NUMERIC_COERCIBLE(TopValue)) if (!IS_NUMERIC_COERCIBLE(TopValue))
ProgramFail(Parser, "first argument to '?' should be a number"); 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 */ /* evaluate the second half of a ternary operator x ? y : z */
void ExpressionColonOperator(struct ParseState *Parser, void ExpressionColonOperator(struct ParseState *Parser,
struct ExpressionStack **StackTop, struct Value *BottomValue, struct ExpressionStack **StackTop, struct Value *BottomValue,
struct Value *TopValue) struct Value *TopValue)
{ {
if (TopValue->Typ->Base == TypeVoid) { if (TopValue->Typ->Base == TypeVoid) {
/* invoke the "else" part - return the BottomValue */ /* invoke the "else" part - return the BottomValue */
@ -863,8 +863,8 @@ void ExpressionPostfixOperator(struct ParseState *Parser,
/* evaluate an infix operator */ /* evaluate an infix operator */
void ExpressionInfixOperator(struct ParseState *Parser, void ExpressionInfixOperator(struct ParseState *Parser,
struct ExpressionStack **StackTop, enum LexToken Op, struct ExpressionStack **StackTop, enum LexToken Op,
struct Value *BottomValue, struct Value *TopValue) struct Value *BottomValue, struct Value *TopValue)
{ {
long ResultInt = 0; long ResultInt = 0;
struct Value *StackValue; struct Value *StackValue;
@ -1192,7 +1192,7 @@ void ExpressionInfixOperator(struct ParseState *Parser,
/* take the contents of the expression stack and compute the top until /* take the contents of the expression stack and compute the top until
there's nothing greater than the given precedence */ there's nothing greater than the given precedence */
void ExpressionStackCollapse(struct ParseState *Parser, void ExpressionStackCollapse(struct ParseState *Parser,
struct ExpressionStack **StackTop, int Precedence, int *IgnorePrecedence) struct ExpressionStack **StackTop, int Precedence, int *IgnorePrecedence)
{ {
int FoundPrecedence = Precedence; int FoundPrecedence = Precedence;
struct Value *TopValue; struct Value *TopValue;
@ -1303,8 +1303,7 @@ void ExpressionStackCollapse(struct ParseState *Parser,
/* we're not running it so just return 0 */ /* we're not running it so just return 0 */
ExpressionPushInt(Parser, StackTop, 0); ExpressionPushInt(Parser, StackTop, 0);
} }
} } else
else
FoundPrecedence = -1; FoundPrecedence = -1;
break; break;
case OrderNone: case OrderNone:
@ -1332,8 +1331,8 @@ void ExpressionStackCollapse(struct ParseState *Parser,
/* push an operator on to the expression stack */ /* push an operator on to the expression stack */
void ExpressionStackPushOperator(struct ParseState *Parser, void ExpressionStackPushOperator(struct ParseState *Parser,
struct ExpressionStack **StackTop, enum OperatorOrder Order, struct ExpressionStack **StackTop, enum OperatorOrder Order,
enum LexToken Token, int Precedence) enum LexToken Token, int Precedence)
{ {
struct ExpressionStack *StackNode = VariableAlloc(Parser->pc, Parser, struct ExpressionStack *StackNode = VariableAlloc(Parser->pc, Parser,
sizeof(*StackNode), false); sizeof(*StackNode), false);
@ -1356,7 +1355,7 @@ void ExpressionStackPushOperator(struct ParseState *Parser,
/* do the '.' and '->' operators */ /* do the '.' and '->' operators */
void ExpressionGetStructElement(struct ParseState *Parser, void ExpressionGetStructElement(struct ParseState *Parser,
struct ExpressionStack **StackTop, enum LexToken Token) struct ExpressionStack **StackTop, enum LexToken Token)
{ {
struct Value *Ident; struct Value *Ident;
@ -1693,8 +1692,8 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result)
/* do a parameterized 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)
{ {
int ArgCount; int ArgCount;
enum LexToken Token; enum LexToken Token;
@ -1771,7 +1770,7 @@ void ExpressionParseMacroCall(struct ParseState *Parser,
/* do a function call */ /* do a function call */
void ExpressionParseFunctionCall(struct ParseState *Parser, void ExpressionParseFunctionCall(struct ParseState *Parser,
struct ExpressionStack **StackTop, const char *FuncName, int RunIt) struct ExpressionStack **StackTop, const char *FuncName, int RunIt)
{ {
int ArgCount; int ArgCount;
enum LexToken Token = LexGetToken(Parser, NULL, true); /* open bracket */ enum LexToken Token = LexGetToken(Parser, NULL, true); /* open bracket */

View file

@ -41,7 +41,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, enum ParseResult ParseStatementMaybeRun(struct ParseState *Parser,
int Condition, int CheckTrailingSemicolon) int Condition, int CheckTrailingSemicolon)
{ {
if (Parser->Mode != RunModeSkip && !Condition) { if (Parser->Mode != RunModeSkip && !Condition) {
enum RunMode OldMode = Parser->Mode; enum RunMode OldMode = Parser->Mode;
@ -75,7 +75,7 @@ int ParseCountParams(struct ParseState *Parser)
/* parse a function definition and store it for later */ /* parse a function definition and store it for later */
struct Value *ParseFunctionDefinition(struct ParseState *Parser, struct Value *ParseFunctionDefinition(struct ParseState *Parser,
struct ValueType *ReturnType, char *Identifier) struct ValueType *ReturnType, char *Identifier)
{ {
int ParamCount = 0; int ParamCount = 0;
char *ParamIdentifier; char *ParamIdentifier;

View file

@ -104,7 +104,7 @@ void PicocCallMain(Picoc *pc, int argc, char **argv)
#endif #endif
void PrintSourceTextErrorLine(IOFILE *Stream, const char *FileName, void PrintSourceTextErrorLine(IOFILE *Stream, const char *FileName,
const char *SourceText, int Line, int CharacterPos) const char *SourceText, int Line, int CharacterPos)
{ {
int LineCount; int LineCount;
int CCount; int CCount;
@ -171,8 +171,8 @@ void ProgramFailNoParser(Picoc *pc, const char *Message, ...)
/* like ProgramFail() but gives descriptive error messages for assignment */ /* like ProgramFail() but gives descriptive error messages for assignment */
void AssignFail(struct ParseState *Parser, const char *Format, void AssignFail(struct ParseState *Parser, const char *Format,
struct ValueType *Type1, struct ValueType *Type2, int Num1, int Num2, struct ValueType *Type1, struct ValueType *Type2, int Num1, int Num2,
const char *FuncName, int ParamNo) const char *FuncName, int ParamNo)
{ {
IOFILE *Stream = Parser->pc->CStdOut; IOFILE *Stream = Parser->pc->CStdOut;

View file

@ -37,7 +37,7 @@ unsigned int TableHash(const char *Key, int Len)
/* initialize a table */ /* initialize a table */
void TableInitTable(struct Table *Tbl, struct TableEntry **HashTable, int Size, void TableInitTable(struct Table *Tbl, struct TableEntry **HashTable, int Size,
int OnHeap) int OnHeap)
{ {
Tbl->Size = Size; Tbl->Size = Size;
Tbl->OnHeap = OnHeap; 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. /* set an identifier to a value. returns FALSE if it already exists.
* Key must be a shared string from TableStrRegister() */ * Key must be a shared string from TableStrRegister() */
int TableSet(Picoc *pc, struct Table *Tbl, char *Key, struct Value *Val, 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; int AddAt;
struct TableEntry *FoundEntry = TableSearch(Tbl, Key, &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. /* find a value in a table. returns FALSE if not found.
* Key must be a shared string from TableStrRegister() */ * Key must be a shared string from TableStrRegister() */
int TableGet(struct Table *Tbl, const char *Key, struct Value **Val, 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; int AddAt;
struct TableEntry *FoundEntry = TableSearch(Tbl, Key, &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 */ /* check a hash table entry for an identifier */
struct TableEntry *TableSearchIdentifier(struct Table *Tbl, 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; int HashValue = TableHash(Key, Len) % Tbl->Size;
struct TableEntry *Entry; struct TableEntry *Entry;

4
type.c
View file

@ -313,7 +313,7 @@ void TypeParseStruct(struct ParseState *Parser, struct ValueType **Typ,
/* create a system struct which has no user-visible members */ /* create a system struct which has no user-visible members */
struct ValueType *TypeCreateOpaqueStruct(Picoc *pc, struct ParseState *Parser, 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, struct ValueType *Typ = TypeGetMatching(pc, Parser, &pc->UberType,
TypeStruct, 0, StructName, false); TypeStruct, 0, StructName, false);
@ -577,7 +577,7 @@ void TypeParseIdentPart(struct ParseState *Parser, struct ValueType *BasicTyp,
/* parse a type - a complete declaration including identifier */ /* parse a type - a complete declaration including identifier */
void TypeParse(struct ParseState *Parser, struct ValueType **Typ, void TypeParse(struct ParseState *Parser, struct ValueType **Typ,
char **Identifier, int *IsStatic) char **Identifier, int *IsStatic)
{ {
struct ValueType *BasicType; struct ValueType *BasicType;

View file

@ -147,8 +147,8 @@ struct Value *VariableAllocValueAndCopy(Picoc *pc, struct ParseState *Parser,
/* allocate a value either on the heap or the stack from an /* allocate a value either on the heap or the stack from an
existing AnyValue and type */ existing AnyValue and type */
struct Value *VariableAllocValueFromExistingData(struct ParseState *Parser, struct Value *VariableAllocValueFromExistingData(struct ParseState *Parser,
struct ValueType *Typ, union AnyValue *FromValue, int IsLValue, struct ValueType *Typ, union AnyValue *FromValue, int IsLValue,
struct Value *LValueFrom) struct Value *LValueFrom)
{ {
struct Value *NewValue = VariableAlloc(Parser->pc, Parser, struct Value *NewValue = VariableAlloc(Parser->pc, Parser,
sizeof(struct Value), false); 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 /* allocate a value either on the heap or the stack from an
existing Value, sharing the value */ existing Value, sharing the value */
struct Value *VariableAllocValueShared(struct ParseState *Parser, struct Value *VariableAllocValueShared(struct ParseState *Parser,
struct Value *FromValue) struct Value *FromValue)
{ {
return VariableAllocValueFromExistingData(Parser, FromValue->Typ, return VariableAllocValueFromExistingData(Parser, FromValue->Typ,
FromValue->Val, FromValue->IsLValue, 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 */ /* add a stack frame when doing a function call */
void VariableStackFrameAdd(struct ParseState *Parser, const char *FuncName, void VariableStackFrameAdd(struct ParseState *Parser, const char *FuncName,
int NumParams) int NumParams)
{ {
struct StackFrame *NewFrame; struct StackFrame *NewFrame;