Search in sources :

Example 31 with Name

use of dyvil.lang.Name in project Dyvil by Dyvil.

the class REPLContext method getMethodMatches.

@Override
public void getMethodMatches(MatchList<IMethod> list, IValue receiver, Name name, ArgumentList arguments) {
    for (IMethod method : this.methods) {
        method.checkMatch(list, receiver, name, arguments);
    }
    if (name == null) {
        return;
    }
    final Name removeEq = Util.removeEq(name);
    IProperty property = this.properties.get(removeEq);
    if (property != null) {
        property.checkMatch(list, receiver, name, arguments);
    }
    final IField field = this.fields.get(removeEq);
    if (field != null) {
        property = field.getProperty();
        if (property != null) {
            property.checkMatch(list, receiver, name, arguments);
        }
    }
}
Also used : IProperty(dyvilx.tools.compiler.ast.field.IProperty) IMethod(dyvilx.tools.compiler.ast.method.IMethod) IField(dyvilx.tools.compiler.ast.field.IField) Name(dyvil.lang.Name)

Example 32 with Name

use of dyvil.lang.Name in project Dyvil by Dyvil.

the class REPLContext method setValue.

@Override
public void setValue(IValue value) {
    final Name name = Name.fromRaw("res" + this.resultIndex++);
    final REPLVariable field = new REPLVariable(this, name, value);
    this.initMember(field);
    this.currentClass.getBody().addDataMember(field);
    this.members.add(field);
}
Also used : Name(dyvil.lang.Name)

Example 33 with Name

use of dyvil.lang.Name in project Dyvil by Dyvil.

the class RenameCommand method execute.

@Override
public void execute(DyvilREPL repl, String argument) {
    final String[] split;
    if (argument == null || (split = argument.split(" ", 2)).length < 2) {
        repl.getErrorOutput().println(I18n.get("command.argument_list.invalid", this.getUsage()));
        return;
    }
    final Name memberName = Name.from(split[0]);
    final Name newName = Name.from(split[1]);
    final Map<Name, IField> fields = repl.getContext().getFields();
    final IField field = fields.remap(memberName, newName);
    if (field != null) {
        field.setName(newName);
        repl.getOutput().println(I18n.get("command.rename.success", memberName, newName));
    } else {
        repl.getOutput().println(I18n.get("command.rename.not_found", memberName));
    }
}
Also used : IField(dyvilx.tools.compiler.ast.field.IField) 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