Beispiel #1
0
        public override FieldInfo Compile(LoadClasses load, Scop scop, Tree tree)
        {
            var      hasElse = tree.Count == 3;
            AsmLabel debElse = load.Optimum.SetLabel(null, false),
                     finElse = load.Optimum.SetLabel(null, false);

            var condition = load.Compile(scop, tree[0]);

            if (condition == null || condition.Return != Assembly.Bool)
            {
                load.LogIn(scop, tree, condition, "Condition Value Must be Of Type System.Bool");
            }

            load.Add("test", condition, FieldInfo.Immediate(0));
            load.Optimum.SetGoto("jne", debElse);
            if (tree[1].GeneratedBy != null)
            {
                tree[1].GeneratedBy.Compile(load, scop, tree[1]);
                load.Optimum.SetLabel(debElse);
                if (!hasElse)
                {
                    return(null);
                }
                load.Optimum.SetGoto("jmp", finElse);
                tree[2].GeneratedBy.Compile(load, scop, tree[2]);
                load.Optimum.SetLabel(finElse);
            }
            else
            {
                load.Optimum.SetLabel(debElse);
            }
            return(null);
        }
Beispiel #2
0
        public override FieldInfo Compile(LoadClasses load, Scop scop, Tree tree)
        {
            tree[0].GeneratedBy.Compile(load, scop, tree[0]);
            AsmLabel
                label1 = load.Optimum.SetLabel(null, true),
                label2 = load.Optimum.SetLabel(null, false);

            var condition = tree[1].GeneratedBy.Compile(load, scop, tree[1]);

            if (condition == null || condition.Return != Assembly.Bool)
            {
                load.LogIn(scop, tree, condition, "Condition Value Must be Of Type System.Bool");
            }
            load.Add("test", condition, FieldInfo.Immediate(0));
            load.Optimum.SetGoto("jne", label2);
            tree[3].GeneratedBy.Compile(load, scop, tree[3]);
            tree[2].GeneratedBy.Compile(load, scop, tree[2]);
            load.Optimum.SetGoto("jmp", label1);
            load.Optimum.SetLabel(label2);
            return(null);
        }