-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlowlevel.cpp
87 lines (75 loc) · 1.74 KB
/
lowlevel.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include "stdafx.h" // pre-compiled headers
#include "globaldata.h" // for access to many global vars
#include "application.h" // for MsgSleep()
#include "exports.h"
#include "script.h"
// #define BETA
#define BIF(fun) void fun(ExprTokenType &aResultToken, ExprTokenType *aParam[], int aParamCount)
BIF(BIF_Getvar)
{
int i = 0;
if (aParam[0]->symbol == SYM_VAR)
i = (int)aParam[0]->var;
aResultToken.value_int64 = i;
}
BIF(BIF_Static)
{
if (aParam[0]->symbol == SYM_VAR)
{
Var *var = aParam[0]->var;
if (var->mType == VAR_ALIAS)
var = var->mAliasFor;
var->mAttrib |= VAR_ATTRIB_STATIC;
}
}
BIF(BIF_Alias)
{
ExprTokenType &aParam0 = *aParam[0];
ExprTokenType &aParam1 = *aParam[1];
if (aParam0.symbol == SYM_VAR)
{
Var &var = *aParam0.var;
UINT len = 0;
switch (aParam1.symbol)
{
case SYM_VAR:
case SYM_INTEGER:
len = (UINT)aParam1.var;
}
var.mType = len ? VAR_ALIAS : VAR_NORMAL;
var.mLength = len;
}
}
BIF(BIF_GetTokenValue)
{
ExprTokenType *token = aParam[0];
if (token->symbol != SYM_INTEGER)
return;
token = (ExprTokenType*) token->value_int64;
if (token->symbol == SYM_VAR)
{
Var &var = *token->var;
#ifdef BETA
VarAttribType cache_attrib = var.mAttrib & (VAR_ATTRIB_HAS_VALID_INT64 | VAR_ATTRIB_HAS_VALID_DOUBLE);
if (cache_attrib)
{
aResultToken.symbol = (SymbolType) (cache_attrib >> 4);
aResultToken.value_int64 = var.mContentsInt64;
}
else
#endif
{
aResultToken.symbol = SYM_OPERAND;
aResultToken.marker = var.mContents;
}
}
else
{
aResultToken.symbol = token->symbol;
aResultToken.value_int64 = token->value_int64;
}
}
BIF(BIF_CacheEnable)
{
// to implement
}