public override bool check(CodeContext context) { if (is_checked) { return(!error); } is_checked = true; var st = (Struct)context.analyzer.root_symbol.scope.lookup(get_type_name()); // ensure attributes are already processed st.check(context); value_type = new FloatingType(st); return(!error); }
/// <summary> /// Instantiates a new <see cref="AttributeInfo"/> object. /// </summary> /// <param name="name">Name of the attribute.</param> public DataInfo(string name, string[] possibleValues, bool optional, bool canBeEmpty) { if (name == null) throw new ArgumentNullException("name"); if (name.Length == 0) throw new ArgumentException("name is an empty string"); Name = name; PropertyName = StringUtility.GetUpperCamelCase(name); CanBeEmpty = canBeEmpty; IsOptional = optional; // Create the possible data type objects. mTypeLookup = new Dictionary<DataType, IDataType>(); mTypeLookup.Add(DataType.Boolean, new BooleanType(this, possibleValues)); mTypeLookup.Add(DataType.Byte, new IntegralType<byte>(this, possibleValues)); mTypeLookup.Add(DataType.Double, new FloatingType<double>(this, possibleValues)); FloatingType<float> type = new FloatingType<Single>(this, possibleValues); mTypeLookup.Add(DataType.Float, new FloatingType<float>(this, possibleValues)); mTypeLookup.Add(DataType.Int, new IntegralType<int>(this, possibleValues)); mTypeLookup.Add(DataType.Long, new IntegralType<long>(this, possibleValues)); mTypeLookup.Add(DataType.SByte, new IntegralType<sbyte>(this, possibleValues)); mTypeLookup.Add(DataType.Short, new IntegralType<short>(this, possibleValues)); mTypeLookup.Add(DataType.String, new StringType(this, possibleValues)); mTypeLookup.Add(DataType.UInt, new IntegralType<uint>(this, possibleValues)); mTypeLookup.Add(DataType.ULong, new IntegralType<ulong>(this, possibleValues)); mTypeLookup.Add(DataType.UShort, new IntegralType<ushort>(this, possibleValues)); mTypeLookup.Add(DataType.DateTime, new DateTimeType(this, possibleValues)); mTypeLookup.Add(DataType.Enum, new EnumType(this, possibleValues)); mTypeLookup.Add(DataType.SerialPortParity, new SerialPortParityEnumType(this, possibleValues)); mTypeLookup.Add(DataType.SerialPortStopBits, new SerialPortStopBitsEnumType(this, possibleValues)); mTypeLookup.Add(DataType.Version, new VersionType(this, possibleValues)); mTypeLookup.Add(DataType.TimeSpan, new TimeSpanType(this, possibleValues)); mTypeLookup.Add(DataType.MACAddress, new MacAddressType(this, possibleValues)); mTypeLookup.Add(DataType.IPAddress, new IPAddressType(this, possibleValues)); DetermineDefaultSelectedType(); }
public static DataType get_data_type_for_symbol(TypeSymbol sym) { DataType type = null; List <TypeParameter> type_parameters = null; if (sym is ObjectTypeSymbol) { type = new ObjectType((ObjectTypeSymbol)sym); type_parameters = ((ObjectTypeSymbol)sym).get_type_parameters(); } else if (sym is Struct) { var st = (Struct)sym; if (st.is_boolean_type()) { type = new BooleanType(st); } else if (st.is_integer_type()) { type = new IntegerType(st); } else if (st.is_floating_type()) { type = new FloatingType(st); } else { type = new StructValueType(st); } type_parameters = st.get_type_parameters(); } else if (sym is ValaEnum) { type = new EnumValueType((ValaEnum)sym); } else if (sym is ErrorDomain) { type = new ErrorType((ErrorDomain)sym, null); } else if (sym is ErrorCode) { type = new ErrorType((ErrorDomain)sym.parent_symbol, (ErrorCode)sym); } else { Report.error(null, "internal error: `%s' is not a supported type".printf(sym.get_full_name())); return(new InvalidType()); } if (type_parameters != null) { foreach (var type_param in type_parameters) { var type_arg = new GenericType(type_param); type_arg.value_owned = true; type.add_type_argument(type_arg); } } return(type); }