Пример #1
0
 public override FieldInfo Compile(LoadClasses load, Scop scop, Tree tree)
 {
     if (tree.Method == null)
     {
         tree.Method = load.GetMethod(tree[0], tree[1].Children);
     }
     if (tree.Method == null)
     {
         load.LogIn(scop, tree, this, "Function(" + tree[0].Content + ") Entrer cannot be found");
         return(null);
     }
     if (tree.Method.ISCPUMethod)
     {
         var parm = new List <FieldInfo>(2);
         foreach (Tree e in tree[1])
         {
             parm.Add(load.Compile(scop, e));
         }
     }
     foreach (Tree e in tree[1])
     {
         var z = load.Compile(scop, e);
         load.Optimum.PushParam(z);
     }
     load.Optimum.Call(tree.Method);
     return(tree.Membre = RegInfo.eax);
 }
Пример #2
0
        public override FieldInfo Compile(LoadClasses load, Scop scop, Tree tree)
        {
            if (!new TypeCalc(load.ByteCodeMapper).CalcTypes(tree))
            {
                load.LogIn(scop, tree, this, "there are undefined variables or methods in expression : " + tree.Content);
                return(tree[0].Membre);
            }
            tree.Parcure(tree.Parent, (MethodInfo)scop);
            var m = load.Compile(scop, tree[0]);
            var n = tree.Count == 3 ? load.Compile(scop, tree[2]) : null;

            if (tree.Method is CPUMethodInfo)
            {
                var e = Qs.Pdb.CPU.CPUType.Call(load, scop, tree.Membre, tree.Method, tree[0].Membre, tree[2].Membre);
                //TODO :Obsolete load.Caller.Call(scop, tree.Method, m, n, tree.Membre);
            }
            else
            {
                load.Optimum.PushParam(m);
                if (n != null)
                {
                    load.Optimum.PushParam(n);
                }
                load.Optimum.Call(tree.Method);
            }
            return(tree.Membre);
        }
Пример #3
0
        public override FieldInfo Compile(LoadClasses load, Scop scop, Tree tree)
        {
            var ret = load.Compile(scop, tree[1]); //.GeneratedBy.Compile(load, scop, tree[0]);

            load.Return(scop, ret);
            return(null);
        }
Пример #4
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);
        }
Пример #5
0
        public override FieldInfo Compile(LoadClasses load, Scop scop, Tree tree)
        {
            if (tree.Count == 3 && tree[2].Kind == Kind.Numbre)
            {
            }
            var dataPortor = scop as DataPortor;
            var l          = load.SetVariable(dataPortor, tree);

            tree[1].BaseCall = tree.BaseCall = dataPortor;
            tree[1].Type     = tree.Type = l.Return;
            tree[1].Membre   = tree.Membre = l;
            tree[1].Compiled = true;
            tree.Compiled    = true;
            if (tree.Children.Count == 2)
            {
                return(null);
            }
            var fieldInfo = load.Compile(scop, tree[2]);

            if (l != fieldInfo)
            {
                load.Optimum.Assign(l, fieldInfo);
            }
            return(l);
        }
Пример #6
0
        public override FieldInfo Compile(LoadClasses load, Scop scop, Tree tree)
        {
            var
                label1 = load.Optimum.SetLabel(null, true);

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

            if (condition == null || condition.Return != Assembly.Bool)
            {
                load.LogIn(scop, tree, tree[1], "Condition Value Must be Of Type System.Bool");
            }
            load.Add("test", condition, FieldInfo.Immediate(0));
            load.Optimum.SetGoto("jne", label1);
            return(RegInfo.eax);
        }
Пример #7
0
        public override FieldInfo Compile(LoadClasses load, Scop scop, Tree tree)
        {
            var dataPortor = scop as DataPortor;
            var l          = load.SetVariable(dataPortor, tree[0]);

            tree.BaseCall = dataPortor;
            tree.Type     = l.Return;
            tree.Membre   = l;
            tree.Compiled = true;
            if (tree.Children.Count == 2)
            {
                return(null);
            }
            var fieldInfo = load.Compile(scop, tree[1]);

            return(load.Add("mov", l, fieldInfo));
        }
Пример #8
0
        public static void _Test()
        {
            while (true)
            {
                __test();

                var parse = new BasicParse {
                    Pile = new Pile(Prg_Example)
                };
                var parent = new Tree(parse.Pile, null, Kind.Program);
                var glob   = CurrentScop.Initialize("globe");
                Update(parse);
                var s = new Space(parse);
                if (s.Parse(parent))
                {
                    var byteCode = new ByteCodeMapper(glob);
                    var load     = new LoadClasses(byteCode);
                    load.Add(parent[0]);
                    load.Compile();
                    var inst = load.Optimum.Instructs;
                    var sw   = new IO.Stream.StreamWriter(true);
                    for (int i = 0; i < inst.Count; i++)
                    {
                        inst[i].Push(sw);
                    }
                    var tt = inst[0].Length;
                    var sr = new IO.Stream.StreamReader(sw);
                    for (int i = 0; i < inst.Count; i++)
                    {
                        var x     = Instruct.Pop(sr);
                        var isieq = x.Equals(inst[i]);
                        if (!isieq)
                        {
                        }
                    }
                }
            }
        }
Пример #9
0
        public override FieldInfo Compile(LoadClasses load, Scop scop, Tree tree)
        {
            AsmLabel
                label1 = load.Optimum.SetLabel(null, true),
                label2 = 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", label2);
            var bloc = tree[1];

            if (tree.Count == 2 && bloc.GeneratedBy != null)
            {
                bloc.GeneratedBy.Compile(load, scop, bloc);
            }
            load.Optimum.SetGoto("jmp", label1);
            load.Optimum.SetLabel(label2);
            return(RegInfo.eax);
        }