001 /* 002 * The JastAdd Extensible Java Compiler (http://jastadd.org) is covered 003 * by the modified BSD License. You should have received a copy of the 004 * modified BSD license with this compiler. 005 * 006 * Copyright (c) 2005-2008, Torbjorn Ekman 007 * All rights reserved. 008 */ 009 010 aspect NodeConstructors { 011 public ParameterDeclaration.ParameterDeclaration(Access type, String name) { 012 this(new Modifiers(new List()), type, name); 013 } 014 public ParameterDeclaration.ParameterDeclaration(TypeDecl type, String name) { 015 this(new Modifiers(new List()), type.createQualifiedAccess(), name); 016 } 017 018 public PackageAccess.PackageAccess(String name, int start, int end) { 019 this(name); 020 this.start = this.Packagestart = start; 021 this.end = this.Packageend = end; 022 } 023 public TypeAccess.TypeAccess(String name, int start, int end) { 024 this(name); 025 this.start = this.IDstart = start; 026 this.end = this.IDend = end; 027 } 028 public PackageOrTypeAccess.PackageOrTypeAccess(String name, int start, int end) { 029 this(name); 030 this.start = this.IDstart = start; 031 this.end = this.IDend = end; 032 } 033 public AmbiguousAccess.AmbiguousAccess(String name, int start, int end) { 034 this(name); 035 this.start = this.IDstart = start; 036 this.end = this.IDend = end; 037 } 038 public VarAccess.VarAccess(String name, int start, int end) { 039 this(name); 040 this.start = this.IDstart = start; 041 this.end = this.IDend = end; 042 } 043 044 public TypeAccess.TypeAccess(String typeName) { 045 this("", typeName); 046 } 047 048 public IntegerLiteral.IntegerLiteral(int i) { 049 this(Integer.toString(i)); 050 } 051 052 public BooleanLiteral.BooleanLiteral(boolean b) { 053 this(b ? "true" : "false"); 054 } 055 056 public MethodAccess.MethodAccess(String name, List args, int start, int end) { 057 this(name, args); 058 setStart(start); 059 setEnd(end); 060 } 061 062 public ReturnStmt.ReturnStmt(Expr expr) { 063 this(new Opt(expr)); 064 } 065 066 public IfStmt.IfStmt(Expr cond, Stmt thenBranch) { 067 this(cond, thenBranch, new Opt()); 068 } 069 070 public IfStmt.IfStmt(Expr cond, Stmt thenBranch, Stmt elseBranch) { 071 this(cond, thenBranch, new Opt(elseBranch)); 072 } 073 074 public VariableDeclaration.VariableDeclaration(Access type, String name, Expr init) { 075 this(new Modifiers(new List()), type, name, new Opt(init)); 076 } 077 078 public VariableDeclaration.VariableDeclaration(Access type, String name) { 079 this(new Modifiers(new List()), type, name, new Opt()); 080 } 081 082 public ClassInstanceExpr.ClassInstanceExpr(Access type, List args) { 083 this(type, args, new Opt()); 084 } 085 086 public FieldDeclaration.FieldDeclaration(Modifiers m, Access type, String name) { 087 this(m, type, name, new Opt()); 088 } 089 090 public FieldDeclaration.FieldDeclaration(Modifiers m, Access type, String name, Expr init) { 091 this(m, type, name, new Opt(init)); 092 } 093 094 public static Stmt AssignExpr.asStmt(Expr left, Expr right) { 095 return new ExprStmt(new AssignSimpleExpr(left, right)); 096 } 097 }