Exemplo n.º 1
0
 public addressed_value Into(addressed_value x, addressed_value v) // При возникновении новой конструкции в грамматике variable добавить обработку сюда
 {
     if (v.GetType() == typeof(dot_question_node))
     {
         var vv  = v as dot_question_node;
         var res = new dot_question_node(Into(x, vv.left), vv.right, x.source_context);
         return(res);
     }
     else if (v.GetType() == typeof(dot_node))
     {
         var vv  = v as dot_node;
         var res = new dot_node(Into(x, vv.left), vv.right, x.source_context);
         return(res);
     }
     else if (v.GetType() == typeof(indexer))
     {
         var vv  = v as indexer;
         var res = new indexer(Into(x, vv.dereferencing_value), vv.indexes, x.source_context);
         return(res);
     }
     else if (v.GetType() == typeof(slice_expr))
     {
         var vv  = v as slice_expr;
         var res = new slice_expr(Into(x, vv.dereferencing_value), vv.from, vv.to, vv.step, x.source_context);
         return(res);
     }
     else if (v.GetType() == typeof(slice_expr_question))
     {
         var vv  = v as slice_expr_question;
         var res = new slice_expr_question(Into(x, vv.dereferencing_value), vv.from, vv.to, vv.step, x.source_context);
         return(res);
     }
     else if (v.GetType() == typeof(method_call))
     {
         var vv  = v as method_call;
         var res = new method_call(Into(x, vv.dereferencing_value), vv.parameters, x.source_context);
         return(res);
     }
     else if (v.GetType() == typeof(roof_dereference))
     {
         var vv  = v as roof_dereference;
         var res = new roof_dereference(Into(x, vv.dereferencing_value), x.source_context);
         return(res);
     }
     else if (v.GetType() == typeof(ident_with_templateparams))
     {
         var vv  = v as ident_with_templateparams;
         var res = new ident_with_templateparams(Into(x, vv.name), vv.template_params, x.source_context);
         return(res);
     }
     else
     {
         var res = new dot_node(x, v, x.source_context);
         return(res);
     }
 }
Exemplo n.º 2
0
        private expression GetCollectionItemsEqualCheckAfterGap(addressed_value matchingExpression,
                                                                List <pattern_parameter> toCompare,
                                                                CollectionDesugaringResult desugaringResult)
        {
            var        elemFromTail = 1;
            expression equalChecks  = null;

            foreach (var param in toCompare)
            {
                var indexerCall = new indexer(
                    matchingExpression,
                    new expression_list(
                        new bin_expr(
                            new method_call(
                                new dot_node(
                                    matchingExpression,
                                    new ident("Count", matchingExpression.source_context)),
                                new expression_list()),
                            new int32_const(elemFromTail, matchingExpression.source_context),
                            Operators.Minus),
                        matchingExpression.source_context),
                    matchingExpression.source_context);

                if (param is const_pattern_parameter constParam)
                {
                    var eqParams = new expression_list(
                        new List <expression>()
                    {
                        indexerCall,
                        constParam.const_param
                    }
                        );

                    var equalCall = new method_call(
                        new dot_node(
                            new ident("object"),
                            new ident("Equals")),
                        eqParams,
                        matchingExpression.source_context
                        );

                    equalChecks = equalChecks == null ? (expression)equalCall : bin_expr.LogicalAnd(equalChecks, equalCall);
                    desugaringResult.ElemTypeChecks.Add(GetTypeCompatibilityCheck(indexerCall, constParam.const_param));
                }

                if (param is collection_pattern_var_parameter varParam)
                {
                    desugaringResult.VarParametersDeclarations.Add(
                        new var_statement(varParam.identifier, indexerCall));
                }

                ++elemFromTail;
            }
            return(equalChecks);
        }
