- fixed a conversion warning with the pointer-type AActor fields.

- added master and tracer to the list of exported variables.
- fixed: 'none' as class type must map to the real null pointer so that it won't get rejected by the stricter type checks.
- added handling for member function calls to zcc_compile.cpp.
- fixed: FxMemberFunctionCall may not delete the self expression if it gets passed on to the actual function call.
This commit is contained in:
Christoph Oelckers 2016-10-22 19:43:53 +02:00
parent 37914223f0
commit c2b37aeeea
5 changed files with 17 additions and 3 deletions

View file

@ -574,7 +574,7 @@ class PField : public PSymbol
public:
PField(FName name, PType *type) : PSymbol(name), Offset(0), Type(type), Flags(0) {}
PField(FName name, PType *type, DWORD flags) : PSymbol(name), Offset(0), Type(type), Flags(flags) {}
PField(FName name, PType *type, DWORD flags, unsigned offset) : PSymbol(name), Offset(offset), Type(type), Flags(flags) {}
PField(FName name, PType *type, DWORD flags, size_t offset) : PSymbol(name), Offset(unsigned(offset)), Type(type), Flags(flags) {}
unsigned int Offset;
PType *Type;

View file

@ -437,6 +437,8 @@ xx(ScaleX)
xx(ScaleY)
xx(Floatbobphase)
xx(Target)
xx(Master)
xx(Tracer)
xx(Blocking)
xx(Blockmonsters)

View file

@ -4975,6 +4975,7 @@ FxExpression *FxMemberFunctionCall::Resolve(FCompileContext& ctx)
auto self = !(afd->Variants[0].Flags & VARF_Static) ? Self : nullptr;
auto x = new FxVMFunctionCall(self, afd, ArgList, ScriptPosition, staticonly);
ArgList = nullptr;
if (Self == self) Self = nullptr;
delete this;
return x->Resolve(ctx);
}
@ -6226,6 +6227,7 @@ FxExpression *FxClassTypeCast::Resolve(FCompileContext &ctx)
{
FName clsname = static_cast<FxConstant *>(basex)->GetValue().GetName();
PClass *cls = NULL;
FxExpression *x;
if (clsname != NAME_None)
{
@ -6248,8 +6250,12 @@ FxExpression *FxClassTypeCast::Resolve(FCompileContext &ctx)
}
ScriptPosition.Message(MSG_DEBUG, "resolving '%s' as class name", clsname.GetChars());
}
x = new FxConstant(cls, ScriptPosition);
}
else
{
x = new FxConstant(ScriptPosition); // create a genuine null pointer to get past the type checks.
}
FxExpression *x = new FxConstant(cls, ScriptPosition);
delete this;
return x;
}

View file

@ -677,4 +677,6 @@ void InitThingdef()
symt.AddSymbol(new PField(NAME_VisibleEndAngle, TypeFloat64, VARF_Native, myoffsetof(AActor, VisibleEndAngle)));
symt.AddSymbol(new PField(NAME_VisibleEndPitch, TypeFloat64, VARF_Native, myoffsetof(AActor, VisibleEndPitch)));
symt.AddSymbol(new PField(NAME_Target, TypeActor, VARF_Native, myoffsetof(AActor, target)));
symt.AddSymbol(new PField(NAME_Master, TypeActor, VARF_Native, myoffsetof(AActor, master)));
symt.AddSymbol(new PField(NAME_Tracer, TypeActor, VARF_Native, myoffsetof(AActor, tracer)));
}

View file

@ -2381,7 +2381,11 @@ FxExpression *ZCCCompiler::ConvertNode(ZCC_TreeNode *ast)
return new FxFunctionCall(static_cast<ZCC_ExprID *>(fcall->Function)->Identifier, NAME_None, ConvertNodeList(fcall->Parameters), *ast);
case AST_ExprMemberAccess:
break;
{
auto ema = static_cast<ZCC_ExprMemberAccess *>(fcall->Function);
Printf("Member call to %s\n", FName(ema->Right).GetChars());
return new FxMemberFunctionCall(ConvertNode(ema->Left), ema->Right, ConvertNodeList(fcall->Parameters), *ast);
}
case AST_ExprBinary:
// Array syntax for randoms. They are internally stored as ExprBinary with both an identifier on the left and right side.