- scriptified Hexen's flies.
A few notes: * this accesses the lines array in sector_t which effectively is a pointer to an array of pointers - a type the parser can not represent. The compiler has no problems with it, so for now it is defined internally. * array sizes were limited to 65536 entries because the 'bound' instruction only existed as an immediate version with no provisions for larger values. For the static map arrays 65536 is not sufficient so now there are alternative instructions for these cases. * despite the above, at the moment there is no proper bounds checking for arrays that have no fixed size. To do this, a lot more work is needed. The type system as-is is not prepared for such a scenario.
This commit is contained in:
parent
aab304c0cf
commit
de6969997a
14 changed files with 241 additions and 45 deletions
|
|
@ -779,6 +779,7 @@ VMFunction *FFunctionBuildList::AddFunction(PFunction *functype, FxExpression *c
|
|||
it.PrintableName = name;
|
||||
it.Function = new VMScriptFunction;
|
||||
it.Function->Name = functype->SymbolName;
|
||||
it.Function->PrintableName = name;
|
||||
it.Function->ImplicitArgs = functype->GetImplicitArgs();
|
||||
it.Proto = nullptr;
|
||||
it.FromDecorate = fromdecorate;
|
||||
|
|
@ -881,7 +882,6 @@ void FFunctionBuildList::Build()
|
|||
DumpFunction(dump, sfunc, item.PrintableName.GetChars(), (int)item.PrintableName.Len());
|
||||
codesize += sfunc->CodeSize;
|
||||
}
|
||||
sfunc->PrintableName = item.PrintableName;
|
||||
sfunc->Unsafe = ctx.Unsafe;
|
||||
}
|
||||
catch (CRecoverableError &err)
|
||||
|
|
|
|||
|
|
@ -104,7 +104,6 @@
|
|||
#define RIKIRI MODE_AI | MODE_BKI | MODE_CI
|
||||
#define RIKII8 MODE_AI | MODE_BKI | MODE_CIMMZ
|
||||
#define RIRIIs MODE_AI | MODE_BI | MODE_CIMMS
|
||||
#define RIRI MODE_AI | MODE_BI | MODE_CUNUSED
|
||||
#define I8RIRI MODE_AIMMZ | MODE_BI | MODE_CI
|
||||
#define I8RIKI MODE_AIMMZ | MODE_BI | MODE_CKI
|
||||
#define I8KIRI MODE_AIMMZ | MODE_BKI | MODE_CI
|
||||
|
|
|
|||
|
|
@ -713,6 +713,7 @@ begin:
|
|||
assert(0);
|
||||
NEXTOP;
|
||||
|
||||
// Fixme: This really needs to throw something more informative than a number. Printing the message here instead of passing it to the exception is not sufficient.
|
||||
OP(BOUND):
|
||||
if (reg.d[a] >= BC)
|
||||
{
|
||||
|
|
@ -722,6 +723,26 @@ begin:
|
|||
}
|
||||
NEXTOP;
|
||||
|
||||
OP(BOUND_K):
|
||||
ASSERTKD(BC);
|
||||
if (reg.d[a] >= konstd[BC])
|
||||
{
|
||||
assert(false);
|
||||
Printf("Array access out of bounds: Max. index = %u, current index = %u\n", konstd[BC], reg.d[a]);
|
||||
THROW(X_ARRAY_OUT_OF_BOUNDS);
|
||||
}
|
||||
NEXTOP;
|
||||
|
||||
OP(BOUND_R):
|
||||
ASSERTD(B);
|
||||
if (reg.d[a] >= reg.d[B])
|
||||
{
|
||||
assert(false);
|
||||
Printf("Array access out of bounds: Max. index = %u, current index = %u\n", reg.d[B], reg.d[a]);
|
||||
THROW(X_ARRAY_OUT_OF_BOUNDS);
|
||||
}
|
||||
NEXTOP;
|
||||
|
||||
OP(CONCAT):
|
||||
ASSERTS(a); ASSERTS(B); ASSERTS(C);
|
||||
reg.s[a] = reg.s[B] + reg.s[C];
|
||||
|
|
|
|||
|
|
@ -110,6 +110,8 @@ xx(CATCH, catch, CATCH, NOP, 0, 0), // A == 0: continue search on next try
|
|||
// A == 3: (pkB == <type of exception thrown>) then pc++ ; next instruction must JMP to another CATCH
|
||||
// for A > 0, exception is stored in pC
|
||||
xx(BOUND, bound, RII16, NOP, 0, 0), // if rA >= BC, throw exception
|
||||
xx(BOUND_K, bound, LKI, NOP, 0, 0), // if rA >= const[BC], throw exception
|
||||
xx(BOUND_R, bound, RIRI, NOP, 0, 0), // if rA >= rB, throw exception
|
||||
|
||||
// String instructions.
|
||||
xx(CONCAT, concat, RSRSRS, NOP, 0, 0), // sA = sB..sC
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue