public CodeObject VisitMethodDecl(Ast.MethodDecl ast) { CodeMemberMethod codemethod = new CodeMemberMethod(); codemethod.Name = ast.MethodInfo.Name; codemethod.ReturnType = new CodeTypeReference(ast.MethodInfo.ReturnType.Name); codemethod.Attributes = MemberAttributes.Public; //parameters foreach (var p in ast.MethodInfo.Parameters) { codemethod.Parameters.Add(new CodeParameterDeclarationExpression( new CodeTypeReference(p.Type.Name), p.Name)); } //statements foreach (var s in ast.Statements) { var scol = RequiresStatementCollection(s, true); foreach (var statement in scol) { codemethod.Statements.Add(statement); } } //return method codemethod.Statements.Add(new CodeMethodReturnStatement(Visit(ast.ReturnExpression) as CodeExpression)); return(codemethod); }
public virtual AstNode VisitMethodDecl(MethodDecl ast) { return(ast); }