public UnaryOpDefaultBinding(
     ParserRuleContext context,
     IExpressionBinding expr)
 {
     _context = context;
     _expr    = expr;
 }
 public ParenthesizedDefaultBinding(
     ParserRuleContext context,
     IExpressionBinding expressionBinding)
 {
     _context           = context;
     _expressionBinding = expressionBinding;
 }
Ejemplo n.º 3
0
 public NewTypeBinding(
     ParserRuleContext expression,
     IExpressionBinding typeExpressionBinding)
 {
     _expression            = expression;
     _typeExpressionBinding = typeExpressionBinding;
 }
Ejemplo n.º 4
0
 public ArgumentListArgument(
     IExpressionBinding binding,
     ParserRuleContext context,
     VBAParser.ArgumentListContext argumentListContext,
     ArgumentListArgumentType argumentType,
     bool isAddressOfArgument = false)
     : this(binding, context, argumentListContext, argumentType, calledProcedure => null, isAddressOfArgument)
 {
 }
Ejemplo n.º 5
0
 public TypeOfIsDefaultBinding(
     ParserRuleContext context,
     IExpressionBinding expressionBinding,
     IExpressionBinding typeExpressionBinding)
 {
     _context               = context;
     _expressionBinding     = expressionBinding;
     _typeExpressionBinding = typeExpressionBinding;
 }
 public ObjectPrintDefaultBinding(
     ParserRuleContext context,
     IExpressionBinding printMethodBinding,
     IExpressionBinding outputListBinding)
 {
     _context            = context;
     _printMethodBinding = printMethodBinding;
     _outputListBinding  = outputListBinding;
 }
 public BinaryOpDefaultBinding(
     ParserRuleContext context,
     IExpressionBinding left,
     IExpressionBinding right)
 {
     _context = context;
     _left    = left;
     _right   = right;
 }
Ejemplo n.º 8
0
        private void SetPreferProjectOverUdt(IExpressionBinding lExpression)
        {
            if (!(lExpression is MemberAccessTypeBinding))
            {
                return;
            }
            var simpleNameBinding = (SimpleNameTypeBinding)((MemberAccessTypeBinding)lExpression).LExpressionBinding;

            simpleNameBinding.PreferProjectOverUdt = true;
        }
Ejemplo n.º 9
0
        public IBoundExpression Resolve(Declaration module, Declaration parent, ParserRuleContext expression, IBoundExpression withBlockVariable, StatementResolutionContext statementContext)
        {
            IExpressionBinding bindingTree = BuildTree(module, parent, expression, withBlockVariable, statementContext);

            if (bindingTree != null)
            {
                return(bindingTree.Resolve());
            }
            return(null);
        }
        public IBoundExpression Resolve(Declaration module, Declaration parent, IParseTree expression, IBoundExpression withBlockVariable, StatementResolutionContext statementContext, bool requiresLetCoercion = false, bool isLetAssignment = false)
        {
            IExpressionBinding bindingTree = BuildTree(module, parent, expression, withBlockVariable, statementContext);

            if (bindingTree != null)
            {
                return(bindingTree.Resolve());
            }
            return(null);
        }
Ejemplo n.º 11
0
        public IBoundExpression Resolve(Declaration module, Declaration parent, ParserRuleContext expression)
        {
            dynamic            dynamicExpression = expression;
            IExpressionBinding bindingTree       = Visit(module, parent, dynamicExpression);

            if (bindingTree != null)
            {
                return(bindingTree.Resolve());
            }
            return(null);
        }
Ejemplo n.º 12
0
        //This is a wrapper used to model Let coercion for object types.

        public LetCoercionDefaultBinding(
            ParserRuleContext expression,
            IExpressionBinding wrappedExpressionBinding,
            bool isAssignment = false)
            : this(
                expression,
                (IBoundExpression)null,
                isAssignment)
        {
            _wrappedExpressionBinding = wrappedExpressionBinding;
        }
        //This is based on the spec at https://docs.microsoft.com/en-us/openspecs/microsoft_general_purpose_programming_languages/MS-VBAL/f20c9ebc-3365-4614-9788-1cd50a504574

        public DictionaryAccessDefaultBinding(
            ParserRuleContext expression,
            IExpressionBinding lExpressionBinding,
            ArgumentList argumentList)
            : this(
                expression,
                (IBoundExpression)null,
                argumentList)
        {
            _lExpressionBinding = lExpressionBinding;
        }
