Пример #1
0
        /// <inheritdoc />
        public override void VisitNewEx(NewEx x)
        {
            if (x.ClassNameRef is IndirectTypeRef)
            {
                occurrenceNodes.Enqueue(x);
            }

            base.VisitNewEx(x);
        }
Пример #2
0
        public override void VisitNewEx(NewEx x)
        {
            //force traversing
            VisitElement(x.ClassNameRef);

            foreach (var param in x.CallSignature.Parameters)
            {
                VisitElement(param);
            }
        }
Пример #3
0
        // TODO: StaticMtdCall.typeRef and StaticFieldUse.typeRef contain information about class
        // on the left side, but it cannot be accessed, because typeRef is private field
        // public override void VisitDirectStMtdCall(DirectStMtdCall x)
        // public override void VisitIndirectStMtdCall(IndirectStMtdCall x)
        // public override void VisitDirectStFldUse(DirectStFldUse x)
        // public override void VisitIndirectStFldUse(IndirectStFldUse x)

        /// <inheritdoc />
        public override void VisitNewEx(NewEx x)
        {
            // Use of type can only be determined by DirectTypeRef
            if (x.ClassNameRef is DirectTypeRef)
            {
                var typeRef = x.ClassNameRef as DirectTypeRef;
                AddCoupling(typeRef);
            }

            base.VisitNewEx(x);
        }
Пример #4
0
        public override void VisitNewEx(NewEx x)
        {
            var arguments = CreateArguments(x.CallSignature);

            ValuePoint name = null;

            if (!(x.ClassNameRef is DirectTypeRef))
            {
                name = CreateRValue(x.ClassNameRef);
            }

            Result(new NewExPoint(x, name, arguments));
        }
Пример #5
0
 public override void VisitNewEx(NewEx x)
 {
     ConsumeToken(Tokens.T_NEW, "new");
     VisitElement(x.ClassNameRef);
     VisitCallSignature(x.CallSignature);
 }
Пример #6
0
 /// <summary>
 /// Visit "new" call parameters.
 /// </summary>
 /// <param name="x"></param>
 virtual public void VisitNewEx(NewEx x)
 {
     VisitElement(x.ClassNameRef);
     VisitList(x.CallSignature.Parameters);
 }
Пример #7
0
 override public void VisitNewEx(NewEx x)
 {
     _serializer.StartSerialize(typeof(NewEx).Name, SerializeSpan(x.Span));
     base.VisitNewEx(x);
     _serializer.EndSerialize();
 }
Пример #8
0
 /// <inheritdoc />
 public override void VisitNewEx(NewEx x)
 {
     RValueResult(x);
 }
Пример #9
0
        public static void PartOneStart()
        {
            int    amount   = 50;
            string splitter = "=";

            Program.center(amount, "Start of first Part", "*");
            Program.center(amount, "Индексаторы", splitter);
            Indexator indexator = new Indexator(5, "Default");

            IOService.ShowUserStringWithLineBreak(indexator[3]);
            indexator.show_array();

            Program.center(amount, "Перегрузка операторов", splitter);

            OperatorReboot operatorReboot1 = new OperatorReboot(1);
            OperatorReboot operatorReboot2 = new OperatorReboot(1);

            IOService.ShowUserStringWithLineBreak(operatorReboot1 + operatorReboot2);
            IOService.ShowUserStringWithLineBreak(operatorReboot1 > operatorReboot2);
            if (operatorReboot1)
            {
                IOService.ShowUserStringWithLineBreak("if (operatorReboot) {Size != 0}");
            }
            for (int i = 0; i < 10; i++, operatorReboot1++)
            {
                IOService.ShowUserStringWithLineBreak(operatorReboot1);
            }

            Program.center(amount, "Приведение типов", splitter);

            Truck  truck    = new Truck(500, 25000, 1000);
            Bus    bus      = new Bus(650, 30000, 40);
            object refernce = new Car(100, 10000, "Volvo");
            Car    carbus   = new Bus(300, 10000, 20);
            Car    cartruck = new Truck(330, 1233, 100);

            try
            {
                Car truckcar = truck;
                Bus newbus   = cartruck as Bus;
                if (carbus is Bus bus1)
                {
                    IOService.ShowUserStringWithLineBreak(bus1.get_info());
                }
                else
                {
                    IOService.ShowUserStringWithLineBreak("Not This Type!");
                }
                if (newbus == null)
                {
                    IOService.ShowUserStringWithLineBreak("Invalid Operation!");
                }
                //B obj1 = new A(); // Выдаёт ошибку
                //obj1.Foo();

                B obj2 = new B();
                obj2.Foo();

                A obj3 = new B();
                obj3.Foo();

                Car new_car_ref = (Car)refernce;
                IOService.ShowUserStringWithLineBreak(new_car_ref.get_info());
                refernce = (Truck)refernce;
            }
            catch (InvalidCastException e)
            {
                IOService.ShowUserStringWithLineBreak(e.Message);
            }

            Program.center(amount, "Переопределение, сокрытие", splitter);

            BaseClassOver baseClassOver = new NewClassOver();
            NewClassOver  newClassOver  = new NewClassOver();

            baseClassOver.Show();                            // !!!
            newClassOver.Show();                             // !!!

            BaseEx baseEx = new NewEx("ArtyomK", "Kolosov"); // !!!

            baseEx.Show();                                   // !!!
            NewEx newEx = new NewEx("ArtyomK", "Kolosov");

            newEx.Show();

            Program.center(amount, "Generics", splitter);

            Truck truck1 = new Truck(1000, 25000, 1000);
            Bus   bus2   = new Bus(500, 30000, 50);

            Shop <Car> shop = new Shop <Car>();

            shop.add_one_car(truck1);
            shop.add_one_car(bus2);

            shop.sell_one_car();
            shop.sell_one_car();

            shop.show_selled_info();

            Data <int> data1 = new Data <int>()
            {
                Id = 50
            };

            Data <string> data2 = new Data <string>()
            {
                Id = "StringType"
            };

            data1.show_id_type();
            data2.show_id_type();

            Program.center(amount, "End of first Part", "*");
            Console.Write("Press Any Key to Continue...\n\n");
            Console.ReadKey();
        }
Пример #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NewExPoint" /> class.
 /// </summary>
 /// <param name="newEx"><c>new</c> expression</param>
 /// <param name="name">Program point with expression that represents type name</param>
 /// <param name="arguments">Program points with arguments of the object constructor</param>
 internal NewExPoint(NewEx newEx, ValuePoint name, ValuePoint[] arguments)
     : base(null, newEx.CallSignature, arguments)
 {
     Name  = name;
     NewEx = newEx;
 }
Пример #11
0
 private static NewInstanceExpression ToNewInstanceExpression(NewEx e)
 {
     return(new NewInstanceExpression(FromTypeRef(e.ClassNameRef), ToCallSignature(e.CallSignature)));
 }
Пример #12
0
 /// <inheritdoc />
 override public void VisitNewEx(NewEx x)
 {
     result = new NewEx(x.Position, x.ClassNameRef, x.CallSignature.Parameters);
 }