public override void EnterWithStmt(VBAParser.WithStmtContext context)
        {
            var implicitCall = context.implicitCallStmt_InStmt();

            var call = Resolve(implicitCall.iCS_S_ProcedureOrArrayCall())
                       ?? Resolve(implicitCall.iCS_S_VariableOrProcedureCall())
                       ?? Resolve(implicitCall.iCS_S_DictionaryCall())
                       ?? Resolve(implicitCall.iCS_S_MembersCall());

            _withQualifiers.Push(GetReturnType(call));
        }
Example #2
0
        public void EnterWithBlock(VBAParser.WithStmtContext context)
        {
            var boundExpression = _bindingService.ResolveDefault(
                _moduleDeclaration,
                _currentParent,
                context.expression(),
                GetInnerMostWithExpression(),
                StatementResolutionContext.Undefined);

            _boundExpressionVisitor.AddIdentifierReferences(boundExpression, _qualifiedModuleName, _currentScope, _currentParent);
            // note: pushes null if unresolved
            _withBlockExpressions.Push(boundExpression);
        }
Example #3
0
        public void EnterWithBlock(VBAParser.WithStmtContext context)
        {
            var withExpression  = GetInnerMostWithExpression();
            var boundExpression = _bindingService.ResolveDefault(
                _moduleDeclaration,
                _currentParent,
                context.expression(),
                withExpression,
                StatementResolutionContext.Undefined,
                false);

            _failedResolutionVisitor.CollectUnresolved(boundExpression, _currentParent, withExpression);
            _boundExpressionVisitor.AddIdentifierReferences(boundExpression, _qualifiedModuleName, _currentScope, _currentParent);
            _withBlockExpressions.Push(boundExpression);
        }
        public void EnterWithBlock(VBAParser.WithStmtContext context)
        {
            Declaration         qualifier = null;
            IdentifierReference reference = null;

            if (context.NEW() == null)
            {
                // with block is using an identifier declared elsewhere.
                var callee = ResolveInternal(context.implicitCallStmt_InStmt(), _currentScope, ContextAccessorType.GetValueOrReference);
                qualifier = ResolveType(callee);
            }
            else
            {
                // with block is using an anonymous declaration.
                // i.e. object variable reference is held by the with block itself.
                var typeContext     = context.type();
                var baseTypeContext = typeContext.baseType();
                if (baseTypeContext != null)
                {
                    var collectionContext = baseTypeContext.COLLECTION();
                    if (collectionContext != null)
                    {
                        // object variable is a built-in Collection class instance
                        qualifier = _declarations.Items.Single(item => item.IsBuiltIn &&
                                                               item.IdentifierName == collectionContext.GetText() &&
                                                               item.DeclarationType == DeclarationType.Class);
                        reference = CreateReference(baseTypeContext, qualifier);
                    }
                }
                else
                {
                    qualifier = ResolveType(typeContext.complexType());
                }
            }

            if (qualifier != null && reference != null)
            {
                qualifier.AddReference(reference);
                _alreadyResolved.Add(reference.Context);
            }
            _withBlockQualifiers.Push(qualifier); // note: pushes null if unresolved
        }
 public override void ExitWithStmt(VBAParser.WithStmtContext context)
 {
     _resolver.ExitWithBlock();
 }
 public override void EnterWithStmt(VBAParser.WithStmtContext context)
 {
     _resolver.EnterWithBlock(context);
 }
Example #7
0
 public override void EnterWithStmt(VBAParser.WithStmtContext context)
 {
     CheckContext(context, context.END_WITH());
     base.EnterWithStmt(context);
 }
 public override void ExitWithStmt(VBAParser.WithStmtContext context)
 {
     _withQualifiers.Pop();
 }