public CDictionaryType(CTypeRef type)
     : base(type, 1)
 {
     indexType.InternalLoad(BuiltIns.String);
     Dictionaries.Add(this);
     IsObject = true;
 }
示例#2
0
 public CArgument(CToken direction, CToken name, CTypeRef tref)
     : base(name)
 {
     this.direction = direction;
     this.name      = name;
     base.LoadType(tref);
 }
示例#3
0
 public override void LoadType(CTypeRef tref)
 {
     if (declared[0] != null)
     {
         declared[0].LoadType(tref);
     }
 }
示例#4
0
        /// <summary>Creates a new instance of CFunction
        /// this one is for funcs and subs that are parts of classes.  this means
        /// that they can be public or private.  also, we track if they are subs or funcs as this has
        /// implications with how exit/return is used
        /// </summary>
        public CFunction(CToken token, string rawname, string name, TokenTypes visibility, FunctionType subFuncFlag,
                         CArgumentList args, CTypeRef tref)
            : base(token)
        {
            funcName        = name;
            rawFuncName     = rawname;
            this.visibility = visibility;
            functionType    = subFuncFlag;
            LoadType(tref);

            if (args != null)
            {
                arguments = args;
            }

            switch (functionType)
            {
            case vbPropertyGet:
                alias = "get_" + rawname;
                break;

            case vbPropertySet:
                alias = "set_" + rawname;
                break;

            case vbSub:
            case vbFunction:
            default:
                alias = rawname;
                break;
            }
        }
示例#5
0
 public CArgument(CToken direction, CToken name, CTypeRef tref)
     : base(name)
 {
     this.direction = direction;
     this.name = name;
     base.LoadType(tref);
 }
        private void TryItemTypeFixup()
        {
            CClass  type;
            CMethod items = (CMethod)base.LookupMember("items");

            type = ((CArrayType)items.Declared[CProperty.ixGet].Type).ItemType.ActualType;

            if (type == null)
            {
                CMethod add = (CMethod)base.LookupMember("add");
                type = add.Function.Arguments[1].Type.ActualType;
            }

            if (type == null)
            {
                CProperty item = (CProperty)base.LookupMember("item");
                type = item.Type.ActualType;
                if (type == null && item.GetAccessor != null)
                {
                    type = item.GetAccessor.Type.ActualType;
                }
                if (type == null && item.SetAccessor != null)
                {
                    type = item.SetAccessor.Arguments[1].Type.ActualType;
                }
            }

            if (type != null)
            {
                ItemType = new CTypeRef(null, type);
            }
        }
示例#7
0
 public CAttribute(CToken name, CParameters parameters, CTypeRef ctr)
     : base(name)
 {
     this.name = name.Value;
     nameToken = name;
     this.parameters = parameters ?? new CParameters();
     LoadType(new CTypeRef(this, ctr));
 }
示例#8
0
 public CAttribute(CToken name, CParameters parameters, CTypeRef ctr)
     : base(name)
 {
     this.name       = name.Value;
     nameToken       = name;
     this.parameters = parameters ?? new CParameters();
     LoadType(new CTypeRef(this, ctr));
 }
示例#9
0
        public CClass(CToken token, String rawname, String name, CTypeRef baseClass)
            : base(token)
        {
            originalClassName  = name;
            className          = CToken.Identifer(token, name, rawname);
            canConvertToString = false;

            this.baseClass = new CTypeRef(this, baseClass);
            base.LoadType(this);
        }
示例#10
0
 public CVariable(CToken name, bool shared, CTypeRef tref, CParameters arrayDimsinit, CExpression init, CDim parent)
     : base(name, shared)
 {
     this.dim = parent;
     this.name = name;
     base.LoadType(tref);
     this.init = init;
     if (init != null)
         init.Parent = this;
     member = false;
     this.arrayDimsinit = arrayDimsinit;
 }
