mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +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)
|
void BfExprEvaluator::Visit(BfVariableDeclaration* varDecl)
|
||||||
{
|
{
|
||||||
mModule->UpdateExprSrcPos(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);
|
CheckVariableDeclaration(varDecl, true, false, false);
|
||||||
if (varDecl->mInitializer == NULL)
|
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
|
// Temporarily disable so we don't capture calls in params
|
||||||
SetAndRestoreValue<BfFunctionBindResult*> prevBindResult(mFunctionBindResult, NULL);
|
SetAndRestoreValue<BfFunctionBindResult*> prevBindResult(mFunctionBindResult, NULL);
|
||||||
|
SetAndRestoreValue<bool> prevAllowVariableDeclarations(mModule->mCurMethodState->mCurScope->mAllowVariableDeclarations, false); // Don't allow variable declarations in arguments
|
||||||
|
|
||||||
BfMethodInstance* methodInstance = moduleMethodInstance.mMethodInstance;
|
BfMethodInstance* methodInstance = moduleMethodInstance.mMethodInstance;
|
||||||
|
|
||||||
|
@ -5827,7 +5838,7 @@ BfTypedValue BfExprEvaluator::ResolveArgValue(BfResolvedArg& resolvedArg, BfType
|
||||||
{
|
{
|
||||||
BfExprEvaluator exprEvaluator(mModule);
|
BfExprEvaluator exprEvaluator(mModule);
|
||||||
exprEvaluator.mReceivingValue = receivingValue;
|
exprEvaluator.mReceivingValue = receivingValue;
|
||||||
BfEvalExprFlags flags = BfEvalExprFlags_NoCast;
|
BfEvalExprFlags flags = (BfEvalExprFlags)(BfEvalExprFlags_NoCast);
|
||||||
if ((paramKind == BfParamKind_Params) || (paramKind == BfParamKind_DelegateParam))
|
if ((paramKind == BfParamKind_Params) || (paramKind == BfParamKind_DelegateParam))
|
||||||
flags = (BfEvalExprFlags)(flags | BfEvalExprFlags_AllowParamsExpr);
|
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
|
// Temporarily disable so we don't capture calls in params
|
||||||
SetAndRestoreValue<BfFunctionBindResult*> prevBindResult(mFunctionBindResult, NULL);
|
SetAndRestoreValue<BfFunctionBindResult*> prevBindResult(mFunctionBindResult, NULL);
|
||||||
|
SetAndRestoreValue<bool> prevAllowVariableDeclarations(mModule->mCurMethodState->mCurScope->mAllowVariableDeclarations, false); // Don't allow variable declarations in arguments
|
||||||
|
|
||||||
sInvocationIdx++;
|
sInvocationIdx++;
|
||||||
|
|
||||||
|
|
|
@ -12412,7 +12412,7 @@ void BfModule::DoAddLocalVariable(BfLocalVariable* localVar)
|
||||||
}
|
}
|
||||||
|
|
||||||
BfLocalVariable* BfModule::AddLocalVariableDef(BfLocalVariable* localVarDef, bool addDebugInfo, bool doAliasValue, BfIRValue declareBefore, BfIRInitType initType)
|
BfLocalVariable* BfModule::AddLocalVariableDef(BfLocalVariable* localVarDef, bool addDebugInfo, bool doAliasValue, BfIRValue declareBefore, BfIRInitType initType)
|
||||||
{
|
{
|
||||||
if ((localVarDef->mValue) && (!localVarDef->mAddr) && (IsTargetingBeefBackend()))
|
if ((localVarDef->mValue) && (!localVarDef->mAddr) && (IsTargetingBeefBackend()))
|
||||||
{
|
{
|
||||||
if ((!localVarDef->mValue.IsConst()) && (!localVarDef->mValue.IsArg()) && (!localVarDef->mValue.IsFake()))
|
if ((!localVarDef->mValue.IsConst()) && (!localVarDef->mValue.IsArg()) && (!localVarDef->mValue.IsFake()))
|
||||||
|
|
|
@ -66,7 +66,7 @@ enum BfEvalExprFlags
|
||||||
BfEvalExprFlags_FieldInitializer = 0x2000,
|
BfEvalExprFlags_FieldInitializer = 0x2000,
|
||||||
BfEvalExprFlags_VariableDeclaration = 0x4000,
|
BfEvalExprFlags_VariableDeclaration = 0x4000,
|
||||||
BfEvalExprFlags_NoAutoComplete = 0x8000,
|
BfEvalExprFlags_NoAutoComplete = 0x8000,
|
||||||
BfEvalExprFlags_AllowNonConst = 0x10000
|
BfEvalExprFlags_AllowNonConst = 0x10000
|
||||||
};
|
};
|
||||||
|
|
||||||
enum BfCastFlags
|
enum BfCastFlags
|
||||||
|
@ -314,6 +314,7 @@ public:
|
||||||
bool mAllowTargeting;
|
bool mAllowTargeting;
|
||||||
bool mHadScopeValueRetain;
|
bool mHadScopeValueRetain;
|
||||||
bool mIsDeferredBlock;
|
bool mIsDeferredBlock;
|
||||||
|
bool mAllowVariableDeclarations;
|
||||||
BfBlock* mAstBlock;
|
BfBlock* mAstBlock;
|
||||||
BfAstNode* mCloseNode;
|
BfAstNode* mCloseNode;
|
||||||
BfExprEvaluator* mExprEvaluator;
|
BfExprEvaluator* mExprEvaluator;
|
||||||
|
@ -346,6 +347,7 @@ public:
|
||||||
mHadScopeValueRetain = false;
|
mHadScopeValueRetain = false;
|
||||||
mIsDeferredBlock = false;
|
mIsDeferredBlock = false;
|
||||||
mAllowTargeting = true;
|
mAllowTargeting = true;
|
||||||
|
mAllowVariableDeclarations = true;
|
||||||
mMixinDepth = 0;
|
mMixinDepth = 0;
|
||||||
mScopeDepth = 0;
|
mScopeDepth = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1591,7 +1591,7 @@ BfLocalVariable* BfModule::HandleVariableDeclaration(BfVariableDeclaration* varD
|
||||||
|
|
||||||
bool wantsStore = false;
|
bool wantsStore = false;
|
||||||
if ((initValue) && (!handledVarStore) && (!isConst) && (!initHandled))
|
if ((initValue) && (!handledVarStore) && (!isConst) && (!initHandled))
|
||||||
{
|
{
|
||||||
initValue = LoadValue(initValue);
|
initValue = LoadValue(initValue);
|
||||||
if (initValue.IsSplat())
|
if (initValue.IsSplat())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue