Esempio n. 1
0
        public void Process(statement st)
        {
            if (!(st is yield_node || st is labeled_statement))
            {
                curStatList.Add(st);
            }
            if (st is yield_node)
            {
                var yn = st as yield_node;
                curState += 1;
                curStatList.AddMany(
                    new assign(Consts.Current, yn.ex),
                    new assign(Consts.State, curState),
                    new assign("Result", true),
                    new procedure_call("exit")
                    );

                curStatList = new statement_list();
                case_variant cv = new case_variant(new expression_list(new int32_const(curState)), curStatList);
                cas.conditions.variants.Add(cv);
            }
            if (st is labeled_statement)
            {
                var ls = st as labeled_statement;
                curStatList = StatListAfterCase;
                curStatList.Add(new labeled_statement(ls.label_name));
                Process(ls.to_statement);
            }
        }
Esempio n. 2
0
        public void Transform()
        {
            cas = new case_node(new ident(Consts.State));

            curStatList = new statement_list();
            case_variant cv = new case_variant(new expression_list(new int32_const(curState)), curStatList);

            cas.conditions.variants.Add(cv);

            foreach (var st in stl.subnodes)
            {
                Process(st);
            }

            stl.subnodes = BaseChangeVisitor.SeqStatements(cas, StatListAfterCase).ToList();
            //statement_list res = new statement_list(cas);
            res = stl;
        }
Esempio n. 3
0
 public override void visit(case_variant _case_variant)
 {
 }
Esempio n. 4
0
 public virtual void visit(case_variant _case_variant)
 {
     DefaultVisit(_case_variant);
 }
Esempio n. 5
0
		public virtual void post_do_visit(case_variant _case_variant)
		{
		}
Esempio n. 6
0
		public override void visit(case_variant _case_variant)
		{
			DefaultVisit(_case_variant);
			pre_do_visit(_case_variant);
			visit(case_variant.conditions);
			visit(case_variant.exec_if_true);
			post_do_visit(_case_variant);
		}
Esempio n. 7
0
 public virtual void visit(case_variant _case_variant)
 {
 }
Esempio n. 8
0
 public override void visit(case_variant _case_variant)
 {
     throw new NotImplementedException();
 }
Esempio n. 9
0
        // frninja 30/05/16
        public override void visit(case_node csn)
        {
            var b = HasStatementVisitor <yield_node> .Has(csn);

            if (!b)
            {
                return;
            }

            /*
             *
             * case i of
             *   cv1: bla1;
             *   cv2: bla2;
             *   ..
             *   cvN: blaN;
             * else: bla_else;
             *
             * --->
             *
             * if i satisfy cv1
             *   then bla1
             * else if i satisfy cv2
             *   then bla2
             * ..
             * else if i satisfy cvN
             *   then blaN
             * else bla_else
             *
             */

            if_node   currentIfNode       = null;
            statement currentIfElseClause = (csn.else_statement != null) ? csn.else_statement :new statement_list(new empty_statement());;

            for (int i = csn.conditions.variants.Count - 1; i >= 0; --i)
            {
                case_variant cv = csn.conditions.variants[i];

                ProcessNode(cv.exec_if_true);

                var ifCondition = this.CreateConditionFromCaseVariant(csn.param, cv.conditions);
                currentIfNode       = new if_node(ifCondition, new statement_list(cv.exec_if_true), new statement_list(currentIfElseClause));
                currentIfElseClause = currentIfNode;
            }

            if_node finalIfNode = currentIfNode;

            if (finalIfNode == null) // SSM - значит, в цикл мы не заходили и у case отсутствуют все ветви кроме else - поскольку yieldы в case есть
            {
                ReplaceStatement(csn, csn.else_statement);
            }
            else
            {
                ReplaceStatement(csn, finalIfNode);
            }

            if (finalIfNode != null)
            {
                visit(finalIfNode);
            }
        }
Esempio n. 10
0
		public virtual void visit(case_variant _case_variant)
		{
		}
		public virtual void visit(case_variant _case_variant)
		{
			DefaultVisit(_case_variant);
		}
Esempio n. 12
0
 public override void visit(case_variant _case_variant)
 {
     prepare_node(_case_variant.conditions, "conditions");
     prepare_node(_case_variant.exec_if_true, "statement");
 }
Esempio n. 13
0
		public override void visit(case_variant _case_variant)
		{
			executer.visit(_case_variant);
			if (_case_variant.conditions != null)
				this.visit((dynamic)_case_variant.conditions);
			if (_case_variant.exec_if_true != null)
				this.visit((dynamic)_case_variant.exec_if_true);
			if (_case_variant.attributes != null)
				this.visit((dynamic)_case_variant.attributes);
		}