示例#11
0
        public CArrayType(int dims)
            : base("Array<" + (++i) + "," + dims + ">", false)
        {
            id = i;

            this.dims = dims;
            IsObject = false;
            indexType = new CTypeRef(this, BuiltIns.Int32);
            itemType = new CTypeRef(this);

            if (Compiler.Current != null)
                CProgram.Global.AddArray(this);
        }
示例#12
0
 public CLambdaFunction(CToken token, CFunction containingFunction, CFile containingFile, String name, CTypeRef tref,
                        CArgumentList args)
     : base(token, name, name, TokenTypes.visInternal, FunctionType.Function, args, tref)
 {
     this.containingFunction = containingFunction;
     this.containingFile = containingFile;
     if (this.containingFunction != null)
         this.containingFunction.Lambdas.Add(this);
     else
         this.containingFile.Lambdas.Add(this);
     CallCount++;
     Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute")));
 }
示例#13
0
 public CVariable(CToken name, bool shared, CTypeRef tref, CParameters arrayDimsinit, CExpression init, CDim parent)
     : base(name, shared)
 {
     this.dim  = parent;
     this.name = name;
     base.LoadType(tref);
     this.init = init;
     if (init != null)
     {
         init.Parent = this;
     }
     member             = false;
     this.arrayDimsinit = arrayDimsinit;
 }
示例#14
0
        public CArrayType(int dims)
            : base("Array<" + (++i) + "," + dims + ">", false)
        {
            id = i;

            this.dims = dims;
            IsObject  = false;
            indexType = new CTypeRef(this, BuiltIns.Int32);
            itemType  = new CTypeRef(this);

            if (Compiler.Current != null)
            {
                CProgram.Global.AddArray(this);
            }
        }
示例#15
0
 public virtual void Add(CTypeRef tref)
 {
     if (tref.Resolved && tref.ActualType is CUnionType)
     {
         Add((CUnionType)tref.ActualType);
     }
     else
     {
         string prefix = " Or ";
         if (Name == "")
         {
             prefix = "";
         }
         NameToken =
             CToken.Identifer(NameToken, Name + prefix + tref.TypeName.Value,
                              RawName + prefix + tref.TypeName.RawValue);
         types.Add(new CTypeRef(this, tref));
     }
 }
        internal CStatementBlock StartInitialize(CFunction containingFunction, CFile containingFile, CTypeRef tref, CArgumentList args)
        {
            if (lambdaFunction != null)
                throw new InvalidOperationException("Lambdas can only be initalized once");

            CClass @class = null;
            string extra = "";
            if (containingFunction != null)
            {
                @class = containingFunction.Class;
                extra += containingFunction.RawName;
            }

            lambdaFunction =
                new CLambdaFunction(Token, containingFunction, containingFile, "Lambda_" + extra + "_" + lambdaId, tref, args);
            base.LoadType(lambdaType = new CFunctionType(Token, lambdaFunction, false));

            lambdaFunction.Class = @class;

            return lambdaFunction.Statements;
        }
示例#17
0
 public bool Equals(CTypeRef obj)
 {
     return(this == obj);
 }
示例#18
0
 public override void LoadType(CTypeRef tref)
 {
     throw new InvalidOperationException();
 }
示例#19
0
 public CTypeRef(CNode owner, CTypeRef tref)
     : this(owner)
 {
     InternalLoad(tref);
 }
示例#20
0
 public virtual void ClearType()
 {
     type = new CTypeRef(this);
 }
示例#21
0
 internal void InternalLoad(CTypeRef tref)
 {
     TypeName = tref.name;
     ActualType = tref.type;
 }
示例#22
0
 protected CNode()
 {
     type  = new CTypeRef(this);
     token = null;
     lock (allNodes) allNodes.Add(this);
 }
示例#23
0
 public virtual void LoadType(CTypeRef tref)
 {
     type.InternalLoad(tref);
 }
示例#24
0
 public CCast(CTypeRef type, CExpression exp)
     : base(type.TypeName, exp)
 {
     LoadType(type);
 }
