make const actually work, and add unsafe(const) for old behavior
This commit is contained in:
parent
236c9b4224
commit
7e86116ab1
9 changed files with 25 additions and 16 deletions
|
|
@ -6701,7 +6701,7 @@ FxExpression *FxIdentifier::Resolve(FCompileContext& ctx)
|
|||
}
|
||||
FxExpression *self = new FxSelf(ScriptPosition);
|
||||
self = self->Resolve(ctx);
|
||||
newex = ResolveMember(ctx, ctx.Function->Variants[0].SelfClass, self, ctx.Function->Variants[0].SelfClass);
|
||||
newex = ResolveMember(ctx, ctx.Function->Variants[0].SelfClass, self, ctx.Function->Variants[0].SelfClass, ctx.Function->Variants[0].Flags & VARF_SafeConst);
|
||||
ABORT(newex);
|
||||
goto foundit;
|
||||
}
|
||||
|
|
@ -6863,7 +6863,7 @@ foundit:
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FxExpression *FxIdentifier::ResolveMember(FCompileContext &ctx, PContainerType *classctx, FxExpression *&object, PContainerType *objtype)
|
||||
FxExpression *FxIdentifier::ResolveMember(FCompileContext &ctx, PContainerType *classctx, FxExpression *&object, PContainerType *objtype, bool isConst)
|
||||
{
|
||||
PSymbol *sym;
|
||||
PSymbolTable *symtbl;
|
||||
|
|
@ -6956,7 +6956,7 @@ FxExpression *FxIdentifier::ResolveMember(FCompileContext &ctx, PContainerType *
|
|||
}
|
||||
}
|
||||
|
||||
auto x = isclass ? new FxClassMember(object, vsym, ScriptPosition) : new FxStructMember(object, vsym, ScriptPosition);
|
||||
auto x = isclass ? new FxClassMember(object, vsym, ScriptPosition, isConst) : new FxStructMember(object, vsym, ScriptPosition, isConst);
|
||||
object = nullptr;
|
||||
return x->Resolve(ctx);
|
||||
}
|
||||
|
|
@ -7611,8 +7611,8 @@ FxMemberBase::FxMemberBase(EFxType type, PField *f, const FScriptPosition &p)
|
|||
}
|
||||
|
||||
|
||||
FxStructMember::FxStructMember(FxExpression *x, PField* mem, const FScriptPosition &pos)
|
||||
: FxMemberBase(EFX_StructMember, mem, pos)
|
||||
FxStructMember::FxStructMember(FxExpression *x, PField* mem, const FScriptPosition &pos, bool isConst)
|
||||
: FxMemberBase(EFX_StructMember, mem, pos), IsConst(isConst)
|
||||
{
|
||||
classx = x;
|
||||
}
|
||||
|
|
@ -7662,7 +7662,7 @@ bool FxStructMember::RequestAddress(FCompileContext &ctx, bool *writable)
|
|||
bWritable = false;
|
||||
}
|
||||
|
||||
*writable = bWritable;
|
||||
*writable = bWritable && !IsConst;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -7873,8 +7873,8 @@ ExpEmit FxStructMember::Emit(VMFunctionBuilder *build)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FxClassMember::FxClassMember(FxExpression *x, PField* mem, const FScriptPosition &pos)
|
||||
: FxStructMember(x, mem, pos)
|
||||
FxClassMember::FxClassMember(FxExpression *x, PField* mem, const FScriptPosition &pos, bool isConst)
|
||||
: FxStructMember(x, mem, pos, isConst)
|
||||
{
|
||||
ExprType = EFX_ClassMember;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -396,7 +396,7 @@ public:
|
|||
|
||||
FxIdentifier(FName i, const FScriptPosition &p);
|
||||
FxExpression *Resolve(FCompileContext&);
|
||||
FxExpression *ResolveMember(FCompileContext&, PContainerType*, FxExpression*&, PContainerType*);
|
||||
FxExpression *ResolveMember(FCompileContext&, PContainerType*, FxExpression*&, PContainerType*, bool isConst = false);
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -1475,8 +1475,9 @@ class FxStructMember : public FxMemberBase
|
|||
{
|
||||
public:
|
||||
FxExpression *classx;
|
||||
bool IsConst;
|
||||
|
||||
FxStructMember(FxExpression*, PField*, const FScriptPosition&);
|
||||
FxStructMember(FxExpression*, PField*, const FScriptPosition&, bool isConst = false);
|
||||
~FxStructMember();
|
||||
FxExpression *Resolve(FCompileContext&);
|
||||
bool RequestAddress(FCompileContext &ctx, bool *writable);
|
||||
|
|
@ -1494,7 +1495,7 @@ class FxClassMember : public FxStructMember
|
|||
{
|
||||
public:
|
||||
|
||||
FxClassMember(FxExpression*, PField*, const FScriptPosition&);
|
||||
FxClassMember(FxExpression*, PField*, const FScriptPosition&, bool isConst = false);
|
||||
};
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue