Removed unused path in TableSet()
git-svn-id: http://picoc.googlecode.com/svn/trunk@16 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
parent
eba1492fcb
commit
ebf601bfb9
11
parse.c
11
parse.c
|
@ -30,17 +30,10 @@ void VariableDefine(struct LexState *Lexer, const Str *Ident, enum ValueType Typ
|
|||
|
||||
memset(&NewValue, '\0', sizeof(NewValue));
|
||||
NewValue.Typ = Typ;
|
||||
if (!TableSet(&GlobalTable, Ident, &NewValue, FALSE))
|
||||
if (!TableSet(&GlobalTable, Ident, &NewValue))
|
||||
ProgramFail(Lexer, "'%S' is already defined", Ident);
|
||||
}
|
||||
|
||||
/* set the value of a variable */
|
||||
void VariableSet(struct LexState *Lexer, Str *Ident, struct Value *Val)
|
||||
{
|
||||
if (!TableSet(&GlobalTable, Ident, Val, TRUE))
|
||||
ProgramFail(Lexer, "'%S' is undefined", Ident);
|
||||
}
|
||||
|
||||
/* get the value of a variable. must be defined */
|
||||
void VariableGet(struct LexState *Lexer, Str *Ident, struct Value *Val, struct Value **LVal)
|
||||
{
|
||||
|
@ -208,7 +201,7 @@ void ParseFunctionDefinition(struct LexState *Lexer, Str *Identifier, struct Lex
|
|||
FuncValue.Val.Integer = FunctionStoreUsed;
|
||||
FunctionStoreUsed++;
|
||||
|
||||
if (!TableSet(&GlobalTable, Identifier, &FuncValue, FALSE))
|
||||
if (!TableSet(&GlobalTable, Identifier, &FuncValue))
|
||||
ProgramFail(Lexer, "'%S' is already defined", Identifier);
|
||||
}
|
||||
|
||||
|
|
2
picoc.h
2
picoc.h
|
@ -158,7 +158,7 @@ void ScanFile(const Str *FileName);
|
|||
|
||||
/* table.c */
|
||||
void TableInit(struct Table *Tbl, struct TableEntry *HashTable, const char *Name, int Size);
|
||||
int TableSet(struct Table *Tbl, const Str *Key, struct Value *Val, int Exists);
|
||||
int TableSet(struct Table *Tbl, const Str *Key, struct Value *Val);
|
||||
int TableGet(struct Table *Tbl, const Str *Key, struct Value **Val);
|
||||
|
||||
/* lex.c */
|
||||
|
|
9
table.c
9
table.c
|
@ -77,19 +77,14 @@ static int TableSearch(struct Table *Tbl, const Str *Key, int *AddAt)
|
|||
}
|
||||
|
||||
|
||||
int TableSet(struct Table *Tbl, const Str *Key, struct Value *Val, int Exists)
|
||||
int TableSet(struct Table *Tbl, const Str *Key, struct Value *Val)
|
||||
{
|
||||
int HashPos;
|
||||
int AddAt;
|
||||
|
||||
HashPos = TableSearch(Tbl, Key, &AddAt);
|
||||
|
||||
if ( (HashPos != -1) != Exists)
|
||||
return FALSE;
|
||||
|
||||
if (HashPos != -1)
|
||||
Tbl->HashTable[HashPos].Val = *Val; /* found - update value */
|
||||
else
|
||||
if (HashPos == -1)
|
||||
{
|
||||
if (AddAt == -1)
|
||||
Fail("table '%s' is full\n", Tbl->Name);
|
||||
|
|
Loading…
Reference in a new issue