- scriptified the remaining Doom weapon code.
- implemented method calls from struct instances. - optimized disassembly of VM call instructions to print the function's name at the end where it is more visible and does not need to be truncated. Also use the printable name for script functions here.
This commit is contained in:
parent
ab6b2f369e
commit
bb25c5faaa
11 changed files with 351 additions and 368 deletions
|
|
@ -6878,6 +6878,22 @@ FxExpression *FxMemberFunctionCall::Resolve(FCompileContext& ctx)
|
|||
return nullptr;
|
||||
}
|
||||
}
|
||||
else if (Self->ValueType->IsKindOf(RUNTIME_CLASS(PStruct)))
|
||||
{
|
||||
bool writable;
|
||||
if (Self->RequestAddress(ctx, &writable) && writable)
|
||||
{
|
||||
cls = static_cast<PStruct*>(Self->ValueType);
|
||||
Self->ValueType = NewPointer(Self->ValueType);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Cannot be made writable so we cannot use its methods.
|
||||
ScriptPosition.Message(MSG_ERROR, "Invalid expression on left hand side of %s\n", MethodName.GetChars());
|
||||
delete this;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ScriptPosition.Message(MSG_ERROR, "Invalid expression on left hand side of %s\n", MethodName.GetChars());
|
||||
|
|
@ -7250,18 +7266,22 @@ FxExpression *FxVMFunctionCall::Resolve(FCompileContext& ctx)
|
|||
{
|
||||
bool writable;
|
||||
ArgList[i] = ArgList[i]->Resolve(ctx); // nust be resolved before the address is requested.
|
||||
ArgList[i]->RequestAddress(ctx, &writable);
|
||||
ArgList[i]->ValueType = NewPointer(ArgList[i]->ValueType);
|
||||
// For a reference argument the types must match 100%.
|
||||
if (type != ArgList[i]->ValueType)
|
||||
if (ArgList[i]->ValueType != TypeNullPtr)
|
||||
{
|
||||
ScriptPosition.Message(MSG_ERROR, "Type mismatch in reference argument", Function->SymbolName.GetChars());
|
||||
x = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
x = ArgList[i];
|
||||
ArgList[i]->RequestAddress(ctx, &writable);
|
||||
ArgList[i]->ValueType = NewPointer(ArgList[i]->ValueType);
|
||||
// For a reference argument the types must match 100%.
|
||||
if (type != ArgList[i]->ValueType)
|
||||
{
|
||||
ScriptPosition.Message(MSG_ERROR, "Type mismatch in reference argument", Function->SymbolName.GetChars());
|
||||
x = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
x = ArgList[i];
|
||||
}
|
||||
}
|
||||
else x = ArgList[i];
|
||||
}
|
||||
failed |= (x == nullptr);
|
||||
ArgList[i] = x;
|
||||
|
|
@ -7305,13 +7325,6 @@ FxExpression *FxVMFunctionCall::Resolve(FCompileContext& ctx)
|
|||
{
|
||||
ValueType = TypeVoid;
|
||||
}
|
||||
// If self is a struct, it will be a value type, not a reference, so we need to make an addresss request.
|
||||
if (Self != nullptr && Self->ValueType->IsKindOf(RUNTIME_CLASS(PStruct)) && !Self->ValueType->IsKindOf(RUNTIME_CLASS(PClass)))
|
||||
{
|
||||
bool writable;
|
||||
Self->RequestAddress(ctx, &writable);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -8852,6 +8865,13 @@ FxExpression *FxClassPtrCast::Resolve(FCompileContext &ctx)
|
|||
return this;
|
||||
}
|
||||
}
|
||||
else if (basex->ValueType == TypeString || basex->ValueType == TypeName)
|
||||
{
|
||||
FxExpression *x = new FxClassTypeCast(to, basex);
|
||||
basex = nullptr;
|
||||
delete this;
|
||||
return x->Resolve(ctx);
|
||||
}
|
||||
// Everything else is an error.
|
||||
ScriptPosition.Message(MSG_ERROR, "Cannot cast %s to %s. The types are incompatible.", basex->ValueType->DescriptiveName(), to->DescriptiveName());
|
||||
delete this;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue