mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-22 04:52:21 +00:00
format all the things!
This commit is contained in:
1 parent
54ec75fd3d
commit
b36c6dade6
377 files changed
+6833
-6772
No files matched your search
@@ -34,7 +34,7 @@ public abstract class Statement {
|
||||
case T_VAL: {
|
||||
Token start = parser.next();
|
||||
String name = parser.required(T_ID, "identifier expected").getValue();
|
||||
|
||||
|
||||
ZenType type = null;
|
||||
ParsedExpression initializer = null;
|
||||
if (parser.optional(T_AS) != null) {
|
||||
@@ -61,11 +61,11 @@ public abstract class Statement {
|
||||
String name = parser.required(T_ID, "identifier expected").getValue();
|
||||
List<String> names = new ArrayList<String>();
|
||||
names.add(name);
|
||||
|
||||
|
||||
while (parser.optional(T_COMMA) != null) {
|
||||
names.add(parser.required(T_ID, "identifier expected").getValue());
|
||||
}
|
||||
|
||||
|
||||
parser.required(T_IN, "in expected");
|
||||
ParsedExpression source = ParsedExpression.read(parser, environment);
|
||||
Statement content = read(parser, environment, null);
|
||||
@@ -78,33 +78,33 @@ public abstract class Statement {
|
||||
case T_VERSION: {
|
||||
Token t = parser.next();
|
||||
parser.required(T_INTVALUE, "integer expected");
|
||||
|
||||
//MineTweaker.logWarning("The version statement is no longer necessary");
|
||||
|
||||
|
||||
// MineTweaker.logWarning("The version statement is no longer necessary");
|
||||
|
||||
parser.required(T_SEMICOLON, "; expected");
|
||||
return new StatementNull(t.getPosition());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZenPosition position = parser.peek().getPosition();
|
||||
StatementExpression result = new StatementExpression(position, ParsedExpression.read(parser, environment));
|
||||
parser.required(T_SEMICOLON, "; expected");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private final ZenPosition position;
|
||||
|
||||
|
||||
public Statement(ZenPosition position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
|
||||
public ZenPosition getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
|
||||
public boolean isReturn() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public abstract void compile(IEnvironmentMethod environment);
|
||||
}
|
||||
@@ -7,10 +7,10 @@ import stanhebben.zenscript.util.ZenPosition;
|
||||
|
||||
public class StatementBlock extends Statement {
|
||||
private final List<Statement> statements;
|
||||
|
||||
|
||||
public StatementBlock(ZenPosition position, List<Statement> statements) {
|
||||
super(position);
|
||||
|
||||
|
||||
this.statements = statements;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,10 +15,10 @@ public class StatementForeach extends Statement {
|
||||
private final String[] varnames;
|
||||
private final ParsedExpression list;
|
||||
private final Statement body;
|
||||
|
||||
|
||||
public StatementForeach(ZenPosition position, String[] varnames, ParsedExpression list, Statement body) {
|
||||
super(position);
|
||||
|
||||
|
||||
this.varnames = varnames;
|
||||
this.list = list;
|
||||
this.body = body;
|
||||
@@ -28,16 +28,16 @@ public class StatementForeach extends Statement {
|
||||
public void compile(IEnvironmentMethod environment) {
|
||||
Expression cList = list.compile(environment, ZenType.ANYARRAY).eval(environment);
|
||||
ZenType listType = cList.getType();
|
||||
|
||||
|
||||
IZenIterator iterator = listType.makeIterator(varnames.length, environment);
|
||||
if (iterator == null) {
|
||||
environment.error(getPosition(), "No iterator with " + varnames.length + " variables");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
MethodOutput methodOutput = environment.getOutput();
|
||||
environment.getOutput().position(getPosition());
|
||||
|
||||
|
||||
IEnvironmentMethod local = new EnvironmentScope(environment);
|
||||
int[] localVariables = new int[varnames.length];
|
||||
for (int i = 0; i < localVariables.length; i++) {
|
||||
@@ -45,13 +45,13 @@ public class StatementForeach extends Statement {
|
||||
local.putValue(varnames[i], localVar, getPosition());
|
||||
localVariables[i] = local.getLocal(localVar);
|
||||
}
|
||||
|
||||
|
||||
cList.compile(true, environment);
|
||||
iterator.compileStart(localVariables);
|
||||
|
||||
|
||||
Label repeat = new Label();
|
||||
Label exit = new Label();
|
||||
|
||||
|
||||
methodOutput.label(repeat);
|
||||
iterator.compilePreIterate(localVariables, exit);
|
||||
body.compile(local);
|
||||
|
||||
@@ -12,10 +12,10 @@ public class StatementIf extends Statement {
|
||||
private final ParsedExpression condition;
|
||||
private final Statement onThen;
|
||||
private final Statement onElse;
|
||||
|
||||
|
||||
public StatementIf(ZenPosition position, ParsedExpression condition, Statement onThen, Statement onElse) {
|
||||
super(position);
|
||||
|
||||
|
||||
this.condition = condition;
|
||||
this.onThen = onThen;
|
||||
this.onElse = onElse;
|
||||
@@ -24,26 +24,26 @@ public class StatementIf extends Statement {
|
||||
@Override
|
||||
public void compile(IEnvironmentMethod environment) {
|
||||
environment.getOutput().position(getPosition());
|
||||
|
||||
|
||||
Expression cCondition = condition.compile(environment, ZenType.BOOL)
|
||||
.eval(environment)
|
||||
.cast(getPosition(), environment, ZenType.BOOL);
|
||||
|
||||
.eval(environment)
|
||||
.cast(getPosition(), environment, ZenType.BOOL);
|
||||
|
||||
ZenType expressionType = cCondition.getType();
|
||||
if (expressionType.canCastImplicit(ZenType.BOOL, environment)) {
|
||||
Label labelEnd = new Label();
|
||||
Label labelElse = onElse == null ? labelEnd : new Label();
|
||||
|
||||
|
||||
cCondition.compileIf(labelElse, environment);
|
||||
onThen.compile(environment);
|
||||
|
||||
|
||||
MethodOutput methodOutput = environment.getOutput();
|
||||
if (onElse != null) {
|
||||
methodOutput.goTo(labelEnd);
|
||||
methodOutput.label(labelElse);
|
||||
onElse.compile(environment);
|
||||
}
|
||||
|
||||
|
||||
methodOutput.label(labelEnd);
|
||||
} else {
|
||||
environment.error(getPosition(), "condition is not a boolean");
|
||||
|
||||
@@ -20,6 +20,6 @@ public class StatementNull extends Statement {
|
||||
|
||||
@Override
|
||||
public void compile(IEnvironmentMethod environment) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -10,18 +10,18 @@ import stanhebben.zenscript.util.ZenPosition;
|
||||
public class StatementReturn extends Statement {
|
||||
private final ZenType returnType;
|
||||
private final ParsedExpression expression;
|
||||
|
||||
|
||||
public StatementReturn(ZenPosition position, ZenType returnType, ParsedExpression expression) {
|
||||
super(position);
|
||||
|
||||
|
||||
this.returnType = returnType;
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
|
||||
public ParsedExpression getExpression() {
|
||||
return expression;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isReturn() {
|
||||
return false;
|
||||
@@ -30,13 +30,13 @@ public class StatementReturn extends Statement {
|
||||
@Override
|
||||
public void compile(IEnvironmentMethod environment) {
|
||||
environment.getOutput().position(getPosition());
|
||||
|
||||
|
||||
if (expression == null) {
|
||||
environment.getOutput().ret();
|
||||
} else {
|
||||
Expression cExpression = expression.compile(environment, returnType).eval(environment);
|
||||
cExpression.compile(true, environment);
|
||||
|
||||
|
||||
Type returnType = cExpression.getType().toASMType();
|
||||
environment.getOutput().returnType(returnType);
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@ public class StatementVar extends Statement {
|
||||
private final ZenType type;
|
||||
private final ParsedExpression initializer;
|
||||
private final boolean isFinal;
|
||||
|
||||
|
||||
public StatementVar(ZenPosition position, String name, ZenType type, ParsedExpression initializer, boolean isFinal) {
|
||||
super(position);
|
||||
|
||||
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.initializer = initializer;
|
||||
@@ -36,15 +36,15 @@ public class StatementVar extends Statement {
|
||||
@Override
|
||||
public void compile(IEnvironmentMethod environment) {
|
||||
environment.getOutput().position(getPosition());
|
||||
|
||||
|
||||
Expression cInitializer = initializer == null
|
||||
? null
|
||||
: initializer.compile(environment, type).eval(environment);
|
||||
ZenType cType = type == null ? (cInitializer == null ? ZenTypeAny.INSTANCE : cInitializer.getType()) : type;
|
||||
SymbolLocal symbol = new SymbolLocal(cType, isFinal);
|
||||
|
||||
|
||||
environment.putValue(name, symbol, getPosition());
|
||||
|
||||
|
||||
if (cInitializer != null) {
|
||||
cInitializer.compile(true, environment);
|
||||
environment.getOutput().store(symbol.getType().toASMType(), environment.getLocal(symbol));
|
||||
|
||||
Reference in new issue
Block a user