mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-17 10:55:04 +00:00
- Continued writing on the IC2 integration code
- Implemented advanced recipes on <*> values - Removed unused ZenScript classes - Continued work on any values - Moved documentation generation to buildSrc - Started work on a jar merging task - Added toString implementation to ingredients - Added stack count to ICraftingInventory - Fixed imports - Added logCommand to the logger to log command output - Implemented memory script provider to load scripts received from the server - Added exception handling for script execution - First attempt at creating a transformer to generate a list of ZenClass and ZenExpansion classes - Added console commands (reload, names, liquids, inventory, hand, oredict) - Added general logic - Fixed item ingredients for wildcard sizes - Implemented selective recipe removal - Fixed null recipe results - Started implementation of player-specific recipes - Removed redundant IC2 mod copy - Other minor fixes
This commit is contained in:
1 parent
f3ea7f7831
commit
489347558f
124 files changed
+3942
-419
No files matched your search
@@ -5,11 +5,15 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import static stanhebben.zenscript.ZenTokener.*;
|
||||
import stanhebben.zenscript.compiler.EnvironmentScript;
|
||||
import stanhebben.zenscript.compiler.IEnvironmentGlobal;
|
||||
import stanhebben.zenscript.definitions.Import;
|
||||
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.SymbolType;
|
||||
import stanhebben.zenscript.type.ZenType;
|
||||
|
||||
/**
|
||||
* Contains a parsed file.
|
||||
@@ -32,6 +36,7 @@ public class ZenParsedFile {
|
||||
private final List<Import> imports;
|
||||
private final Map<String, ParsedFunction> functions;
|
||||
private final List<Statement> statements;
|
||||
private final IEnvironmentGlobal environmentScript;
|
||||
|
||||
/**
|
||||
* Constructs and parses a given file.
|
||||
@@ -48,6 +53,7 @@ public class ZenParsedFile {
|
||||
imports = new ArrayList<Import>();
|
||||
functions = new HashMap<String, ParsedFunction>();
|
||||
statements = new ArrayList<Statement>();
|
||||
environmentScript = new EnvironmentScript(environment);
|
||||
|
||||
tokener.setFile(this);
|
||||
|
||||
@@ -74,20 +80,55 @@ public class ZenParsedFile {
|
||||
imports.add(new Import(start.getPosition(), importName, rename));
|
||||
}
|
||||
|
||||
for (Import imprt : imports) {
|
||||
List<String> name = imprt.getName();
|
||||
IPartialExpression type = null;
|
||||
|
||||
StringBuilder nameSoFar = new StringBuilder();
|
||||
|
||||
for (String part : name) {
|
||||
if (type == null) {
|
||||
nameSoFar.append(part);
|
||||
type = environment.getValue(part, imprt.getPosition());
|
||||
if (type == null) {
|
||||
environment.error(imprt.getPosition(), "could not find package " + type);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
nameSoFar.append('.').append(part);
|
||||
type = type.getMember(imprt.getPosition(), environment, part);
|
||||
if (type == null) {
|
||||
environment.error(imprt.getPosition(), "could not find type or package " + nameSoFar);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (type != null) {
|
||||
environmentScript.putValue(imprt.getRename(), type.toSymbol());
|
||||
} else {
|
||||
environmentScript.putValue(imprt.getRename(), new SymbolType(ZenType.ANY));
|
||||
}
|
||||
}
|
||||
|
||||
while (tokener.hasNext()) {
|
||||
Token next = tokener.peek();
|
||||
if (next.getType() == T_FUNCTION) {
|
||||
ParsedFunction function = ParsedFunction.parse(tokener, environment);
|
||||
ParsedFunction function = ParsedFunction.parse(tokener, environmentScript);
|
||||
if (functions.containsKey(function.getName())) {
|
||||
environment.error(function.getPosition(), "function " + function.getName() + " already exists");
|
||||
}
|
||||
functions.put(function.getName(), function);
|
||||
} else {
|
||||
statements.add(Statement.read(tokener, environment));
|
||||
statements.add(Statement.read(tokener, environmentScript));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IEnvironmentGlobal getEnvironment() {
|
||||
return environmentScript;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the output classname for this file.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user