Ejemplo n.º 14
0
        //This is a wrapper used to model procedure coercion in call statements without arguments.
        //The one with arguments is basically an index expression and uses its binding.

        public ProcedureCoercionDefaultBinding(
            ParserRuleContext expression,
            IExpressionBinding wrappedExpressionBinding,
            bool hasExplicitCall,
            Declaration parent)
            : this(
                expression,
                (IBoundExpression)null,
                hasExplicitCall,
                parent)
        {
            _wrappedExpressionBinding = wrappedExpressionBinding;
        }
Ejemplo n.º 15
0
 private void SetLeftMatch(IExpressionBinding binding, int argumentCount)
 {
     // See SimpleNameDefaultBinding for a description on why we're doing this.
     if (!(binding is SimpleNameDefaultBinding))
     {
         return;
     }
     if (argumentCount != 2)
     {
         return;
     }
     ((SimpleNameDefaultBinding)binding).IsPotentialLeftMatch = true;
 }
Ejemplo n.º 16
0
        //This is based on the spec at https://docs.microsoft.com/en-us/openspecs/microsoft_general_purpose_programming_languages/MS-VBAL/551030b2-72a4-4c95-9cb0-fb8f8c8774b4

        //We pass _lExpression to the expressions we create instead of passing it along the call chain because this simplifies the handling
        //when resolving recursive default member calls. For these we use a fake bound simple name expression, which leads to the right resolution.
        //However, using this on the returned expressions would lead to no identifier references being generated for the original lExpression.

        public IndexDefaultBinding(
            ParserRuleContext expression,
            IExpressionBinding lExpressionBinding,
            ArgumentList argumentList,
            Declaration parent)
            : this(
                expression,
                (IBoundExpression)null,
                argumentList,
                parent)
        {
            _lExpressionBinding = lExpressionBinding;
        }
 public MemberAccessTypeBinding(
     DeclarationFinder declarationFinder,
     Declaration module,
     Declaration parent,
     VBAExpressionParser.MemberAccessExprContext expression,
     IExpressionBinding lExpressionBinding)
 {
     _declarationFinder  = declarationFinder;
     _project            = module.ParentDeclaration;
     _module             = module;
     _parent             = parent;
     _memberAccessExpr   = expression;
     _lExpressionBinding = lExpressionBinding;
 }
Ejemplo n.º 18
0
 public NewTypeBinding(
     DeclarationFinder declarationFinder,
     Declaration module,
     Declaration parent,
     VBAExpressionParser.NewExpressionContext expression,
     IExpressionBinding typeExpressionBinding)
 {
     _declarationFinder     = declarationFinder;
     _project               = module.ParentDeclaration;
     _module                = module;
     _parent                = parent;
     _expression            = expression;
     _typeExpressionBinding = typeExpressionBinding;
 }
Ejemplo n.º 19
0
 public ArgumentListArgument(
     IExpressionBinding binding,
     ParserRuleContext context,
     VBAParser.ArgumentListContext argumentListContext,
     ArgumentListArgumentType argumentType,
     Func <Declaration, IBoundExpression> namedArgumentExpressionCreator,
     bool isAddressOfArgument = false)
 {
     _binding                        = binding;
     Context                         = context;
     ArgumentListContext             = argumentListContext;
     ArgumentType                    = argumentType;
     _namedArgumentExpressionCreator = namedArgumentExpressionCreator;
     _isAddressOfArgument            = isAddressOfArgument;
     ReferencedParameter             = null;
 }
Ejemplo n.º 20
0
 public MemberAccessProcedurePointerBinding(
     DeclarationFinder declarationFinder,
     Declaration project,
     Declaration module,
     Declaration parent,
     VBAParser.MemberAccessExprContext expression,
     ParserRuleContext unrestrictedNameContext,
     IExpressionBinding lExpressionBinding)
 {
     _declarationFinder       = declarationFinder;
     _project                 = project;
     _module                  = module;
     _parent                  = parent;
     _expression              = expression;
     _lExpressionBinding      = lExpressionBinding;
     _unrestrictedNameContext = unrestrictedNameContext;
 }
