protected override SyntaxNode VisitMemberAccessSyntax(MemberAccessSyntax pNode)
 {
     if (_unit.HasReference(pNode.Identifier.Value))
     {
         return(SyntaxFactory.MemberAccess(SyntaxFactory.Namespace(pNode.Identifier.Value), (IdentifierSyntax)Visit(pNode.Value)));
     }
     return(base.VisitMemberAccessSyntax(pNode));
 }
Beispiel #2
0
        protected virtual void VisitMemberAccessSyntax(MemberAccessSyntax pNode)
        {
            Visit(pNode.Identifier);
            using (var t = Store.AddValue("__Type", pNode.Identifier.Type))
            {
                Visit(pNode.Value);
            }

            Namespace = null;
        }
 public override void Visit(MemberAccessSyntax pNode)
 {
     base.Visit(pNode);
     if (pNode.Name.Type.IsTupleType)
     {
         var v = pNode.Value;
         var t = pNode.Name.Type.ToSystemType();
         var f = t.GetField(v.Value);
         v.SetType(SmallType.FromSystemType(f.FieldType));
     }
 }
        protected override void VisitMemberAccessSyntax(MemberAccessSyntax pNode)
        {
            Visit(pNode.Identifier);

            //Save current local definitions
            //Mark the current type we are on so error messages can be more descriptive
            var l = _locals;

            using (var t = Store.AddValue("__Type", pNode.Identifier.Type))
            {
                //If field doesn't exist or something went wrong, stop checking things to reduce redundant errors
                if (CurrentType != SmallTypeCache.Undefined)
                {
                    //For methods and arrays we need to allow existing variables, but member access should only allow the struct's fields
                    if (NeedToCopyLocals(pNode.Value))
                    {
                        _locals = _locals.Copy();
                    }
                    else
                    {
                        _locals = new ScopeCache <LocalDefinition>();
                    }

                    //Namespaces return a null type
                    if (CurrentType != null)
                    {
                        _locals.AddScope();
                        foreach (var f in CurrentType.GetFields())
                        {
                            if (!_locals.IsVariableDefinedInScope(f.Name))
                            {
                                _locals.DefineVariableInScope(f.Name, LocalDefinition.Create(false, f.Type));
                            }
                        }
                    }

                    Visit(pNode.Value);
                }
            }

            //Restore local definitions
            Namespace = null;
            _locals   = l;
        }
Beispiel #5
0
        public override SyntaxNode Visit(MemberAccessSyntax pNode)
        {
            MemberAccessContext ma      = GetValue <MemberAccessContext>("MemberContext", null);
            MemberAccessContext context = new MemberAccessContext();

            if (ma != null)
            {
                context.Member = ma.Member;
            }
            using (new ContextValue(this, "MemberContext", context))
            {
                var n = pNode.Name.Accept <IdentifierSyntax>(this);

                var v = pNode.Value.Accept <IdentifierSyntax>(this);
                if (v.GetType() == typeof(FunctionInvocationSyntax))
                {
                    n.LoadAddress = true;
                }

                return(SyntaxFactory.MemberAccess(n, v));
            }
        }
Beispiel #6
0
 protected virtual SyntaxNode VisitMemberAccessSyntax(MemberAccessSyntax pNode)
 {
     return(SyntaxFactory.MemberAccess((IdentifierSyntax)Visit(pNode.Identifier), (IdentifierSyntax)Visit(pNode.Value)));
 }
 public MemberAccess(MemberAccessSyntax syntax, Package containingPackage, Expression expression)
     : base(syntax, containingPackage)
 {
     Expression = expression;
     Member     = syntax.Member.ValueText;
 }