mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-12 16:27:40 +00:00
- Expanded MFR support to 1.7.10 - Improved MFR implementation, no longer uses reflection. Yay! - Registration of a class registry now allows a description to be shown when loaded. Handy to check if mod support loaded properly. - Fixed a few bugs in MFR support - Fixed 1.7.2 IC2 item bracket handler
82 lines
2.5 KiB
Java
82 lines
2.5 KiB
Java
/*
|
|
* To change this license header, choose License Headers in Project Properties.
|
|
* To change this template file, choose Tools | Templates
|
|
* and open the template in the editor.
|
|
*/
|
|
|
|
package stanhebben.zenscript.expression.partial;
|
|
|
|
import java.util.Arrays;
|
|
import stanhebben.zenscript.compiler.IEnvironmentGlobal;
|
|
import stanhebben.zenscript.compiler.IEnvironmentMethod;
|
|
import stanhebben.zenscript.expression.Expression;
|
|
import stanhebben.zenscript.expression.ExpressionCallStatic;
|
|
import stanhebben.zenscript.expression.ExpressionInvalid;
|
|
import stanhebben.zenscript.symbols.IZenSymbol;
|
|
import stanhebben.zenscript.symbols.SymbolJavaStaticMethod;
|
|
import stanhebben.zenscript.type.ZenType;
|
|
import stanhebben.zenscript.type.natives.IJavaMethod;
|
|
import stanhebben.zenscript.util.ZenPosition;
|
|
|
|
/**
|
|
*
|
|
* @author Stanneke
|
|
*/
|
|
public class PartialStaticMethod implements IPartialExpression {
|
|
private final ZenPosition position;
|
|
private final IJavaMethod method;
|
|
|
|
public PartialStaticMethod(ZenPosition position, IJavaMethod method) {
|
|
this.position = position;
|
|
this.method = method;
|
|
}
|
|
|
|
@Override
|
|
public Expression eval(IEnvironmentGlobal environment) {
|
|
environment.error(position, "not a valid expression");
|
|
return new ExpressionInvalid(position);
|
|
}
|
|
|
|
@Override
|
|
public Expression assign(ZenPosition position, IEnvironmentGlobal environment, Expression other) {
|
|
environment.error(position, "cannot alter this final");
|
|
return new ExpressionInvalid(position);
|
|
}
|
|
|
|
@Override
|
|
public IPartialExpression getMember(ZenPosition position, IEnvironmentGlobal environment, String name) {
|
|
environment.error(position, "methods have no members");
|
|
return new ExpressionInvalid(position);
|
|
}
|
|
|
|
@Override
|
|
public Expression call(ZenPosition position, IEnvironmentMethod environment, Expression... values) {
|
|
if (method.accepts(environment, values)) {
|
|
return new ExpressionCallStatic(position, environment, method, values);
|
|
} else {
|
|
environment.error(position, "parameter count mismatch: got " + values.length + " arguments");
|
|
return new ExpressionInvalid(position, method.getReturnType());
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public ZenType[] predictCallTypes(int numArguments) {
|
|
return Arrays.copyOf(method.getParameterTypes(), numArguments);
|
|
}
|
|
|
|
@Override
|
|
public IZenSymbol toSymbol() {
|
|
return new SymbolJavaStaticMethod(method);
|
|
}
|
|
|
|
@Override
|
|
public ZenType getType() {
|
|
return method.getReturnType();
|
|
}
|
|
|
|
@Override
|
|
public ZenType toType(IEnvironmentGlobal environment) {
|
|
return ZenType.ANY;
|
|
}
|
|
}
|