private static Param match_param() { var param = new Param { match = Type.Match(), type = null, name = Look.ToString() }; Match(ID); return(param); }
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("--------------------------"); }
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); }