Пример #1
0
        public TypeReference(string fullName, Assembly assembly)
        {
            Name = fullName;
            var bit = BaseIntegerType.Types.Find(p => p.Name == fullName);

            if (bit != null)
            {
                Type        = TypeReferenceType.Integer;
                IntegerType = bit;
                return;
            }
            else if (ArrayType.ArrayTypeRegex.IsMatch(fullName))
            {
                Type      = TypeReferenceType.Array;
                ArrayType = new ArrayType(fullName, assembly);
            }
            else if (fullName == StringType.StringTypeKeyword)
            {
                Type      = TypeReferenceType.Array;
                ArrayType = new StringType(assembly);
            }
            else
            {
                Type = TypeReferenceType.Class;
            }
            assembly?.RegisterType(this);
        }
Пример #2
0
 public TypeReference(BaseIntegerType intType, Assembly assembly)
 {
     Type        = TypeReferenceType.Integer;
     Name        = intType.Name;
     IntegerType = intType;
     assembly?.RegisterType(this);
 }
Пример #3
0
        protected override ParseError Parse(string str, BaseIntegerType type, out Constant constant)
        {
            constant = new Constant(type);
            ulong value = 0;

            try
            {
                value = Convert.ToUInt64(str);
            }
            catch (OverflowException)
            {
                return(new ParseError(ParseErrorType.Syntax_Constant_TooLong));
            }

            if (CheckMaxValues(value, type))
            {
                return(new ParseError(ParseErrorType.Syntax_Constant_BaseOverflow));
            }

            constant.IntValue = new Integer(value, type);

            return(null);
        }
Пример #4
0
 internal Constant(BaseIntegerType type)
 {
     Type     = TypeReferenceType.Integer;
     IntValue = new Integer(0, type);
 }
Пример #5
0
 protected virtual ParseError Parse(string str, BaseIntegerType type, out Constant constant)
 {
     constant = null; return(null);
 }
Пример #6
0
 public bool CheckMaxValues(ulong value, BaseIntegerType type)
 {
     return((value > type.MaxValue) || ((long)value < type.MinValue));
 }