示例#1
0
 public void Resolve(VBAParser.RedimStmtContext context)
 {
     // TODO: Create local variable if no match for redim variable declaration.
     foreach (var redimVariableDeclaration in context.redimDeclarationList().redimVariableDeclaration())
     {
         // We treat redim statements as index expressions to make it SLL.
         var lExpr     = ((VBAParser.LExprContext)redimVariableDeclaration.expression()).lExpression();
         var indexExpr = (VBAParser.IndexExprContext)lExpr;
         // The lexpression is the array that is being resized.
         // We can't treat it as a normal index expression because the semantics are different.
         // It's not actually a function call but a special statement.
         ResolveDefault(indexExpr.lExpression());
         var positionalOrNamedArgumentList = indexExpr.argumentList().positionalOrNamedArgumentList();
         // There is always at least one argument
         ResolveRedimArgument(positionalOrNamedArgumentList.requiredPositionalArgument().argumentExpression());
         if (positionalOrNamedArgumentList.positionalArgumentOrMissing() != null)
         {
             foreach (var positionalArgumentOrMissing in positionalOrNamedArgumentList.positionalArgumentOrMissing())
             {
                 if (positionalArgumentOrMissing is VBAParser.SpecifiedPositionalArgumentContext)
                 {
                     ResolveRedimArgument(((VBAParser.SpecifiedPositionalArgumentContext)positionalArgumentOrMissing).positionalArgument().argumentExpression());
                 }
             }
         }
     }
 }
示例#2
0
        public void Resolve(VBAParser.RedimStmtContext context)
        {
            // TODO: Create local variable if no match for ReDim variable declaration.
            foreach (var redimVariableDeclaration in context.redimDeclarationList().redimVariableDeclaration())
            {
                // We treat ReDim statements as index expressions to make it SLL.
                var lExpr = ((VBAParser.LExprContext)redimVariableDeclaration.expression()).lExpression();

                VBAParser.LExpressionContext  indexedExpression;
                VBAParser.ArgumentListContext argumentList;
                if (lExpr is VBAParser.IndexExprContext indexExpr)
                {
                    indexedExpression = indexExpr.lExpression();
                    argumentList      = indexExpr.argumentList();
                }
                else
                {
                    var whitespaceIndexExpr = (VBAParser.WhitespaceIndexExprContext)lExpr;
                    indexedExpression = whitespaceIndexExpr.lExpression();
                    argumentList      = whitespaceIndexExpr.argumentList();
                }
                // The indexedExpression is the array that is being resized.
                // We can't treat it as a normal index expression because the semantics are different.
                // It's not actually a function call but a special statement.
                ResolveDefault(indexedExpression, false);
                if (argumentList.argument() != null)
                {
                    foreach (var positionalArgument in argumentList.argument())
                    {
                        if (positionalArgument.positionalArgument() != null)
                        {
                            ResolveReDimArgument(positionalArgument.positionalArgument().argumentExpression());
                        }
                    }
                }
            }
        }
 public override void EnterRedimStmt(VBAParser.RedimStmtContext context)
 {
     _resolver.Resolve(context);
 }