Beispiel #1
0
        private static Param match_param()
        {
            var param = new Param
            {
                match = Type.Match(),
                type  = null,
                name  = Look.ToString()
            };

            Match(ID);
            return(param);
        }
Beispiel #2
0
 public void Generate(Class @class)
 {
     @class.current_method = this;
     if (return_match != null && @return == null)
     {
         @return = Phrase.GetEnd(return_match).type;
     }
     statements.Generate(this);
     Debugger.Message("-----" + name + "生成的字节码-------");
     for (var index = 0; index < locals.Count; index++)
     {
         Debugger.Message(".[" + index + "]" + locals[index].type + " " + locals[index].name);
     }
     foreach (var code in codes)
     {
         Debugger.Message(code.ToString());
     }
     Debugger.Message("--------------------------");
 }
Beispiel #3
0
        public static Method Match(Class @class)
        {
            var function = new Method()
            {
                @class = @class
            };

            Match(FUNC);
            function.name = Look.ToString();
            Match(ID);
            Match('(');
            if (Check(BASIC) || Check(ID))
            {
                function.return_match = Type.Match();
            }
            else
            {
                function.@return = Type.Void;
            }

            Match('|');
            if (Check(BASIC) || Check(ID))
            {
                [email protected](match_param());
                while (Check(','))
                {
                    Move();
                    [email protected](match_param());
                }
            }
            Match(')');
            Match('{');
            function.statements = Stmts.Match();
            Match('}');
            return(function);
        }