Beispiel #1
0
        public override D.CsStmt Concretize()
        {
            var result = new D.CsStmtList();
            var kw     = "if";

            foreach (var cond in _conditions)
            {
                var if1 = new D.CsComplexStmt
                {
                    Before = $"{kw} ({cond})"
                };
                if1.AddCode(_thenBranches[cond].Select(x => x.Concretize()));
                result.AddStmt(if1);
                kw = "else if";
            }

            if (_elseBranch.Count <= 0)
            {
                return(result);
            }
            {
                var if2 = new D.CsComplexStmt
                {
                    Before = "else"
                };
                if2.AddCode(_elseBranch.Select(x => x.Concretize()));
                result.AddStmt(if2);
            }
            return(result);
        }
Beispiel #2
0
        public override D.CsStmt Concretize()
        {
            D.CsComplexStmt switch1 = new D.CsComplexStmt();
            switch1.Before = $"switch ({Expression})";

            var cases = Branches.Keys.ToList();

            cases.Sort((x, y) => y.Length - x.Length);

            foreach (var case1 in cases)
            {
                var case2 = new D.CsComplexStmt();
                case2.Embrace = false; // no curlies
                case2.Before  = $"case {case1}:";
                case2.AddCode(Branches[case1].Select(x => x.Concretize()));
                case2.AddCode("break");
                switch1.AddCode(case2);
            }
            // default
            if (DefaultBranch.Count > 1)
            {
                var case3 = new D.CsComplexStmt();
                case3.Embrace = false; // no curlies
                case3.Before  = "default:";
                case3.AddCode(DefaultBranch.Select(x => x.Concretize()));
                case3.AddCode("break");
                switch1.AddCode(case3);
            }

            return(switch1);
        }
Beispiel #3
0
        public override D.CsStmt Concretize()
        {
            var lambda = new D.CsComplexStmt();

            lambda.Before = $"Schedule(typeof({Type}), {Var} =>";
            lambda.After  = ");";
            lambda.AddCode(Code.Select(x => x.Concretize()));
            return(lambda);
        }
Beispiel #4
0
        public override D.CsStmt Concretize()
        {
            var result = new D.CsStmtList();
            var kw     = "if";

            foreach (var cond in Conditions)
            {
                var if1 = new D.CsComplexStmt();
                if1.Before = $"{kw} ({cond})";
                if1.AddCode(ThenBranches[cond].Select(x => x.Concretize()));
                result.Stmts.Add(if1);
                kw = "else if";
            }
            if (ElseBranch.Count > 0)
            {
                var if2 = new D.CsComplexStmt();
                if2.Before = "else";
                if2.AddCode(ElseBranch.Select(x => x.Concretize()));
                result.Stmts.Add(if2);
            }
            return(result);
        }