Exemplo n.º 3
0
        private expression GetCollectionItemsEqualCheckBeforeGap(addressed_value matchingExpression,
                                                                 List <pattern_parameter> toCompare,
                                                                 CollectionDesugaringResult desugaringResult)
        {
            var        fromIndex   = 0;
            expression equalChecks = null;

            foreach (var param in toCompare)
            {
                if (param is const_pattern_parameter constParam)
                {
                    var indexerCall = new indexer(
                        matchingExpression,
                        new expression_list(
                            new int32_const(fromIndex, matchingExpression.source_context),
                            matchingExpression.source_context),
                        matchingExpression.source_context);

                    var eqParams = new expression_list(
                        new List <expression>()
                    {
                        indexerCall,
                        constParam.const_param
                    }
                        );

                    var equalCall = new method_call(
                        new dot_node(
                            new ident("object"),
                            new ident("Equals")),
                        eqParams,
                        matchingExpression.source_context
                        );

                    equalChecks = equalChecks == null ? (expression)equalCall : bin_expr.LogicalAnd(equalChecks, equalCall);
                    desugaringResult.ElemTypeChecks.Add(GetTypeCompatibilityCheck(indexerCall, constParam.const_param));
                }

                if (param is collection_pattern_var_parameter varParam)
                {
                    desugaringResult.VarParametersDeclarations.Add(
                        new var_statement(varParam.identifier,
                                          GetIndexerCallForCollectionPattern(matchingExpression as addressed_value, fromIndex)));
                }
                ++fromIndex;
            }
            return(equalChecks);
        }
    // Start is called before the first frame update
    void Start()
    {
        //typ zmiennej nazwa;
        //deklaracja
        int a;

        //inicjalizacja
        a = 10;
        //2 w 1
        int b = 15;

        //wyświetlanie na konsoli
        Debug.Log(a);

        float f = 1.5f;  // jak jest kropka to dopisujemy f

        f = 4;
        bool   log = true; //false  //zmienna logiczna
        string str = "jakiś napis";

        Debug.Log("f: " + f + " log: " + log + " str: " + str);

        Debug.Log(a / b);
        Debug.Log(a / f);
        Debug.Log(Mathf.Sqrt(2));

        //oberacje logiczne
        Debug.Log(a == b); //równe
        Debug.Log(a != b); //różne
        Debug.Log(a > b);
        Debug.Log(a >= b);
        Debug.Log(a < b);
        Debug.Log(a <= b);

        //instrukcja warunkowa
        //if (warunek_logiczny){
        //}

        if (a == b)
        {
            Debug.Log("Tak,jest taka sama!");
        }
        else if (a < b)
        {
            Debug.Log("a < b");
        }
        else
        {
            Debug.Log("żadne z powyższych");
        }
        //koniuńkcja  oba muszą być prawdziwe
        Debug.Log((a != b) && (a > 0));

        if (a != b)
        {
            if (a > 0)
            {
                //kod
            }
        }

        if ((a != b) && (a > 0))
        {
            //kod
        }

        //alternatywa  tylko jedno musi być prawdziwe
        //brzydka wersja XD

        indexer hp = 2, time = 1;

        if (hp <= 0)
        {
            if (!amulet)
            {
                //
            }
            else
            {
            }
        }

        // ładna wersja XDDDD
        if (hp <= 0 || time <= 0)
        {
            if (!amulet)
            {
            }
            else
            {
            }
        }
    }
Exemplo n.º 5
0
 public override void visit(indexer _indexer)
 {
 }
Exemplo n.º 6
0
 public virtual void visit(indexer _indexer)
 {
     DefaultVisit(_indexer);
 }
Exemplo n.º 7
0
		public virtual void post_do_visit(indexer _indexer)
		{
		}
Exemplo n.º 8
0
		public override void visit(indexer _indexer)
		{
			DefaultVisit(_indexer);
			pre_do_visit(_indexer);
			visit(indexer.indexes);
			post_do_visit(_indexer);
		}
Exemplo n.º 9
0
 public virtual void visit(indexer _indexer)
 {
 }
Exemplo n.º 10
0
 public override void visit(indexer _indexer)
 {
     _indexer.dereferencing_value.visit(this);
     _indexer.indexes.visit(this);
 }
Exemplo n.º 11
0
		public virtual void visit(indexer _indexer)
		{
		}
		public virtual void visit(indexer _indexer)
		{
			DefaultVisit(_indexer);
		}
Exemplo n.º 13
0
        private expression GetIndexerCallForCollectionPattern(addressed_value matchingExpression, int ind)
        {
            var indexerCall = new indexer(matchingExpression, new int32_const(ind), matchingExpression.source_context);

            return(indexerCall);
        }
Exemplo n.º 14
0
 public override void visit(indexer _indexer)
 {
     prepare_node(_indexer.dereferencing_value, "array");
     prepare_node(_indexer.indexes, "indexers");
 }
Exemplo n.º 15
0
		public override void visit(indexer _indexer)
		{
			executer.visit(_indexer);
			if (_indexer.indexes != null)
				this.visit((dynamic)_indexer.indexes);
			if (_indexer.dereferencing_value != null)
				this.visit((dynamic)_indexer.dereferencing_value);
			if (_indexer.attributes != null)
				this.visit((dynamic)_indexer.attributes);
		}