public override void Observe(VHDLCompilerInterface compiler) { compiler.TypeDictionary.AddItem(type, type.Identifier); if (BuiltInTypesDictionary.ContainsBuiltInSubType(type)) { return; } ISubtypeIndication si = type.SubtypeIndication; string typeName = type.Identifier; if (si is RangeSubtypeIndication) { RangeSubtypeIndication rangeSI = si as RangeSubtypeIndication; ISubtypeIndication baseSI = rangeSI.BaseType; if (baseSI is VHDL.type.IntegerType) { ObserveIntegerSubType(compiler, rangeSI, typeName); } if (baseSI is VHDL.type.RealType) { ObserveRealSubType(compiler, rangeSI, typeName); } } }
public void visit(RangeSubtypeIndication item) { if (item == null) { return; } baseType = item.BaseType; }
public void rangeSubtypeIndication(RangeSubtypeIndication indication) { if (indication.BaseType != null) { output.writeSubtypeIndication(indication.BaseType); } else { writer.Append("null"); } writer.Append(' ').Append(KeywordEnum.RANGE.ToString()).Append(' '); output.writeDiscreteRange(indication.Range); }
public static string GenerateFloatingPointSubType(VHDLCompilerInterface compiler, string typeName, RangeSubtypeIndication rangeSubtype) { string baseType = compiler.TypeDictionary[rangeSubtype.BaseType]; double rangeLeft = ((rangeSubtype.Range as VHDL.Range).From as VHDL.literal.RealLiteral).RealValue; double rangeRight = ((rangeSubtype.Range as VHDL.Range).To as VHDL.literal.RealLiteral).RealValue; RangeDirection rangeRirection = ((rangeSubtype.Range as VHDL.Range).Direction == VHDL.Range.RangeDirection.TO) ? RangeDirection.To : RangeDirection.DownTo; return(GenerateFloatingPointSubType(compiler, typeName, baseType, rangeLeft, rangeRight, rangeRirection)); }
public static string GenerateIntegerSubType(VHDLCompilerInterface compiler, string typeName, RangeSubtypeIndication rangeSubtype) { string baseType = compiler.TypeDictionary[rangeSubtype.BaseType]; Int64 rangeLeft = ((rangeSubtype.Range as VHDL.Range).From as VHDL.literal.IntegerLiteral).IntegerValue; Int64 rangeRight = ((rangeSubtype.Range as VHDL.Range).To as VHDL.literal.IntegerLiteral).IntegerValue; RangeDirection rangeRirection = ((rangeSubtype.Range as VHDL.Range).Direction == VHDL.Range.RangeDirection.TO) ? RangeDirection.To : RangeDirection.DownTo; IntegerSubTypeTemplate template = new IntegerSubTypeTemplate(typeName, baseType, rangeLeft, rangeRight, rangeRirection); string code = template.TransformText(); //compiler.TypeRangeDictionary.AddItem(rangeSubtype, "IntegerRange", template.RangeLeft, template.RangeRight, template.Direction); return(code); }
private void ObserveRealSubType(VHDLCompilerInterface compiler, RangeSubtypeIndication rangeSI, string typeName) { string code = FloatingPointSubTypeGeneratorHelper.GenerateFloatingPointSubType(compiler, typeName, rangeSI); compiler.SaveCode(code, typeName); }