public CDictionaryType(CTypeRef type) : base(type, 1) { indexType.InternalLoad(BuiltIns.String); Dictionaries.Add(this); IsObject = true; }
public CArgument(CToken direction, CToken name, CTypeRef tref) : base(name) { this.direction = direction; this.name = name; base.LoadType(tref); }
public override void LoadType(CTypeRef tref) { if (declared[0] != null) { declared[0].LoadType(tref); } }
/// <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; } }
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); } }
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)); }
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); }
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; }
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); }
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"))); }
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; }
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); } }
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; }
public bool Equals(CTypeRef obj) { return(this == obj); }
public override void LoadType(CTypeRef tref) { throw new InvalidOperationException(); }
public CTypeRef(CNode owner, CTypeRef tref) : this(owner) { InternalLoad(tref); }
public virtual void ClearType() { type = new CTypeRef(this); }
internal void InternalLoad(CTypeRef tref) { TypeName = tref.name; ActualType = tref.type; }
protected CNode() { type = new CTypeRef(this); token = null; lock (allNodes) allNodes.Add(this); }
public virtual void LoadType(CTypeRef tref) { type.InternalLoad(tref); }
public CCast(CTypeRef type, CExpression exp) : base(type.TypeName, exp) { LoadType(type); }
public override void LoadType(CTypeRef tref) { base.LoadType(tref); EnsureDiminsionInitializerIsValid(); }
internal virtual void AddInterface(CTypeRef interfaceref) { this.interfaces.Add(new CTypeRef(this, interfaceref)); }
public CArrayType(CTypeRef type, int dims) : this(dims) { ItemType = type; }
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)); } }
public void Add(CToken name, CParameters parameters, CTypeRef ctr) { list.Add(new CAttribute(name, parameters, ctr)); }
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); }
protected CNode(CToken token) { type = new CTypeRef(this); this.token = token; lock (allNodes) allNodes.Add(this); }
public void Add(CToken name, CTypeRef ctr) { Add(name, null, ctr); }
internal override void AddInterface(CTypeRef interfaceref) { throw new InvalidOperationException("Enums can't have interfaces"); }
public bool Equals(CTypeRef obj) { return this == obj; }
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); }
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"))); }
internal void SetInterface(int i, CTypeRef itr) { interfaces[i] = itr; }