public CrawlArrayType(int rank, CrawlType elementType) : base(elementType.Identifier + "[" + new string(',', rank - 1) + "]", elementType.Namespace) { Rank = rank; ElementType = elementType; Ancestor = CrawlSimpleType.Array; }
/// <summary> /// Checks if assigning this to target is legal(according to Cräwl specification). /// </summary> public override bool IsAssignableTo(CrawlType target) { throw new NotImplementedException(); //Are they equal? if (Equals(target)) { return(true); } //Is this a descendant of target? //CrawlConstructedType ancestor = Ancestor; //while (ancestor.Identifier != f$OBJECT") //{ // if(ancestor.Equals(target)) // return true; // ancestor = ancestor.Ancestor; //} ////Is this implicitly castable to target? //if(ImplicitlyCastableTo(target)) // return true; //return false; }
public override bool ImplicitlyCastableTo(CrawlType target) { if (target is CrawlTypeTal) { return(true); } return(base.ImplicitlyCastableTo(target)); }
public override bool CastableTo(CrawlType target) { if (target is CrawlTypeTekst) { return(true); } return(base.CastableTo(target)); }
public override bool CastableTo(CrawlType target) { //CrawlArrayType t = target as CrawlArrayType; //if (t != null && // t.Dimensions == Dimensions && // t.ArrayElementType.CastableTo(ArrayElementType) ) // return true; //else return(false); }
public override bool IsAssignableTo(CrawlType target) { //Arrays cannot be cast up or down //Array of Animals, Containing a Tiger, assigned to an array of Dogs? //Array of Dogs, assigned to array of Animal, then a Tiger is inserted? CrawlArrayType t = target as CrawlArrayType; return(t != null && t.Rank == Rank && t.ElementType.Equals(ElementType)); }
public static CrawlType ParseDecleration(IScope declerationScope, string text) { if (text.Last() == ']') { int arrayMarkStart = text.LastIndexOf('['); string remainingType = text.Substring(0, arrayMarkStart); string arrayPart = text.Substring(arrayMarkStart); int rank = arrayPart.Count(x => x == ',') + 1; return new CrawlArrayType(rank, ParseDecleration(declerationScope, remainingType)); } else if (text.Last() == ')') { int methodMarkStart = text.LastIndexOf('('); string remainingType = text.Substring(0, methodMarkStart); string parametersSingleString = text.Substring(methodMarkStart + 1, text.Length - methodMarkStart - 2); //Uhh, probably correct. Well not, but i don't think we can get anything that breaks it. "foo(,)" would lead to no parameters... string[] parameters = parametersSingleString.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries); CrawlType returnType; if (remainingType.Trim() == "intet") { returnType = CrawlSimpleType.Intet; } else { returnType = ParseDecleration(declerationScope, remainingType); } CrawlType[] parameterTypes = new CrawlType[parameters.Length]; for (int i = 0; i < parameters.Length; i++) { parameterTypes[i] = ParseDecleration(declerationScope, parameters[i]); } return new CrawlMethodType(returnType, parameterTypes); } else { var results = declerationScope.FindSymbol(text.Trim()); if (results == null || results.Length == 0) { throw new TypeNotFoundException("Unknown type " + text); //TODO: ERROR MSG } else if (results.Length == 1) { return results[0].Type; } else throw new Exception("Ambigious types " + text); //TODO: ERROR MSG } }
public override bool ImplicitlyCastableTo(CrawlType target) { //Casting an entire array in any way dosen't make sense. //We could try, but it just leads to _weird_ erros when trying //to save something in a casted array. //CrawlArrayType t = target as CrawlArrayType; //if (t != null && // t.Dimensions == Dimensions && // t.ArrayElementType.ImplicitlyCastableTo(ArrayElementType) ) // return true; //else return(false); }
/// <summary> /// Checks if a cast from this to target is legal(according to the Cräwl specification). /// </summary> public override bool CastableTo(CrawlType target) { throw new NotImplementedException(); //TODO Check additional rules for simple types ////Are they equal? //if (Equals(target)) // return true; ////Is this a descendant of target? //CrawlConstructedType ancestor = Ancestor; //while (ancestor.Identifier != "$OBJECT") //{ // if(ancestor.Equals(target)) // return true; // ancestor = ancestor.Ancestor; //} //return false; }
/// <summary> /// Checks if an implicit cast from this to target is legal(according to the Cräwl specification). /// </summary> public abstract bool ImplicitlyCastableTo(CrawlType target);
/// <summary> /// Checks if an implicit cast from this to target is legal(according to the Cräwl specification). /// </summary> public override bool ImplicitlyCastableTo(CrawlType target) { //TODO Check additional rules for simple types return(false); }
public override bool ImplicitlyCastableTo(CrawlType target) { return(!(target is CrawlSimpleType)); }
public override bool IsAssignableTo(CrawlType target) { return(false); }
public override bool CastableTo(CrawlType target) { return(false); }
public override bool IsAssignableTo(CrawlType target) { return(!(target is CrawlSimpleType)); }
public CrawlMethodType(CrawlType returnType, IEnumerable <CrawlType> parameters) : base("", "") { ReturnType = returnType; Parameters = parameters.ToList(); }
/// <summary> /// Checks if a cast from this to target is legal(according to the Cräwl specification). /// </summary> public abstract bool CastableTo(CrawlType target);
/// <summary> /// Checks if assigning this to target is legal(according to Cräwl specification). /// </summary> public abstract bool IsAssignableTo(CrawlType target);
public override bool CastableTo(CrawlType target) { return(Equals(target)); }
public override bool IsAssignableTo(CrawlType target) { return(Equals(target) || ImplicitlyCastableTo(target)); }
public override bool IsAssignableTo(CrawlType target) { return(Equals(target)); }