Exemple #1
0
 public virtual const_node create_int_const(string text,LexLocation loc,System.Globalization.NumberStyles NumberStyles)
 {
     if (NumberStyles == System.Globalization.NumberStyles.HexNumber)
         text = text.Substring(1);
     const_node cn = new int32_const();
     if (text.Length < 8)
         (cn as int32_const).val = Int32.Parse(text,System.Globalization.NumberStyles.Integer);
     else
     {
         try
         {
             UInt64 uint64 = UInt64.Parse(text,System.Globalization.NumberStyles.Integer);
             if (uint64 <= Int32.MaxValue)
                 (cn as int32_const).val = (Int32)uint64;
             else
                 if (uint64 <= Int64.MaxValue)
                     cn = new int64_const((Int64)uint64);
                 else
                     cn = new uint64_const(uint64);
         }
         catch (Exception)
         {
             if (NumberStyles == System.Globalization.NumberStyles.HexNumber)
                 GPPGParser.errors.Add(new BadHex(GPPGParser.current_file_name,GetTokenSourceContext(loc),new syntax_tree_node()));
             else
                 GPPGParser.errors.Add(new BadInt(GPPGParser.current_file_name,GetTokenSourceContext(loc),new syntax_tree_node()));
         }
     }
     cn.source_context = GetTokenSourceContext(loc);
     return cn;
 }
		public void write_int64_const(int64_const _int64_const)
		{
			write_const_node(_int64_const);
			bw.Write(_int64_const.val);
		}
		public void visit(int64_const _int64_const)
		{
			bw.Write((Int16)147);
			write_int64_const(_int64_const);
		}
        public virtual const_node create_int_const(GPBParser parser, System.Globalization.NumberStyles NumberStyles)
		{
            //таблица целых констант на уровне синтаксиса
            //      не может быть - 0 +
            // 32--------16----8----|----8----16--------32----------------64(bits)
            // [  int64  )[       int32       ](  int64 ](      uint64     ]
            string text = parser.LRParser.TokenString;
            if (NumberStyles == System.Globalization.NumberStyles.HexNumber)
                text = text.Substring(1);
            const_node cn=new int32_const();
            SourceContext sc = GetTokenSourceContext(parser.LRParser);//create_source_context(token);
            if (text.Length < 8)
                (cn as int32_const).val = Int32.Parse(text, NumberStyles);
            else
            {
                try
                {
                    UInt64 uint64 = UInt64.Parse(text, NumberStyles);
                    if (uint64 <= Int32.MaxValue)
                        (cn as int32_const).val = (Int32)uint64;
                    else
                        if (uint64 <= Int64.MaxValue)
                            cn = new int64_const((Int64)uint64);
                        else
                            cn = new uint64_const(uint64);
                }
                catch (Exception)
                {
                    if(NumberStyles == System.Globalization.NumberStyles.HexNumber)
                        parser.errors.Add(new BadHex(parser.current_file_name, sc, (syntax_tree_node)parser.prev_node));
                    else
                        parser.errors.Add(new BadInt(parser.current_file_name, sc, (syntax_tree_node)parser.prev_node));
                }
            }
            cn.source_context = sc;
			return cn;
		}
 public override void visit(int64_const _int64_const)
 {
     //throw new NotImplementedException();
 }
 public override void visit(int64_const _int64_const)
 {
     //throw new Exception("The method or operation is not implemented.");
     returned_scope = TypeTable.int64_type;//entry_scope.FindName(PascalABCCompiler.TreeConverter.compiler_string_consts.long_type_name);
 	cnst_val.prim_val = _int64_const.val;
 }
 public const_node create_int_const(string text, SourceContext sc, System.Globalization.NumberStyles NumberStyles)
 {
     //таблица целых констант на уровне синтаксиса
     //      не может быть - 0 +
     // 32--------16----8----|----8----16--------32----------------64(bits)
     // [  int64  )[       int32       ](  int64 ](      uint64     ]
     if (NumberStyles == System.Globalization.NumberStyles.HexNumber)
         text = text.Substring(1);
     const_node cn = new int32_const();
     if (text.Length < 8)
         (cn as int32_const).val = Int32.Parse(text, NumberStyles);
     else
     {
         try
         {
             UInt64 uint64 = UInt64.Parse(text, NumberStyles);
             if (uint64 <= Int32.MaxValue)
                 (cn as int32_const).val = (Int32)uint64;
             else
                 if (uint64 <= Int64.MaxValue)
                     cn = new int64_const((Int64)uint64);
                 else
                     cn = new uint64_const(uint64);
         }
         catch (Exception)
         {
             if (NumberStyles == System.Globalization.NumberStyles.HexNumber)
                 errors.Add(new BadHex(CurrentFileName, sc, null));
             else
                 errors.Add(new BadInt(CurrentFileName, sc, null));
         }
     }
     cn.source_context = sc;
     return cn;
 }
		public override void visit(int64_const _int64_const)
		{
			returned_scope = new ElementScope(TypeTable.int64_type);
		}
		public void read_int64_const(int64_const _int64_const)
		{
			read_const_node(_int64_const);
			_int64_const.val = br.ReadInt64();
		}
Exemple #10
0
        public override void visit(int64_const _int_const)
        {

        }
		public void visit(int64_const _int64_const)
		{
			read_int64_const(_int64_const);
		}
 public override void visit(int64_const _int64_const)
 {
     WriteNode(_int64_const);
 }
 public void CompareInternal(int64_const left, int64_const right)
 {
     if (left == null && right != null || left != null && right == null)
         throw_not_equal(left, right);
     if (left != null && right != null)
     {
         if (left.val != right.val)
             throw_not_equal(left, right);
     }
 }
 public override void visit(int64_const _int64_const)
 {
     RetValue val = new RetValue();
     val.prim_val = _int64_const.val;
     names.Add(_int64_const.val.ToString());
 }
 public override void visit(int64_const _int64_const)
 {
     AddPossibleComments(_int64_const, true, true);
 }
 public override void visit(int64_const _int_const)
 {
     text = "Value: " + _int_const.val.ToString();
 }