示例#25
0
        public override void LoadType(CTypeRef tref)
        {
            base.LoadType(tref);

            EnsureDiminsionInitializerIsValid();
        }
示例#26
0
 internal virtual void AddInterface(CTypeRef interfaceref)
 {
     this.interfaces.Add(new CTypeRef(this, interfaceref));
 }
示例#27
0
 public CArrayType(CTypeRef type, int dims)
     : this(dims)
 {
     ItemType = type;
 }
示例#28
0
 public virtual void Add(CTypeRef tref)
 {
     if (tref.Resolved && tref.ActualType is CUnionType)
         Add((CUnionType)tref.ActualType);
     else
     {
         string prefix = " Or ";
         if (Name == "")
             prefix = "";
         NameToken =
             CToken.Identifer(NameToken, Name + prefix + tref.TypeName.Value,
                              RawName + prefix + tref.TypeName.RawValue);
         types.Add(new CTypeRef(this, tref));
     }
 }
示例#29
0
 public CArrayType(CTypeRef type, int dims)
     : this(dims)
 {
     ItemType = type;
 }
示例#30
0
 public CTypeRef(CNode owner, CTypeRef tref)
     : this(owner)
 {
     InternalLoad(tref);
 }
示例#31
0
 public void Add(CToken name, CParameters parameters, CTypeRef ctr)
 {
     list.Add(new CAttribute(name, parameters, ctr));
 }
示例#32
0
        public virtual String UpdateMembers(IVisitor checker)
        {
            if (types.Count == 0)
            {
                return("Empty enum type used");
            }

            bool isObject = true;

            for (int i = 0; i < types.Count; i++)
            {
                CTypeRef otype = types[i];
                if (!otype.Resolved)
                {
                    CClass ntype = CProgram.Global.FindClass(otype.TypeName);
                    if (ntype == null)
                    {
                        return("Cannot find type " + otype.TypeName.RawValue);
                    }
                    otype.InternalLoad(ntype);
                }
                types[i] = otype;
                types[i].ActualType.Accept(checker);
                isObject = isObject && otype.ActualType.IsObject;
            }
            IsObject = isObject;

            base.ClearMembers();
            Scope.Clear();

            foreach (CMember member in types[0].ActualType.InheritedMemberIterator)
            {
                bool found;
                if (member is CMemberOverload)
                {
                    found = false;
                }
                else// Unions can only access public members
                {
                    found = member.Visibility == TokenTypes.visPublic;
                }


                IEnumerator <CTypeRef> it = types.GetEnumerator();
                it.MoveNext();
                while (found && it.MoveNext())
                {
                    CClass  type     = it.Current.ActualType;
                    CMember luMember = type.LookupMember(member.Name);
                    if (luMember == null)
                    {
                        found = false;
                    }
                    else if (luMember.MemberType != member.MemberType)
                    {
                        // one's a method, the other's a field, or etc...
                        found = false;
                    }
                    else if (luMember.Visibility != TokenTypes.visPublic)
                    {
                        found = false;
                    }
                    else
                    {
                        switch (luMember.MemberType)
                        {
                        case "method":
                            CMethod metho   = (CMethod)member;
                            CMethod luMetho = (CMethod)luMember;
                            // already checked return type, let's try the parameters
                            if (metho.Function.Arguments.Count != luMetho.Function.Arguments.Count)
                            {
                                found = false;
                            }
                            break;

                        case "property":
                            found = UnionProperty((CProperty)member, (CProperty)luMember);
                            // dur
                            break;

                        case "field":
                            // already checked return type, nothing left to check
                            break;

                        case "override":
                            found = false;    // dur
                            break;
                        }
                    }
                }
                if (found)
                {
                    CMember fmember;
                    switch (member.MemberType)
                    {
                    case "method":
                        fmember = new CMethod((CMethod)member, true);
                        break;

                    case "property":
                        fmember = new CProperty((CProperty)member, true);
                        break;

                    case "field":
                        fmember = new CField((CField)member, true);
                        break;

                    case "override":
                        fmember = new CMemberOverload((CMemberOverload)member, true);
                        break;

                    default:
                        throw new InvalidOperationException();
                    }
                    SetMember(member.Name, fmember);
                    Scope.add(fmember);
                }
            }

            bool hasDefault = true;

            DefaultMember = null;
            foreach (CTypeRef _class in types)
            {
                var memberBase = ((CClass)types[0]).DefaultMember;
                var member     = _class.ActualType.DefaultMember;
                if (memberBase == null ||
                    member == null ||
                    !UnionProperty((CProperty)memberBase, (CProperty)member))
                {
                    hasDefault = false;
                    break;
                }
            }
            if (hasDefault)
            {
                DefaultMember = ((CClass)types[0]).DefaultMember;
            }

            return(null);
        }
