Search in sources :

Example 1 with Name

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;
}
Also used : ExternalTypeParameter(dyvilx.tools.compiler.ast.external.ExternalTypeParameter) Name(dyvil.lang.Name)

Example 2 with Name

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);
    }
}
Also used : IParameter(dyvilx.tools.compiler.ast.parameter.IParameter) Name(dyvil.lang.Name)

Example 3 with Name

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);
}
Also used : IClass(dyvilx.tools.compiler.ast.classes.IClass) IHeaderUnit(dyvilx.tools.compiler.ast.header.IHeaderUnit) Name(dyvil.lang.Name)

Example 4 with Name

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));
    }
}
Also used : IField(dyvilx.tools.compiler.ast.field.IField) Name(dyvil.lang.Name)

Example 5 with Name

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;
}
Also used : CodeMethod(dyvilx.tools.compiler.ast.method.CodeMethod) CodeParameter(dyvilx.tools.compiler.ast.parameter.CodeParameter) Name(dyvil.lang.Name)

Aggregations

Name (dyvil.lang.Name)33 Annotation (dyvilx.tools.compiler.ast.attribute.annotation.Annotation)4 CodeAnnotation (dyvilx.tools.compiler.ast.attribute.annotation.CodeAnnotation)4 AnnotationParser (dyvilx.tools.compiler.parser.annotation.AnnotationParser)4 TypeParser (dyvilx.tools.compiler.parser.type.TypeParser)4 IClass (dyvilx.tools.compiler.ast.classes.IClass)3 IField (dyvilx.tools.compiler.ast.field.IField)3 IParameter (dyvilx.tools.compiler.ast.parameter.IParameter)3 IType (dyvilx.tools.compiler.ast.type.IType)3 AttributeList (dyvilx.tools.compiler.ast.attribute.AttributeList)2 Modifier (dyvilx.tools.compiler.ast.attribute.modifiers.Modifier)2 IValue (dyvilx.tools.compiler.ast.expression.IValue)2 IOperator (dyvilx.tools.compiler.ast.expression.operator.IOperator)2 IDataMember (dyvilx.tools.compiler.ast.field.IDataMember)2 IProperty (dyvilx.tools.compiler.ast.field.IProperty)2 IMethod (dyvilx.tools.compiler.ast.method.IMethod)2 ArgumentList (dyvilx.tools.compiler.ast.parameter.ArgumentList)2 CodeParameter (dyvilx.tools.compiler.ast.parameter.CodeParameter)2 NamedType (dyvilx.tools.compiler.ast.type.raw.NamedType)2 ExpressionParser (dyvilx.tools.compiler.parser.expression.ExpressionParser)2