45 lines
1.2 KiB
Plaintext
45 lines
1.2 KiB
Plaintext
package slangc.model;
|
|
|
|
import slangc.api.Reporter;
|
|
import slangc.parser.Branch;
|
|
import slangc.parser.Node;
|
|
import slangc.parser.NodeType;
|
|
|
|
public class ParameterModel extends LocalStorageModel {
|
|
|
|
public ParameterModel(MethodModel owner, int index, Branch source) {
|
|
super(owner, index, (Branch) source/*.getSubnode(2)*/, owner.resolveType(source.getSubnode(1)));
|
|
}
|
|
|
|
public boolean isVariableArguments() {
|
|
return source.getNodeType() == NodeType.VARIABLE_ARGUMENT_DECLARATION;
|
|
}
|
|
|
|
public void dump(Reporter reporter, String indent, String incr) {
|
|
reporter.note("DUMP", indent + "> '" + getName() + "', storage type " + getStorageType() + (isVariableArguments() ? " [varargs]" : ""));
|
|
}
|
|
|
|
@Override
|
|
public TypeModel getStorageType() {
|
|
if (isVariableArguments()) {
|
|
return super.getStorageType().getOrCreateArrayInstance();
|
|
} else {
|
|
return super.getStorageType();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public Node getNameNode() {
|
|
if (isVariableArguments()) {
|
|
return source.getSubnode(3);
|
|
} else {
|
|
return source.getSubnode(2);
|
|
}
|
|
}
|
|
|
|
//@Override
|
|
public StorageSlot.Kind getSlotKind() {
|
|
return StorageSlot.Kind.ARGUMENT;
|
|
}
|
|
}
|