Package scriptingLanguage.variables

Source Code of scriptingLanguage.variables.JavaMethodClass

package scriptingLanguage.variables;

import java.util.ArrayList;

import scriptingLanguage.Token;
import scriptingLanguage.Type;
import scriptingLanguage.errors.UnexpectedTypeException;
import scriptingLanguage.frames.AbstractFrame;
import scriptingLanguage.frames.errors.FrameAccessException;

public class JavaMethodClass extends AbstractMethodClass {
 
  public JavaMethodClass(String name, Token source, AbstractClass<?> returnType, AbstractFrame frame, Type<?> tokenType) throws UnexpectedTypeException, FrameAccessException {
    super(name, source, returnType, frame, tokenType);
  }
 
  public JavaMethodClass(String name, Token source, AbstractClass<?> returnType, ArrayList<AbstractClass<?>> parameters, Type<?> tokenType) {
    super(name, source, returnType, parameters, tokenType);
  }
 
  public static JavaMethodClass make(AbstractClass<?> returnType, AbstractClass<?>... parameters) {
    String name = returnType.getName() + ":{";
    int i = 0;
    ArrayList<AbstractClass<?>> params = new ArrayList<>();
    for (; i < parameters.length - 1; i++) {
      params.add(parameters[i]);
      name = name + parameters[i] + ", ";
    }
    params.add(parameters[i]);
    name = name + parameters[i] + "}";
    return new JavaMethodClass(name, null, returnType, params, new Type<Object>(name));
  }
 
  @Override
  public Token makePlaceholder() {
    return new Token(new JavaMethod(this), getTokenType());
  }
 
  @Override
  public Variable<Token> clone() {
    return new JavaMethodClass(getName(), getSource(), getReturnType(), getParameters(), getTokenType());
  }
 
}
TOP

Related Classes of scriptingLanguage.variables.JavaMethodClass

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.