Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
Rewrite VarTable
Browse files Browse the repository at this point in the history
  • Loading branch information
mitrokosta committed May 30, 2021
1 parent b3244b9 commit fff9ab5
Show file tree
Hide file tree
Showing 7 changed files with 189 additions and 323 deletions.
4 changes: 2 additions & 2 deletions src/apps/ENGINE/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ const char *CORE::EngineIniFileName()

void *CORE::GetScriptVariable(const char *pVariableName, uint32_t *pdwVarIndex)
{
VARINFO vi;
VarInfo vi;

const auto dwVarIndex = Compiler->VarTab.FindVar(pVariableName);
if (dwVarIndex == INVALID_VAR_CODE || !Compiler->VarTab.GetVar(vi, dwVarIndex))
Expand All @@ -895,7 +895,7 @@ void *CORE::GetScriptVariable(const char *pVariableName, uint32_t *pdwVarIndex)
if (pdwVarIndex)
*pdwVarIndex = dwVarIndex;

return vi.pDClass;
return vi.value.get();
}

void CORE::Start_CriticalSection()
Expand Down
136 changes: 67 additions & 69 deletions src/apps/ENGINE/compiler.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/apps/ENGINE/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class COMPILER : public VIRTUAL_COMPILER

FUNCINFO *pRun_fi; // running function info
S_FUNCTAB FuncTab;
S_VARTAB VarTab;
VarTable VarTab;
S_CLASSTAB ClassTab;
S_DEFTAB DefTab;
S_STACK SStack;
Expand Down
24 changes: 12 additions & 12 deletions src/apps/ENGINE/expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ bool COMPILER::BC_ProcessExpression(DATA *value)
//--------------------------------------------------------------------------
if (TokenIs(AND))
{
VARINFO vi;
VarInfo vi;

auto Token_type = BC_TokenGet();
if (TokenType() != VARIABLE)
Expand All @@ -45,7 +45,7 @@ bool COMPILER::BC_ProcessExpression(DATA *value)
SetError("Global variable not found");
return false;
}
pV = vi.pDClass;
pV = vi.value.get();
}
else
{
Expand Down Expand Up @@ -422,7 +422,7 @@ void COMPILER::BC_ProcessExpression_L6(DATA *value, bool bSkip)

void COMPILER::BC_ProcessExpression_L7(DATA *value, bool bSkip)
{
VARINFO vi;
VarInfo vi;
uint32_t var_code;
long index;
DATA array_index;
Expand Down Expand Up @@ -515,7 +515,7 @@ void COMPILER::BC_ProcessExpression_L7(DATA *value, bool bSkip)
SetError("Global variable not found");
return;
}
pVV = vi.pDClass;
pVV = vi.value.get();
}
else
{
Expand Down Expand Up @@ -607,7 +607,7 @@ void COMPILER::BC_ProcessExpression_L7(DATA *value, bool bSkip)
SetError("Global variable not found");
break;
}
pV = vi.pDClass;
pV = vi.value.get();
}
else
{
Expand Down Expand Up @@ -809,7 +809,7 @@ void COMPILER::BC_ProcessExpression_L7(DATA *value, bool bSkip)
SetError("Global variable not found");
break;
}
pV = vi.pDClass;
pV = vi.value.get();
}
else
{
Expand Down Expand Up @@ -860,7 +860,7 @@ void COMPILER::BC_ProcessExpression_L7(DATA *value, bool bSkip)
bool COMPILER::CompileExpression(SEGMENT_DESC &Segment)
{
uint32_t dwVarCode;
VARINFO vi;
VarInfo vi;
LVARINFO lvi;

const S_TOKEN_TYPE Token_type = CompileAuxiliaryTokens(Segment);
Expand Down Expand Up @@ -900,12 +900,12 @@ bool COMPILER::CompileExpression(SEGMENT_DESC &Segment)
{
VarTab.GetVarX(vi, dwVarCode);
// check for possibilities of '[' operator
if (!vi.bArray)
if (!vi.IsArray())
{
if (vi.type != VAR_REFERENCE)
{
SetError("EN: %d", vi.elements);
SetError(" A Invalid '[' operator, %s - isnt array", vi.name);
SetError(" A Invalid '[' operator, %s - isnt array", vi.name.c_str());
return false;
}
}
Expand Down Expand Up @@ -1232,7 +1232,7 @@ bool COMPILER::CompileExpression_L7(SEGMENT_DESC &Segment)
S_TOKEN_TYPE sttFuncCallType;
uint32_t dwVarCode;
uint32_t dwAWCode;
VARINFO vi;
VarInfo vi;
LVARINFO lvi;
FUNCINFO fi;

Expand Down Expand Up @@ -1467,11 +1467,11 @@ bool COMPILER::CompileExpression_L7(SEGMENT_DESC &Segment)
{
VarTab.GetVarX(vi, dwVarCode);
// check for possibilities of '[' operator
if (!vi.bArray)
if (!vi.IsArray())
{
if (vi.type != VAR_REFERENCE)
{
SetError(" C Invalid '[' operator, %s - isnt array", vi.name);
SetError(" C Invalid '[' operator, %s - isnt array", vi.name.c_str());
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/apps/ENGINE/internal_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1347,7 +1347,7 @@ DATA *COMPILER::BC_CallIntFunction(uint32_t func_code, DATA *&pVResult, uint32_t
pV->SetElementsNum(TempLong1);

if (pV->nGlobalVarTableIndex != 0xffffffff)
VarTab.ArraySizeChanged(pV->nGlobalVarTableIndex, TempLong1);
VarTab.SetElementsNum(pV->nGlobalVarTableIndex, TempLong1);

break;

Expand Down
Loading

0 comments on commit fff9ab5

Please sign in to comment.