Ejemplo n.º 1
0
 public virtual CapnpType Visit(CapnpType target)
 {
     if (target == null)
     {
         return(null);
     }
     return(target.Accept(this));
 }
Ejemplo n.º 2
0
        public CapnpType ResolveFullName(FullName fullName)
        {
            // Find the first scope in which to start looking.
            CapnpComposite startScope = this;
            CapnpType      result     = null;

            for (var scope = startScope; scope != null; scope = scope.Scope)
            {
                result = scope._ResolveName(fullName[0], this, null);
                if (result != null)
                {
                    break;
                }
            }

            if (result == null || fullName.Count == 1)
            {
                return(result);
            }

            // Resolve rest.
            var container = result;

            for (var i = 1; i < fullName.Count; i++)
            {
                if (container is CapnpBoundGenericType)
                {
                    var generic = (CapnpBoundGenericType)container;
                    container = ((CapnpGenericType)generic.OpenType)._ResolveName(fullName[i], this, generic); // todo: this cast should succeed with correct grammar, but perhaps may fail with a bad one

                    // If the reference is to a generic parameter it must resolve.
                    // Note that if the type is still open it could resolve to a generic parameter.
                    if (container is CapnpGenericParameter)
                    {
                        container = generic.ResolveGenericParameter((CapnpGenericParameter)container);
                    }

                    if (container == null)
                    {
                        return(null);
                    }
                }
                else if (container is CapnpComposite)
                {
                    container = ((CapnpComposite)container)._ResolveName(fullName[i].Name);
                    if (container == null)
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
            return(container);
        }
Ejemplo n.º 3
0
 public UnresolvedValue(CapnpType referenceType) : base(referenceType)
 {
 }
Ejemplo n.º 4
0
 public Value(CapnpType type)
 {
     Type = type;
 }
Ejemplo n.º 5
0
 public ConstRefValue(CapnpType constType)
     : base(constType)
 {
     Debug.Assert(!(constType is CapnpReference));
 }