示例#33
0
 protected CNode(CToken token)
 {
     type       = new CTypeRef(this);
     this.token = token;
     lock (allNodes) allNodes.Add(this);
 }
示例#34
0
 protected CNode(CToken token)
 {
     type = new CTypeRef(this);
     this.token = token;
     lock (allNodes) allNodes.Add(this);
 }
示例#35
0
 public virtual void ClearType()
 {
     type = new CTypeRef(this);
 }
示例#36
0
        public override void LoadType(CTypeRef tref)
        {
            base.LoadType(tref);

            EnsureDiminsionInitializerIsValid();
        }
示例#37
0
 public void Add(CToken name, CTypeRef ctr)
 {
     Add(name, null, ctr);
 }
示例#38
0
 internal override void AddInterface(CTypeRef interfaceref)
 {
     throw new InvalidOperationException("Enums can't have interfaces");
 }
示例#39
0
 public virtual void LoadType(CTypeRef tref)
 {
     type.InternalLoad(tref);
 }
示例#40
0
 public bool Equals(CTypeRef obj)
 {
     return this == obj;
 }
示例#41
0
 protected CNode()
 {
     type = new CTypeRef(this);
     token = null;
     lock (allNodes) allNodes.Add(this);
 }
示例#42
0
 internal void InternalLoad(CTypeRef tref)
 {
     TypeName   = tref.name;
     ActualType = tref.type;
 }
        internal CStatementBlock StartInitialize(CFunction containingFunction, CFile containingFile, CTypeRef tref, CArgumentList args)
        {
            if (lambdaFunction != null)
            {
                throw new InvalidOperationException("Lambdas can only be initalized once");
            }

            CClass @class = null;
            string extra  = "";

            if (containingFunction != null)
            {
                @class = containingFunction.Class;
                extra += containingFunction.RawName;
            }

            lambdaFunction =
                new CLambdaFunction(Token, containingFunction, containingFile, "Lambda_" + extra + "_" + lambdaId, tref, args);
            base.LoadType(lambdaType = new CFunctionType(Token, lambdaFunction, false));

            lambdaFunction.Class = @class;

            return(lambdaFunction.Statements);
        }
示例#44
0
 internal override void AddInterface(CTypeRef interfaceref)
 {
     throw new InvalidOperationException("Enums can't have interfaces");
 }
 public CLambdaFunction(CToken token, CFunction containingFunction, CFile containingFile, String name, CTypeRef tref,
                        CArgumentList args)
     : base(token, name, name, TokenTypes.visInternal, FunctionType.Function, args, tref)
 {
     this.containingFunction = containingFunction;
     this.containingFile     = containingFile;
     if (this.containingFunction != null)
     {
         this.containingFunction.Lambdas.Add(this);
     }
     else
     {
         this.containingFile.Lambdas.Add(this);
     }
     CallCount++;
     Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute")));
 }
示例#46
0
 internal void SetInterface(int i, CTypeRef itr)
 {
     interfaces[i] = itr;
 }