Ejemplo n.º 21
0
 public IndexDefaultBinding(
     DeclarationFinder declarationFinder,
     Declaration project,
     Declaration module,
     Declaration parent,
     ParserRuleContext expression,
     IExpressionBinding lExpressionBinding,
     ArgumentList argumentList)
     : this(
         declarationFinder,
         project,
         module,
         parent,
         expression,
         (IBoundExpression)null,
         argumentList)
 {
     _lExpressionBinding = lExpressionBinding;
 }
 public MemberAccessDefaultBinding(
     DeclarationFinder declarationFinder,
     Declaration project,
     Declaration module,
     Declaration parent,
     VBAParser.ObjectPrintExprContext expression,
     IExpressionBinding lExpressionBinding,
     StatementResolutionContext statementContext,
     ParserRuleContext unrestrictedNameContext)
     : this(
         declarationFinder,
         project,
         module,
         parent,
         expression,
         null,
         Tokens.Print,
         statementContext,
         unrestrictedNameContext)
 {
     _lExpressionBinding = lExpressionBinding;
 }
Ejemplo n.º 23
0
 public MemberAccessDefaultBinding(
     DeclarationFinder declarationFinder,
     Declaration project,
     Declaration module,
     Declaration parent,
     VBAParser.MemberAccessExprContext expression,
     IExpressionBinding lExpressionBinding,
     StatementResolutionContext statementContext,
     ParserRuleContext unrestrictedNameContext)
     : this(
         declarationFinder,
         project,
         module,
         parent,
         expression,
         null,
         Identifier.GetName(expression.unrestrictedIdentifier()),
         statementContext,
         unrestrictedNameContext)
 {
     _lExpressionBinding = lExpressionBinding;
 }
Ejemplo n.º 24
0
 public ArgumentListArgument(IExpressionBinding binding, ArgumentListArgumentType argumentType, Func <Declaration, IBoundExpression> namedArgumentExpressionCreator)
 {
     _binding      = binding;
     _argumentType = argumentType;
     _namedArgumentExpressionCreator = namedArgumentExpressionCreator;
 }
Ejemplo n.º 25
0
        private IExpressionBinding VisitDictionaryAccessExpression(ParserRuleContext expression, ParserRuleContext nameContext, IExpressionBinding lExpressionBinding)
        {
            /*
             *  A dictionary access expression is syntactically translated into an index expression with the same
             *  expression for <l-expression> and an argument list with a single positional argument with a
             *  declared type of String and a value equal to the name value of <unrestricted-name>.
             *
             *  Still, we have a specific binding for it in order to attach a reference to the called default member to the exclamation mark.
             */
            var fakeArgList = new ArgumentList();

            fakeArgList.AddArgument(new ArgumentListArgument(new LiteralDefaultBinding(nameContext), nameContext, null, ArgumentListArgumentType.Positional));
            return(new DictionaryAccessDefaultBinding(expression, lExpressionBinding, fakeArgList));
        }
Ejemplo n.º 26
0
 public ArgumentListArgument(IExpressionBinding binding, ArgumentListArgumentType argumentType)
     : this(binding, argumentType, calledProcedure => null)
 {
 }
Ejemplo n.º 27
0
        private IExpressionBinding VisitDictionaryAccessExpression(Declaration module, Declaration parent, ParserRuleContext expression, ParserRuleContext nameContext, IExpressionBinding lExpressionBinding, StatementResolutionContext statementContext)
        {
            /*
             *  A dictionary access expression is syntactically translated into an index expression with the same
             *  expression for <l-expression> and an argument list with a single positional argument with a
             *  declared type of String and a value equal to the name value of <unrestricted-name>.
             */
            var fakeArgList = new ArgumentList();

            fakeArgList.AddArgument(new ArgumentListArgument(new LiteralDefaultBinding(nameContext), ArgumentListArgumentType.Positional));
            return(new IndexDefaultBinding(_declarationFinder, Declaration.GetProjectParent(parent), module, parent, expression, lExpressionBinding, fakeArgList));
        }