fix flow keyword issues

This commit is contained in:
dfsek
2020-12-31 02:44:33 -07:00
parent 792b6efd12
commit 0c3e3f2bc6
6 changed files with 19 additions and 16 deletions

View File

@@ -8,7 +8,7 @@ import com.dfsek.terra.api.structures.tokenizer.Position;
import java.util.Random;
public class BreakKeyword implements Keyword<Block.ReturnLevel> {
public class BreakKeyword implements Keyword<Block.ReturnInfo<?>> {
private final Position position;
public BreakKeyword(Position position) {
@@ -16,8 +16,8 @@ public class BreakKeyword implements Keyword<Block.ReturnLevel> {
}
@Override
public Block.ReturnLevel apply(Buffer buffer, Rotation rotation, Random random, int recursions) {
return Block.ReturnLevel.BREAK;
public Block.ReturnInfo<?> apply(Buffer buffer, Rotation rotation, Random random, int recursions) {
return new Block.ReturnInfo<>(Block.ReturnLevel.BREAK, null);
}
@Override

View File

@@ -8,7 +8,7 @@ import com.dfsek.terra.api.structures.tokenizer.Position;
import java.util.Random;
public class ContinueKeyword implements Keyword<Block.ReturnLevel> {
public class ContinueKeyword implements Keyword<Block.ReturnInfo<?>> {
private final Position position;
public ContinueKeyword(Position position) {
@@ -16,8 +16,8 @@ public class ContinueKeyword implements Keyword<Block.ReturnLevel> {
}
@Override
public Block.ReturnLevel apply(Buffer buffer, Rotation rotation, Random random, int recursions) {
return Block.ReturnLevel.CONTINUE;
public Block.ReturnInfo<?> apply(Buffer buffer, Rotation rotation, Random random, int recursions) {
return new Block.ReturnInfo<>(Block.ReturnLevel.CONTINUE, null);
}
@Override

View File

@@ -8,7 +8,7 @@ import com.dfsek.terra.api.structures.tokenizer.Position;
import java.util.Random;
public class FailKeyword implements Keyword<Block.ReturnLevel> {
public class FailKeyword implements Keyword<Block.ReturnInfo<?>> {
private final Position position;
public FailKeyword(Position position) {
@@ -16,8 +16,8 @@ public class FailKeyword implements Keyword<Block.ReturnLevel> {
}
@Override
public Block.ReturnLevel apply(Buffer buffer, Rotation rotation, Random random, int recursions) {
return Block.ReturnLevel.FAIL;
public Block.ReturnInfo<?> apply(Buffer buffer, Rotation rotation, Random random, int recursions) {
return new Block.ReturnInfo<>(Block.ReturnLevel.FAIL, null);
}
@Override

View File

@@ -8,7 +8,7 @@ import com.dfsek.terra.api.structures.tokenizer.Position;
import java.util.Random;
public class ReturnKeyword implements Keyword<Block.ReturnLevel> {
public class ReturnKeyword implements Keyword<Block.ReturnInfo<?>> {
private final Position position;
public ReturnKeyword(Position position) {
@@ -16,8 +16,8 @@ public class ReturnKeyword implements Keyword<Block.ReturnLevel> {
}
@Override
public Block.ReturnLevel apply(Buffer buffer, Rotation rotation, Random random, int recursions) {
return Block.ReturnLevel.RETURN;
public Block.ReturnInfo<?> apply(Buffer buffer, Rotation rotation, Random random, int recursions) {
return new Block.ReturnInfo<>(Block.ReturnLevel.RETURN, null);
}
@Override

View File

@@ -7,9 +7,9 @@ num testVar = 3.4;
bool boolean = true;
str stringVar = "hello!";
num precedence = 2 + 2 * 2;
num precedence = (3 + 2) * 2 + 3;
test("precedence: " + precedence, 2);
num precedence2 = 2 * 2 + 2;
num precedence2 = 3 * 2 + 2 * 3;
test("precedence 2: " + precedence2, 2);
bool iftest = false;
@@ -20,6 +20,9 @@ num iterator = 0;
for(num i = 0; i < 5; i = i + 1) {
test("i = " + i, iterator);
if(i > 1 + 1) {
test("more than 2", iterator);
}
}
for(num i = 0; i < 5; i = i + 1) {

View File

@@ -40,10 +40,10 @@ public class LoadRawCommand extends LoadCommand implements DebugCommand {
long t = System.nanoTime();
FastRandom chunk = PopulationUtil.getRandom(new BukkitChunk(sender.getLocation().getChunk()));
terraWorld.getConfig().getScriptRegistry().get(args[0]).execute(new Location(new BukkitWorld(sender.getWorld()), sender.getLocation().getX(), sender.getLocation().getY(), sender.getLocation().getZ()), chunk, Rotation.fromDegrees(90 * chunk.nextInt(4)));
boolean success = terraWorld.getConfig().getScriptRegistry().get(args[0]).execute(new Location(new BukkitWorld(sender.getWorld()), sender.getLocation().getX(), sender.getLocation().getY(), sender.getLocation().getZ()), chunk, Rotation.fromDegrees(90 * chunk.nextInt(4)));
long l = System.nanoTime() - t;
sender.sendMessage("Took " + ((double) l) / 1000000 + "ms");
sender.sendMessage("Took " + ((double) l) / 1000000 + "ms. Success: " + success);
return true;
}