initialize
This commit is contained in:
parent
26b21d04be
commit
9c05060820
|
@ -333,7 +333,7 @@ void PlatformLibraryInit()
|
|||
```
|
||||
|
||||
This code takes the structure definition in StructDefinition and runs the lexical
|
||||
analyser over it. This returns some lexical tokens. Then we initialise the parser
|
||||
analyser over it. This returns some lexical tokens. Then we initialize the parser
|
||||
and have it parse the type of the structure definition from the tokens we made.
|
||||
That's enough to define the structure in the system. Finally we free the tokens.
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ struct StdVararg
|
|||
int NumArgs;
|
||||
};
|
||||
|
||||
/* initialises the I/O system so error reporting works */
|
||||
/* initializes the I/O system so error reporting works */
|
||||
void BasicIOInit(Picoc *pc)
|
||||
{
|
||||
pc->CStdOut = stdout;
|
||||
|
|
2
debug.c
2
debug.c
|
@ -4,7 +4,7 @@
|
|||
#define BREAKPOINT_HASH(p) (((unsigned long)(p)->FileName) ^ (((p)->Line << 16) | ((p)->CharacterPos << 16)))
|
||||
|
||||
#ifdef DEBUGGER
|
||||
/* initialise the debugger by clearing the breakpoint table */
|
||||
/* initialize the debugger by clearing the breakpoint table */
|
||||
void DebugInit(Picoc *pc)
|
||||
{
|
||||
TableInitTable(&pc->BreakpointTable, &pc->BreakpointHashTable[0],
|
||||
|
|
2
heap.c
2
heap.c
|
@ -18,7 +18,7 @@ void ShowBigList(Picoc *pc)
|
|||
}
|
||||
#endif
|
||||
|
||||
/* initialise the stack and heap storage */
|
||||
/* initialize the stack and heap storage */
|
||||
void HeapInit(Picoc *pc, int StackOrHeapSize)
|
||||
{
|
||||
int Count;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "interpreter.h"
|
||||
|
||||
|
||||
/* initialise the built-in include libraries */
|
||||
/* initialize the built-in include libraries */
|
||||
void IncludeInit(Picoc *pc)
|
||||
{
|
||||
IncludeRegister(pc, "ctype.h", NULL, &StdCtypeFunctions[0], NULL);
|
||||
|
|
|
@ -633,7 +633,7 @@ extern void LibPrintf(struct ParseState *Parser, struct Value *ReturnValue,
|
|||
/* the following are defined in picoc.h:
|
||||
* void PicocCallMain(int argc, char **argv);
|
||||
* int PicocPlatformSetExitPoint();
|
||||
* void PicocInitialise(int StackSize);
|
||||
* void PicocInitialize(int StackSize);
|
||||
* void PicocCleanup();
|
||||
* void PicocPlatformScanFile(const char *FileName);
|
||||
* extern int PicocExitValue; */
|
||||
|
|
2
lex.c
2
lex.c
|
@ -97,7 +97,7 @@ static struct ReservedWord ReservedWords[] = {
|
|||
|
||||
|
||||
|
||||
/* initialise the lexer */
|
||||
/* initialize the lexer */
|
||||
void LexInit(Picoc *pc)
|
||||
{
|
||||
int Count;
|
||||
|
|
22
parse.c
22
parse.c
|
@ -5,7 +5,7 @@
|
|||
static enum ParseResult ParseStatementMaybeRun(struct ParseState *Parser,
|
||||
int Condition, int CheckTrailingSemicolon);
|
||||
static int ParseCountParams(struct ParseState *Parser);
|
||||
static int ParseArrayInitialiser(struct ParseState *Parser,
|
||||
static int ParseArrayInitializer(struct ParseState *Parser,
|
||||
struct Value *NewVariable, int DoAssignment);
|
||||
static void ParseDeclarationAssignment(struct ParseState *Parser,
|
||||
struct Value *NewVariable, int DoAssignment);
|
||||
|
@ -186,8 +186,8 @@ struct Value *ParseFunctionDefinition(struct ParseState *Parser,
|
|||
return FuncValue;
|
||||
}
|
||||
|
||||
/* parse an array initialiser and assign to a variable */
|
||||
int ParseArrayInitialiser(struct ParseState *Parser, struct Value *NewVariable,
|
||||
/* parse an array initializer and assign to a variable */
|
||||
int ParseArrayInitializer(struct ParseState *Parser, struct Value *NewVariable,
|
||||
int DoAssignment)
|
||||
{
|
||||
int ArrayIndex = 0;
|
||||
|
@ -200,7 +200,7 @@ int ParseArrayInitialiser(struct ParseState *Parser, struct Value *NewVariable,
|
|||
int NumElements;
|
||||
|
||||
ParserCopy(&CountParser, Parser);
|
||||
NumElements = ParseArrayInitialiser(&CountParser, NewVariable, false);
|
||||
NumElements = ParseArrayInitializer(&CountParser, NewVariable, false);
|
||||
|
||||
if (NewVariable->Typ->Base != TypeArray)
|
||||
AssignFail(Parser, "%t from array initializer", NewVariable->Typ,
|
||||
|
@ -218,11 +218,11 @@ int ParseArrayInitialiser(struct ParseState *Parser, struct Value *NewVariable,
|
|||
#endif
|
||||
}
|
||||
|
||||
/* parse the array initialiser */
|
||||
/* parse the array initializer */
|
||||
Token = LexGetToken(Parser, NULL, false);
|
||||
while (Token != TokenRightBrace) {
|
||||
if (LexGetToken(Parser, NULL, false) == TokenLeftBrace) {
|
||||
/* this is a sub-array initialiser */
|
||||
/* this is a sub-array initializer */
|
||||
int SubArraySize = 0;
|
||||
struct Value *SubArray = NewVariable;
|
||||
if (Parser->Mode == RunModeRun && DoAssignment) {
|
||||
|
@ -245,7 +245,7 @@ int ParseArrayInitialiser(struct ParseState *Parser, struct Value *NewVariable,
|
|||
ProgramFail(Parser, "too many array elements");
|
||||
}
|
||||
LexGetToken(Parser, NULL, true);
|
||||
ParseArrayInitialiser(Parser, SubArray, DoAssignment);
|
||||
ParseArrayInitializer(Parser, SubArray, DoAssignment);
|
||||
} else {
|
||||
struct Value *ArrayElement = NULL;
|
||||
|
||||
|
@ -281,7 +281,7 @@ int ParseArrayInitialiser(struct ParseState *Parser, struct Value *NewVariable,
|
|||
true, NewVariable);
|
||||
}
|
||||
|
||||
/* this is a normal expression initialiser */
|
||||
/* this is a normal expression initializer */
|
||||
if (!ExpressionParse(Parser, &CValue))
|
||||
ProgramFail(Parser, "expression expected");
|
||||
|
||||
|
@ -318,11 +318,11 @@ void ParseDeclarationAssignment(struct ParseState *Parser,
|
|||
struct Value *CValue;
|
||||
|
||||
if (LexGetToken(Parser, NULL, false) == TokenLeftBrace) {
|
||||
/* this is an array initialiser */
|
||||
/* this is an array initializer */
|
||||
LexGetToken(Parser, NULL, true);
|
||||
ParseArrayInitialiser(Parser, NewVariable, DoAssignment);
|
||||
ParseArrayInitializer(Parser, NewVariable, DoAssignment);
|
||||
} else {
|
||||
/* this is a normal expression initialiser */
|
||||
/* this is a normal expression initializer */
|
||||
if (!ExpressionParse(Parser, &CValue))
|
||||
ProgramFail(Parser, "expression expected");
|
||||
|
||||
|
|
2
picoc.c
2
picoc.c
|
@ -41,7 +41,7 @@ int main(int argc, char **argv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
PicocInitialise(&pc, StackSize);
|
||||
PicocInitialize(&pc, StackSize);
|
||||
|
||||
if (strcmp(argv[ParamCount], "-s") == 0) {
|
||||
DontRunMain = true;
|
||||
|
|
2
picoc.h
2
picoc.h
|
@ -26,7 +26,7 @@ extern void PicocParseInteractive(Picoc *pc);
|
|||
|
||||
/* platform.c */
|
||||
extern void PicocCallMain(Picoc *pc, int argc, char **argv);
|
||||
extern void PicocInitialise(Picoc *pc, int StackSize);
|
||||
extern void PicocInitialize(Picoc *pc, int StackSize);
|
||||
extern void PicocCleanup(Picoc *pc);
|
||||
extern void PicocPlatformScanFile(Picoc *pc, const char *FileName);
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ static int gEnableDebugger = false;
|
|||
#endif
|
||||
|
||||
|
||||
/* initialise everything */
|
||||
void PicocInitialise(Picoc *pc, int StackSize)
|
||||
/* initialize everything */
|
||||
void PicocInitialize(Picoc *pc, int StackSize)
|
||||
{
|
||||
memset(pc, '\0', sizeof(*pc));
|
||||
PlatformInit(pc);
|
||||
|
@ -255,7 +255,7 @@ void PlatformVPrintf(IOFILE *Stream, const char *Format, va_list Args)
|
|||
}
|
||||
|
||||
/* make a new temporary name. takes a static buffer of char [7] as a parameter.
|
||||
* should be initialised to "XX0000"
|
||||
* should be initialized to "XX0000"
|
||||
* where XX can be any characters */
|
||||
char *PlatformMakeTempName(Picoc *pc, char *TempNameBuffer)
|
||||
{
|
||||
|
|
4
table.c
4
table.c
|
@ -10,7 +10,7 @@ static struct TableEntry *TableSearch(struct Table *Tbl, const char *Key,
|
|||
static struct TableEntry *TableSearchIdentifier(struct Table *Tbl,
|
||||
const char *Key, int Len, int *AddAt);
|
||||
|
||||
/* initialise the shared string system */
|
||||
/* initialize the shared string system */
|
||||
void TableInit(Picoc *pc)
|
||||
{
|
||||
TableInitTable(&pc->StringTable, &pc->StringHashTable[0],
|
||||
|
@ -35,7 +35,7 @@ unsigned int TableHash(const char *Key, int Len)
|
|||
return Hash;
|
||||
}
|
||||
|
||||
/* initialise a table */
|
||||
/* initialize a table */
|
||||
void TableInitTable(struct Table *Tbl, struct TableEntry **HashTable, int Size,
|
||||
int OnHeap)
|
||||
{
|
||||
|
|
|
@ -33,7 +33,7 @@ TESTS= 00_assignment.test \
|
|||
33_ternary_op.test \
|
||||
34_array_assignment.test \
|
||||
35_sizeof.test \
|
||||
36_array_initialisers.test \
|
||||
36_array_initializers.test \
|
||||
37_sprintf.test \
|
||||
38_multiple_array_index.test \
|
||||
39_typedef.test \
|
||||
|
@ -49,7 +49,7 @@ TESTS= 00_assignment.test \
|
|||
51_static.test \
|
||||
52_unnamed_enum.test \
|
||||
54_goto.test \
|
||||
55_array_initialiser.test \
|
||||
55_array_initializer.test \
|
||||
56_cross_structure.test \
|
||||
57_macro_bug.test \
|
||||
58_return_outside.test \
|
||||
|
|
2
type.c
2
type.c
|
@ -136,7 +136,7 @@ void TypeAddBaseType(Picoc *pc, struct ValueType *TypeNode, enum BaseType Base,
|
|||
pc->UberType.DerivedTypeList = TypeNode;
|
||||
}
|
||||
|
||||
/* initialise the type system */
|
||||
/* initialize the type system */
|
||||
void TypeInit(Picoc *pc)
|
||||
{
|
||||
struct IntAlign {char x; int y;} ia;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#define MAX_TMP_COPY_BUF (256)
|
||||
|
||||
|
||||
/* initialise the variable system */
|
||||
/* initialize the variable system */
|
||||
void VariableInit(Picoc *pc)
|
||||
{
|
||||
TableInitTable(&(pc->GlobalTable), &(pc->GlobalHashTable)[0],
|
||||
|
|
Loading…
Reference in a new issue