JFormalParameter.java |
1 // Copyright 2012- Bill Campbell, Swami Iyer and Bahar Akbal-Delibas 2 3 package jminusminus; 4 5 /** 6 * The AST node for a formal parameter declaration. 7 */ 8 class JFormalParameter extends JAST { 9 // Parameter name. 10 private String name; 11 12 // Parameter type. 13 private Type type; 14 15 /** 16 * Constructs an AST node for a formal parameter declaration. 17 * 18 * @param line line in which the parameter occurs in the source file. 19 * @param name parameter name. 20 * @param type parameter type. 21 */ 22 public JFormalParameter(int line, String name, Type type) { 23 super(line); 24 this.name = name; 25 this.type = type; 26 } 27 28 /** 29 * Returns the parameter's name. 30 * 31 * @return the parameter's name. 32 */ 33 public String name() { 34 return name; 35 } 36 37 /** 38 * Returns the parameter's type. 39 * 40 * @return the parameter's type. 41 */ 42 public Type type() { 43 return type; 44 } 45 46 /** 47 * Sets the parameter's type to the specified type, and returns the new type. 48 * 49 * @param newType the new type. 50 * @return return the new type. 51 */ 52 public Type setType(Type newType) { 53 return type = newType; 54 } 55 56 /** 57 * {@inheritDoc} 58 */ 59 public JAST analyze(Context context) { 60 // Nothing here. 61 return this; 62 } 63 64 /** 65 * {@inheritDoc} 66 */ 67 public void codegen(CLEmitter output) { 68 // Nothing here. 69 } 70 } 71