2023-04-10 11:17:11 -04:00
|
|
|
/*
|
|
|
|
* Code formatter project
|
|
|
|
* CS 4481
|
|
|
|
*/
|
|
|
|
package submit.ast;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @author edwajohn
|
|
|
|
*/
|
|
|
|
public class Param extends AbstractNode implements Node {
|
|
|
|
|
|
|
|
private final VarType type;
|
|
|
|
private final String id;
|
|
|
|
private final boolean array;
|
|
|
|
|
|
|
|
public Param(VarType type, String id, boolean array) {
|
|
|
|
this.type = type;
|
|
|
|
this.id = id;
|
|
|
|
this.array = array;
|
|
|
|
}
|
|
|
|
|
2023-04-23 02:24:42 -04:00
|
|
|
public VarType getType() { return type; }
|
2023-04-10 11:17:11 -04:00
|
|
|
|
2023-04-23 02:24:42 -04:00
|
|
|
public String getId() { return id; }
|
2023-04-10 11:17:11 -04:00
|
|
|
|
2023-04-23 02:24:42 -04:00
|
|
|
public boolean isArray() { return array; }
|
2023-04-10 11:17:11 -04:00
|
|
|
|
|
|
|
public void toCminus(StringBuilder builder, final String prefix) {
|
|
|
|
if (isArray()) {
|
|
|
|
builder.append(type).append(" ").append(id).append("[]");
|
|
|
|
} else {
|
|
|
|
builder.append(type).append(" ").append(id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|