예제 #1
0
        public static CIL_FunctionDef Descend()
        {
            List <string> par = new List <string> {
                "s", "p"
            };
            var lis = new CIL_StamentList(new List <CIL_AST_Node>()
            {
                new CIL_TypeOf("Object", "obj"),
                new CIL_Asig("result", "0", "Int"),
                new CIL_Label("descend.iterate"),
                new CIL_ExpBin("s", "p", "=", "exp0"),
                new CIL_If_Goto("exp0", "descend.end"),
                new CIL_ExpBin("p", "obj", "=", "exp0"),
                new CIL_If_Goto("exp0", "descend.wrong"),
                new CIL_ExpBin("p", "0", "=", "exp0"),
                new CIL_If_Goto("exp0", "descend.wrong"),
                new CIL_FatherType("p", "p2"),
                new CIL_Asig("p", "p2", "var"),
                new CIL_ExpBin("result", "1", "+", "result"),
                new CIL_Goto("descend.iterate"),
                new CIL_Label("descend.wrong"),
                new CIL_Asig("result", "10000", "Int"),
                new CIL_Label("descend.end"),
                new CIL_Return("result", "var")
            });

            return(new CIL_FunctionDef("descend", new CIL_Params(par), new CIL_Params(new List <string>()
            {
                "result", "exp0", "obj", "p2"
            }), lis));
        }
예제 #2
0
 public string Visit(CIL_StamentList node)
 {
     foreach (var item in node.ListNode)
     {
         item.Visit(this);
     }
     return("");
 }
예제 #3
0
        public static CIL_FunctionDef Abort()
        {
            List <string> par = new List <string> {
                "self"
            };
            var lis = new CIL_StamentList(new List <CIL_AST_Node>()
            {
                new CIL_Abort(),
                new CIL_Return("0", "Int")
            });

            return(new CIL_FunctionDef("Object.abort", new CIL_Params(par), new CIL_Params(new List <string>()), lis));
        }
예제 #4
0
        public static CIL_FunctionDef GeneratePrintInt()
        {
            List <string> par = new List <string> {
                "self", "x"
            };
            var lis = new CIL_StamentList(new List <CIL_AST_Node>()
            {
                new CIL_IOPrintInt("x"),
                new CIL_Return("self", "IO")
            });

            return(new CIL_FunctionDef("IO.out_int", new CIL_Params(par), new CIL_Params(new List <string>()), lis));
        }
예제 #5
0
        public static CIL_FunctionDef GenerateReadInt()
        {
            List <string> par = new List <string> {
                "self"
            };
            var lis = new CIL_StamentList(new List <CIL_AST_Node>()
            {
                new CIL_IOReadInt("x"),
                new CIL_Return("x", "var")
            });

            return(new CIL_FunctionDef("IO.in_int", new CIL_Params(par), new CIL_Params(new List <string>()
            {
                "x"
            }), lis));
        }
예제 #6
0
        public static CIL_FunctionDef StrSubstr()
        {
            List <string> par = new List <string> {
                "self", "i", "j"
            };
            var lis = new CIL_StamentList(new List <CIL_AST_Node>()
            {
                new CIL_StrStr("self", "i", "j", "x"),
                new CIL_Return("x", "var")
            });

            return(new CIL_FunctionDef("String.substr", new CIL_Params(par), new CIL_Params(new List <string>()
            {
                "x"
            }), lis));
        }
예제 #7
0
        public static CIL_FunctionDef TypeName()
        {
            List <string> par = new List <string> {
                "self"
            };
            var lis = new CIL_StamentList(new List <CIL_AST_Node>()
            {
                new CIL_TypeOf("self", "t"),
                new CIL_TypeName("t", "res", true),
                new CIL_Return("res", "var")
            });

            return(new CIL_FunctionDef("Object.type_name", new CIL_Params(par), new CIL_Params(new List <string>()
            {
                "res", "t"
            }), lis));
        }
예제 #8
0
        internal static CIL_FunctionDef Entry()
        {
            List <string> par = new List <string> {
            };
            var lis           = new CIL_StamentList(new List <CIL_AST_Node>()
            {
                new CIL_Allocate("Main", "self", false),
                new CIL_FunctionCall("main", new CIL_Params(new List <string> {
                    "self"
                }),
                                     "Main", "self", false, "Main")
            });

            return(new CIL_FunctionDef("main", new CIL_Params(par), new CIL_Params(new List <string> {
                "self"
            }), lis));
        }
예제 #9
0
        public static CIL_FunctionDef StrConcat()
        {
            List <string> par = new List <string> {
                "self", "other"
            };
            var lis = new CIL_StamentList(new List <CIL_AST_Node>()
            {
                new CIL_StrConcat("self", "other", "salva"),
                new CIL_Asig("self", "salva", "var"),
                new CIL_Return("self", "var")
            });

            return(new CIL_FunctionDef("String.concat", new CIL_Params(par), new CIL_Params(new List <string>()
            {
                "res", "salva"
            }), lis));
        }
예제 #10
0
 public string Visit(CIL_StamentList node)
 {
     throw new NotImplementedException();
 }