public override void LoadType(CClass type) { if (declared[0] != null) { declared[0].LoadType(type); } }
public override bool canConvertTo(CClass klass) { if (klass.Name == "progid:scripting.dictionary") { return(true); } return(base.canConvertTo(klass)); }
public virtual void incAccessCount(CClass currentclass, CFunction currentfunction) { if (assignCount == 0) { accessedBeforeUsed = true; } accessCount++; }
public CClassConst(CClass declaringClass, CConst myConst) : base(myConst.Token, myConst.Name.Value, "const", 1, false) { this.declaringClass = declaringClass; this.myConst = myConst; Declared[0] = myConst; myConst.ClassConst = this; }
public CConstantExpression(CToken tok) : base(tok) { m_value = tok; CClass type = null; switch (tok.TokenType) { case TokenTypes.number: int i; if (Int32.TryParse(tok.Value, out i) || tok.Value.StartsWith("0x")) { type = BuiltIns.Int32; } else { type = BuiltIns.Double; } break; case TokenTypes.str: type = BuiltIns.String; break; case TokenTypes.character: type = BuiltIns.Character; break; case TokenTypes.pound: type = BuiltIns.Date; break; case TokenTypes.keyword: if (tok.Value == "true") { type = BuiltIns.Boolean; } else if (tok.Value == "false") { type = BuiltIns.Boolean; } else if (tok.Value == "nothing") { type = BuiltIns.Nothing; } else if (tok.Value == "dbnull") { type = BuiltIns.DbNull; } break; } if (type != null) { base.LoadType(type); } }
internal void AddClass(string p, CClass type) { if (classes.ContainsKey(p)) { CClass[] rg = new CClass[] { type, classes[p] }; duplicateClasses.Add(rg); } classes[p] = type; classesList.Add(type); }
protected override bool canUnionConvert(CClass klass) { foreach (CTypeRef tref in types) { if (tref.ActualType == null || !tref.ActualType.canConvertTo(klass)) { return(false); } } return(true); }
public override bool canConvertTo(CClass klass) { CFunctionType target = klass as CFunctionType; if (target == null) { return(base.canConvertTo(klass)); } UpdateName(); target.UpdateName(); return(Name == target.Name); }
public CClass FindClass(CToken name, bool searchImports) { CClass result = null; CFile file = null; if (name.Filename != null) { fileMap.TryGetValue(name.Filename, out file); } // first look to see if the type has been renamed CToken newName; if (file != null && file.ClassNameAliases.TryGetValue(name.RawValue, out newName)) { name = newName; } // Try to find the class the normal way if (result == null) { result = InternalFindClass(name.RawValue, name.Value, searchImports); } // Look in the namespace mapping if (result == null && file != null) { foreach (var prefix in file.NameSpaceResolutionPrefixes) { result = InternalFindClass( prefix.RawValue + "." + name.RawValue, prefix.Value + "." + name.Value, searchImports); if (result != null) { break; } } } return(result); }
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 virtual bool canAssign(CClass currentclass, CFunction currentfunction) { return(currentfunction == this); }
public void incAccessCount(CClass currentclass, CFunction currentfunction) { accesses++; }
public virtual void incAssignmentCount(CClass currentclass, CFunction currentfunction) { assignCount++; }
public CTypeRef(CNode owner, CClass type) : this(owner) { InternalLoad(type); }
internal void InternalLoad(CClass type) { ActualType = type; }
public virtual void Add(CClass type) { Add(new CTypeRef(this, type)); }
public override void ConvertToArray(CClass type, int count) { base.ConvertToArray(type, count); EnsureDiminsionInitializerIsValid(); }
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); }
public virtual void LoadType(CClass type) { this.type.InternalLoad(type); }
public CTypeRef(CNode owner) { this.owner = owner; name = null; type = null; }
public void incAssignmentCount(CClass currentclass, CFunction currentfunction) { throw new Exception("Const variable is readonly"); }
public void add(CClass type) { add(type.Name, type); }
public virtual void ConvertToArray(CClass type, int count) { base.LoadType(type); }
public CMemberOverload(CMemberOverload field, bool isUnionMember) : base(field.Token, field.Name, "override", 0, isUnionMember) { this.owner = field.DeclaringClass; }
public CMemberOverload(CToken tok, CClass owner, string name) : base(tok, name, "override", 0, false) { this.owner = owner; }
public bool canAssign(CClass currentclass, CFunction currentfunction) { return(false); }
public override void LoadType(CClass type) { base.LoadType(type); EnsureDiminsionInitializerIsValid(); }