mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 20:42:21 +02:00
Fixed some places where variable declarations should be illegal
This commit is contained in:
parent
26604017f8
commit
b128180a15
4 changed files with 18 additions and 4 deletions
|
@ -2456,6 +2456,16 @@ bool BfExprEvaluator::HasVariableDeclaration(BfAstNode* checkNode)
|
|||
void BfExprEvaluator::Visit(BfVariableDeclaration* varDecl)
|
||||
{
|
||||
mModule->UpdateExprSrcPos(varDecl);
|
||||
|
||||
if ((mModule->mCurMethodState == NULL) || (!mModule->mCurMethodState->mCurScope->mAllowVariableDeclarations))
|
||||
{
|
||||
mModule->Fail("Variable declarations are not allowed in this context", varDecl);
|
||||
if (varDecl->mInitializer != NULL)
|
||||
{
|
||||
VisitChild(varDecl->mInitializer);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
CheckVariableDeclaration(varDecl, true, false, false);
|
||||
if (varDecl->mInitializer == NULL)
|
||||
|
@ -5017,6 +5027,7 @@ BfTypedValue BfExprEvaluator::CreateCall(BfAstNode* targetSrc, const BfTypedValu
|
|||
|
||||
// Temporarily disable so we don't capture calls in params
|
||||
SetAndRestoreValue<BfFunctionBindResult*> prevBindResult(mFunctionBindResult, NULL);
|
||||
SetAndRestoreValue<bool> prevAllowVariableDeclarations(mModule->mCurMethodState->mCurScope->mAllowVariableDeclarations, false); // Don't allow variable declarations in arguments
|
||||
|
||||
BfMethodInstance* methodInstance = moduleMethodInstance.mMethodInstance;
|
||||
|
||||
|
@ -5827,7 +5838,7 @@ BfTypedValue BfExprEvaluator::ResolveArgValue(BfResolvedArg& resolvedArg, BfType
|
|||
{
|
||||
BfExprEvaluator exprEvaluator(mModule);
|
||||
exprEvaluator.mReceivingValue = receivingValue;
|
||||
BfEvalExprFlags flags = BfEvalExprFlags_NoCast;
|
||||
BfEvalExprFlags flags = (BfEvalExprFlags)(BfEvalExprFlags_NoCast);
|
||||
if ((paramKind == BfParamKind_Params) || (paramKind == BfParamKind_DelegateParam))
|
||||
flags = (BfEvalExprFlags)(flags | BfEvalExprFlags_AllowParamsExpr);
|
||||
|
||||
|
@ -6154,6 +6165,7 @@ BfTypedValue BfExprEvaluator::MatchMethod(BfAstNode* targetSrc, BfMethodBoundExp
|
|||
|
||||
// Temporarily disable so we don't capture calls in params
|
||||
SetAndRestoreValue<BfFunctionBindResult*> prevBindResult(mFunctionBindResult, NULL);
|
||||
SetAndRestoreValue<bool> prevAllowVariableDeclarations(mModule->mCurMethodState->mCurScope->mAllowVariableDeclarations, false); // Don't allow variable declarations in arguments
|
||||
|
||||
sInvocationIdx++;
|
||||
|
||||
|
|
|
@ -12412,7 +12412,7 @@ void BfModule::DoAddLocalVariable(BfLocalVariable* localVar)
|
|||
}
|
||||
|
||||
BfLocalVariable* BfModule::AddLocalVariableDef(BfLocalVariable* localVarDef, bool addDebugInfo, bool doAliasValue, BfIRValue declareBefore, BfIRInitType initType)
|
||||
{
|
||||
{
|
||||
if ((localVarDef->mValue) && (!localVarDef->mAddr) && (IsTargetingBeefBackend()))
|
||||
{
|
||||
if ((!localVarDef->mValue.IsConst()) && (!localVarDef->mValue.IsArg()) && (!localVarDef->mValue.IsFake()))
|
||||
|
|
|
@ -66,7 +66,7 @@ enum BfEvalExprFlags
|
|||
BfEvalExprFlags_FieldInitializer = 0x2000,
|
||||
BfEvalExprFlags_VariableDeclaration = 0x4000,
|
||||
BfEvalExprFlags_NoAutoComplete = 0x8000,
|
||||
BfEvalExprFlags_AllowNonConst = 0x10000
|
||||
BfEvalExprFlags_AllowNonConst = 0x10000
|
||||
};
|
||||
|
||||
enum BfCastFlags
|
||||
|
@ -314,6 +314,7 @@ public:
|
|||
bool mAllowTargeting;
|
||||
bool mHadScopeValueRetain;
|
||||
bool mIsDeferredBlock;
|
||||
bool mAllowVariableDeclarations;
|
||||
BfBlock* mAstBlock;
|
||||
BfAstNode* mCloseNode;
|
||||
BfExprEvaluator* mExprEvaluator;
|
||||
|
@ -346,6 +347,7 @@ public:
|
|||
mHadScopeValueRetain = false;
|
||||
mIsDeferredBlock = false;
|
||||
mAllowTargeting = true;
|
||||
mAllowVariableDeclarations = true;
|
||||
mMixinDepth = 0;
|
||||
mScopeDepth = 0;
|
||||
}
|
||||
|
|
|
@ -1591,7 +1591,7 @@ BfLocalVariable* BfModule::HandleVariableDeclaration(BfVariableDeclaration* varD
|
|||
|
||||
bool wantsStore = false;
|
||||
if ((initValue) && (!handledVarStore) && (!isConst) && (!initHandled))
|
||||
{
|
||||
{
|
||||
initValue = LoadValue(initValue);
|
||||
if (initValue.IsSplat())
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue