mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-12 16:27:40 +00:00
- Added toString to the data values
- Added getPlayer to crafting inventory - Added crafting inventory to recipe function - Removed some print statements - Renamed the global minetweaker variable to tweaker - Bumped forge version to 1121 due to ore dictionary changes - Added bracket handler for ore entries - Enabled withTag(null) - Fixed issues with the new ore dictionary implementation in Forge 1113+ - Fixed bug in Ore recipe conversion - Fixed import errors not being detected and reported properly - Fixed nested NBT tags not being converted properly - Fixed something in any type implementation - Added commas in function name generation - Added class registries for IC2 and NEI integration
This commit is contained in:
1 parent
2de467d7d8
commit
3827eba3e2
39 files changed
+301
-50
No files matched your search
@@ -12,6 +12,7 @@ import stanhebben.zenscript.definitions.ParsedFunction;
|
||||
import stanhebben.zenscript.expression.partial.IPartialExpression;
|
||||
import stanhebben.zenscript.parser.Token;
|
||||
import stanhebben.zenscript.statements.Statement;
|
||||
import stanhebben.zenscript.symbols.IZenSymbol;
|
||||
import stanhebben.zenscript.symbols.SymbolType;
|
||||
import stanhebben.zenscript.type.ZenType;
|
||||
|
||||
@@ -105,7 +106,12 @@ public class ZenParsedFile {
|
||||
}
|
||||
|
||||
if (type != null) {
|
||||
environmentScript.putValue(imprt.getRename(), type.toSymbol());
|
||||
IZenSymbol symbol = type.toSymbol();
|
||||
if (symbol == null) {
|
||||
environmentScript.error(imprt.getPosition(), "Not a valid type");
|
||||
} else {
|
||||
environmentScript.putValue(imprt.getRename(), type.toSymbol());
|
||||
}
|
||||
} else {
|
||||
environmentScript.putValue(imprt.getRename(), new SymbolType(ZenType.ANY));
|
||||
}
|
||||
|
||||
@@ -57,7 +57,9 @@ public class EnvironmentScript implements IEnvironmentGlobal {
|
||||
@Override
|
||||
public IPartialExpression getValue(String name, ZenPosition position) {
|
||||
if (imports.containsKey(name)) {
|
||||
return imports.get(name).instance(position);
|
||||
IZenSymbol imprt = imports.get(name);
|
||||
if (imprt == null) throw new RuntimeException("How could this happen?");
|
||||
return imprt.instance(position);
|
||||
} else {
|
||||
return parent.getValue(name, position);
|
||||
}
|
||||
@@ -65,6 +67,8 @@ public class EnvironmentScript implements IEnvironmentGlobal {
|
||||
|
||||
@Override
|
||||
public void putValue(String name, IZenSymbol value) {
|
||||
if (value == null) throw new IllegalArgumentException("value cannot be null");
|
||||
|
||||
imports.put(name, value);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@ public class ExpressionFunction extends Expression {
|
||||
public ExpressionFunction(ZenPosition position, List<ParsedFunctionArgument> arguments, ZenType returnType, Statement[] statements) {
|
||||
super(position);
|
||||
|
||||
System.out.println("Function expression: " + arguments.size() + " arguments");
|
||||
|
||||
this.arguments = arguments;
|
||||
this.returnType = returnType;
|
||||
this.statements = statements;
|
||||
|
||||
@@ -66,6 +66,8 @@ public class ExpressionTable extends Expression {
|
||||
|
||||
@Override
|
||||
public Expression cast(ZenPosition position, IEnvironmentGlobal environment, ZenType type) {
|
||||
System.out.println("Casting Table to " + type.getName());
|
||||
|
||||
if (type instanceof ZenTypeAssociative) {
|
||||
ZenTypeAssociative keyType = (ZenTypeAssociative) type;
|
||||
Expression[] newKeys = new Expression[keys.length];
|
||||
@@ -77,8 +79,11 @@ public class ExpressionTable extends Expression {
|
||||
}
|
||||
|
||||
return new ExpressionTable(getPosition(), newKeys, newValues, type);
|
||||
} else if (this.type.canCastImplicit(type, environment)) {
|
||||
return this.type.cast(position, environment, this, type);
|
||||
} else {
|
||||
return super.cast(position, environment, type);
|
||||
environment.error(position, "cannot cast " + this.type + " to " + type);
|
||||
return new ExpressionInvalid(position, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class SymbolPackage implements IZenSymbol {
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Adding " + parts[parts.length - 1] + " to package " + pkgCurrent.getName() + "(" + symbol + ")");
|
||||
//System.out.println("Adding " + parts[parts.length - 1] + " to package " + pkgCurrent.getName() + "(" + symbol + ")");
|
||||
if (pkgCurrent.members.containsKey(parts[parts.length - 1])) {
|
||||
errors.error(null, parts[parts.length - 1] + " is already defined in that package");
|
||||
} else {
|
||||
|
||||
@@ -379,13 +379,9 @@ public class ZenTypeAny extends ZenType {
|
||||
|
||||
@Override
|
||||
public Expression call(ZenPosition position, IEnvironmentGlobal environment, Expression receiver, Expression... arguments) {
|
||||
try {
|
||||
return JavaMethod
|
||||
.get(environment, IAny.class, "call", Class.forName("[" + signature(IAny.class)))
|
||||
.callVirtual(position, environment, receiver, arguments);
|
||||
} catch (ClassNotFoundException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
return JavaMethod
|
||||
.get(environment, IAny.class, "call", IAny[].class)
|
||||
.callVirtual(position, environment, receiver, arguments);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,7 +37,13 @@ public class ZenTypeFunction extends ZenType {
|
||||
|
||||
StringBuilder nameBuilder = new StringBuilder();
|
||||
nameBuilder.append("function(");
|
||||
boolean first = true;
|
||||
for (ZenType type : argumentTypes) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
nameBuilder.append(',');
|
||||
}
|
||||
nameBuilder.append(type.getName());
|
||||
}
|
||||
nameBuilder.append(returnType.getName());
|
||||
@@ -53,6 +59,7 @@ public class ZenTypeFunction extends ZenType {
|
||||
for (ZenType type : argumentTypes) {
|
||||
nameBuilder.append(type.getName());
|
||||
}
|
||||
nameBuilder.append(')');
|
||||
nameBuilder.append(returnType.getName());
|
||||
name = nameBuilder.toString();
|
||||
}
|
||||
@@ -165,6 +172,8 @@ public class ZenTypeFunction extends ZenType {
|
||||
private boolean canCastToNative(ZenType type) {
|
||||
if (!(type instanceof ZenTypeNative)) return false;
|
||||
|
||||
//System.out.println("Check cast to native type " + type.getName());
|
||||
|
||||
ZenTypeNative ntype = (ZenTypeNative) type;
|
||||
if (ntype.getNativeClass().isInterface() && ntype.getNativeClass().getMethods().length == 1) {
|
||||
// ta-da! we got a functional interface
|
||||
@@ -173,6 +182,7 @@ public class ZenTypeFunction extends ZenType {
|
||||
return true; // assume for now it is
|
||||
}
|
||||
|
||||
System.out.println("Cannot cast");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user