Beispiel #1
0
 public override void DoVisit(AST_FuncDecl node)
 {
     Console.Write("(FUNC ");
     Console.Write(node.symbol.name);
     VisitChildren(node);
     Console.Write(")");
 }
Beispiel #2
0
        static public int GetTotalArgsNum(this AST_FuncDecl n)
        {
            var fparams = n.fparams();

            if (fparams.children.Count == 0)
            {
                return(0);
            }
            int num = fparams.children.Count;

            return(num);
        }
Beispiel #3
0
        public override void DoVisit(AST_FuncDecl ast)
        {
            UseCode();

            var fsymb = ast.symbol;

            func_decls.Push(fsymb);

            fsymb.ip_addr = GetCodeSize();

            Emit(Opcodes.InitFrame, new int[] { fsymb.local_vars_num + 1 /*cargs bits*/ });
            VisitChildren(ast);
            Emit(Opcodes.Return, null, ast.last_line_num);

            func_decls.Pop();

            UseInit();
        }
Beispiel #4
0
        static public int GetDefaultArgsNum(this AST_FuncDecl n)
        {
            var fparams = n.fparams();

            if (fparams.children.Count == 0)
            {
                return(0);
            }

            int num = 0;

            for (int i = 0; i < fparams.children.Count; ++i)
            {
                var fc = fparams.children[i].GetChildren();
                if (fc != null && fc.Count > 0)
                {
                    ++num;
                }
            }
            return(num);
        }
Beispiel #5
0
 static public AST_Tree block(this AST_FuncDecl n)
 {
     return(n.GetChildren()[1] as AST_Tree);
 }
Beispiel #6
0
 static public AST_Tree fparams(this AST_FuncDecl n)
 {
     return(n.GetChildren()[0] as AST_Tree);
 }
Beispiel #7
0
 public abstract void DoVisit(AST_FuncDecl ast);