/// <summary> /// It check if it's possible the operation accessing BCLClassType and a member, if is not possible /// it raises and error /// </summary> /// <param name="d">A BCLCClassType to pass the message member</param> /// <returns>The resulting type expression, if no operation is possible it raises and error. /// </returns> public override object Exec(BCLClassType d, object arg) { TypeExpression member = (TypeExpression)d.AcceptOperation(new UnconstrainedDotOperation(this.memberName, this.previousDot), arg); if (member == null) { ErrorManager.Instance.NotifyError(new UnknownMemberError(this.memberName, this.location)); } return(member); }
public override object Exec(BCLClassType caller, object arg) { // * Load the constructors if (caller.Constructors == null) { caller.FindConstructor(this.location); } // * Follows the superclass behaviour // * Actually Base Class return the GrandFather Class. return(caller.BaseClass.AcceptOperation(this, arg)); }
public override object Exec(NullType firstOperand, object arg) { // * Built-in types: no promotion, except string if (this.secondOperand is BoolType || this.secondOperand is CharType || this.secondOperand is DoubleType || this.secondOperand is IntType || this.secondOperand is VoidType) { return(-1); } // * BCL Value Types (structs): No promotion BCLClassType bclClass = TypeExpression.As <BCLClassType>(this.secondOperand); if (bclClass != null) { if (bclClass.TypeInfo.IsValueType) { return(-1); } // * Correct promotion to classes that are not value types return(0); } // * WriteType variable TypeVariable typeVariable = this.secondOperand as TypeVariable; if (typeVariable != null) { if (typeVariable.Substitution != null) { // * If the variable is bounded, the promotion is the one of its substitution return(firstOperand.AcceptOperation(new PromotionLevelOperation(typeVariable.EquivalenceClass.Substitution), arg)); } // * A free variable is complete promotion return(0); } // * Union type UnionType unionType = TypeExpression.As <UnionType>(this.secondOperand); if (unionType != null) { return(unionType.SuperType(firstOperand)); } // * Field type and bounded type variable FieldType fieldType = TypeExpression.As <FieldType>(this.secondOperand); if (fieldType != null) { return(firstOperand.AcceptOperation(new PromotionLevelOperation(fieldType.FieldTypeExpression), arg)); } // * Correct Promotion return(0); }
public override object Exec(BCLClassType a, object arg) { // * Brackets are allowed if it is an array nb if (a.TypeInfo.IsArray) { return(TypeTable.Instance.GetType(a.TypeInfo.GetElementType().FullName, this.location)); } // * Brackets are allowed if it is an indexer if (a.Methods.ContainsKey("get_Item")) { MethodType method = a.Methods["get_Item"].Type as MethodType; if (method != null && method.ParameterListCount == 1) // && method.GetParameter(0).Equivalent(IntType.Instance)) { return(method.Return); } } // if we are in these point the [] is not applicable simply raise an error. return(ReportError(a)); }
public override object Exec(ArrayType operand1, object arg) { // * Is it an array? ArrayType arrayType = TypeExpression.As <ArrayType>(this.operand2); if (arrayType != null) { return(operand1.ArrayTypeExpression.AcceptOperation(new EquivalentOperation(arrayType.ArrayTypeExpression), arg)); } // * It can be a System.Array BCLClassType bclClassType = TypeExpression.As <BCLClassType>(this.operand2); if (bclClassType.TypeInfo.IsArray) { TypeExpression elementType = TypeTable.Instance.GetType(bclClassType.TypeInfo.GetElementType().FullName, new Location()); return(elementType.AcceptOperation(new EquivalentOperation(operand1), arg)); } return(false); }
public override object Exec(BCLClassType d, object arg) { // * Has the attribute been previosly found? if (d.Members.ContainsKey(this.memberName)) { return(d.Members[this.memberName].Type); } // * Let's try introspection TypeExpression member = d.FindMember(this.memberName); if (member != null) { return(member); } // * Search in base class if (d.BaseClass != null) { return(d.BaseClass.AcceptOperation(new UnconstrainedDotOperation(this.memberName, this.previousDot), arg)); } return(null); }
public override object Exec(BCLClassType operand1, object arg) { if (this.operand2 == null) { return(false); } if (operand1.FullName.Equals(this.operand2.FullName)) { return(true); } if ((bool)BCLClassType.BCLtoTypeSystemMapping.ContainsKey(operand1.FullName) && (bool)BCLClassType.BCLtoTypeSystemMapping[operand1.FullName].AcceptOperation(new EquivalentOperation(operand2), null)) { return(true); } if (operand1.TypeInfo.IsArray) { Type elementType = operand1.TypeInfo.GetElementType(); if (this.operand2 is ArrayType) { return(new BCLClassType(elementType.FullName, elementType).AcceptOperation(new EquivalentOperation(((ArrayType)this.operand2).ArrayTypeExpression), null)); } BCLClassType bclType = TypeExpression.As <BCLClassType>(this.operand2); if (bclType != null && bclType.TypeInfo.IsArray) { TypeExpression thisArrayType = TypeTable.Instance.GetType(operand1.TypeInfo.GetElementType().FullName, new Location()), paramArrayType = TypeTable.Instance.GetType(bclType.TypeInfo.GetElementType().FullName, new Location()); return(thisArrayType.AcceptOperation(new EquivalentOperation(paramArrayType), null)); } } return(false); }
public override object Exec(BCLClassType bclClassType, object arg) { // * This operation has an important performance cost. Therefore, it is done locally because // the BCLClassType only returns the type of an specific member (not all of them) return(this.getAccessModifiers(bclClassType, false)); }
public virtual object Exec(BCLClassType b, object arg) { return(Exec((ClassType)b, arg)); }