use of dyvil.lang.Name in project Dyvil by Dyvil.
the class ClassFormat method readGeneric.
private static int readGeneric(String desc, int start, ITypeParametric generic) {
int index = desc.indexOf(':', start);
final Name name = Name.fromRaw(desc.substring(start, index));
final ExternalTypeParameter typeParam = new ExternalTypeParameter(generic, name);
if (desc.charAt(index + 1) == ':') {
// name::
index++;
}
while (desc.charAt(index) == ':') {
index = readTyped(desc, index + 1, typeParam::addUpperBound, true);
}
generic.getTypeParameters().add(typeParam);
return index;
}
use of dyvil.lang.Name in project Dyvil by Dyvil.
the class SimpleMethodVisitor method visitParameter.
@Override
public void visitParameter(String name, int modifiers) {
final IParameter parameter = this.method.getExternalParameterList().get(this.parameterIndex);
if (parameter == null) {
return;
}
this.parameterIndex++;
if (name != null && !name.isEmpty()) {
final Name name1 = Name.fromQualified(name);
parameter.setName(name1);
parameter.setLabel(name1);
}
if (modifiers != 0) {
if ((modifiers & Modifiers.ACC_VARARGS) != 0) {
// add the internal bitflag for varargs parameters
modifiers |= Modifiers.VARARGS;
}
parameter.getAttributes().addFlag(modifiers);
}
}
use of dyvil.lang.Name in project Dyvil by Dyvil.
the class Package method resolveClass.
@Override
public IClass resolveClass(Name name) {
for (IHeaderUnit c : this.headers) {
if (c.getName() == name) {
return c.getClass(name);
}
}
for (IClass c : this.classes) {
if (c.getName() == name) {
return c;
}
}
String qualifiedName = name.qualified;
// Check for inner / nested / anonymous classes
final int cashIndex = qualifiedName.lastIndexOf('$');
if (cashIndex < 0) {
return this.loadClass(name, qualifiedName);
}
final Name outerName = Name.fromRaw(qualifiedName.substring(0, cashIndex));
final Name innerName = Name.fromRaw(qualifiedName.substring(cashIndex + 1));
final IClass outerClass = this.resolveClass(outerName);
if (outerClass != null) {
return outerClass.resolveClass(innerName);
}
return this.loadClass(name, qualifiedName);
}
use of dyvil.lang.Name in project Dyvil by Dyvil.
the class VariablesCommand method execute.
@Override
public void execute(DyvilREPL repl, String args) {
final Map<Name, IField> fieldMap = repl.getContext().getFields();
if (fieldMap.isEmpty()) {
repl.getOutput().println(I18n.get("command.variables.none"));
return;
}
final IField[] fields = fieldMap.toValueArray(IField.class);
Arrays.sort(fields, MemberSorter.MEMBER_COMPARATOR);
for (IField field : fields) {
repl.getOutput().println(Util.memberSignatureToString(field, null));
}
}
use of dyvil.lang.Name in project Dyvil by Dyvil.
the class Property method initSetter.
@Override
public IMethod initSetter() {
if (this.setter != null) {
return this.setter;
}
final Name name = Name.from(this.name.unqualified + "_=", this.name.qualified + "_$eq");
this.setter = new CodeMethod(this.enclosingClass, name, Types.VOID);
this.setter.setPosition(this.position);
this.setterParameter = new CodeParameter(this.setter, this.position, Names.newValue, this.type);
this.setter.getParameters().add(this.setterParameter);
return this.setter;
}
Aggregations