Inheritance: ConstrainedType
Esempio n. 1
0
        private Range VisitRange(Range range)
        {
            WriteStart("range {0} ", range.Name.Name);
            this.VisitExpression(range.Min);
            Write(" .. ");
            this.VisitExpression(range.Max);
            WriteFinish(";");

            return range;
        }
Esempio n. 2
0
 private Range VisitRange(Range range)
 {
     if (range == null) return null;
     Range result = (Range)this.VisitConstrainedType(range);
     result.Min = this.VisitExpression(range.Min);
     result.Max = this.VisitExpression(range.Max);
     return result;
 }
Esempio n. 3
0
        private Range VisitRange(Range range)
        {
            range.Min = this.VisitExpression(range.Min);
            range.Max = this.VisitExpression(range.Max);

            return (Range)this.VisitConstrainedType((ConstrainedType)range);
        }
Esempio n. 4
0
        private void GenerateRange(Range rangeNode)
        {
            TypeNode rangeClass = Templates.GetTypeTemplateByName("Range");

            Debug.Assert(rangeClass.Members[0] is EnumNode);
            EnumNode rangeEnum = (EnumNode)rangeClass.Members[0];
            rangeEnum.Name = rangeNode.Name;
            Replacer.Replace(rangeEnum, "_MinValue", rangeNode.Min);
            Replacer.Replace(rangeEnum, "_MaxValue", rangeNode.Max);
            InstallType(rangeEnum);

            Debug.Assert(rangeClass.Members[1] is Field);
            Field f = (Field)rangeClass.Members[1];
            f.Name = new Identifier(rangeNode.Name.Name + "Choices");

            choosableTypes.Add(rangeNode.Name, f.Name);

            Debug.Assert(f.Initializer != null && f.Initializer is ConstructArray);
            ConstructArray consArray = (ConstructArray)f.Initializer;
            Debug.Assert(rangeNode.Min is Literal);
            int min = (int)((Literal)rangeNode.Min).Value;
            int max = (int)((Literal)rangeNode.Max).Value;
            for (int i = min; i <= max; i++)
                consArray.Initializers.Add(new Literal(i, SystemTypes.Int32));

            appClass.Members.Add(f);
            f.DeclaringType = appClass;
        }