More testing on Serpent compiler, some operand order fixes:

This commit is contained in:
romanman 2014-05-14 19:45:02 +03:00
parent b1a965c549
commit b72cc89b6f
5 changed files with 596 additions and 193 deletions

View File

@ -61,6 +61,7 @@ public class ConnectionConsole extends JFrame implements PeerListener{
public void componentShown(ComponentEvent e) {
Thread t = new Thread() {
public void run() {
new ClientPeer(thisConsole).connect("54.201.28.117", 30303);
// new ClientPeer(thisConsole).connect("82.217.72.169", 30303);
// new ClientPeer(thisConsole).connect("54.204.10.41", 30303);

View File

@ -103,10 +103,19 @@ public class SerpentEditor extends JFrame {
// todo: integrate new compiler when avail
asmResult = SerpentCompiler.compile(codeArea.getText());
} catch (Throwable th) {th.printStackTrace();}
} catch (Throwable th) {
th.printStackTrace();
splitPanel.setDividerLocation(0.7);
result.setVisible(true);
result.setText(th.getMessage());
result.setForeground(Color.RED);
return;
}
result.setForeground(Color.BLUE);
splitPanel.setDividerLocation(0.7);
result.setVisible(true);
result.setText(asmResult);
}

View File

@ -193,8 +193,8 @@ public class SerpentToAssemblyCompiler extends SerpentBaseVisitor<String> {
public String visitMul_expr(@NotNull SerpentParser.Mul_exprContext ctx) {
if (ctx.mul_expr() == null) return visit(ctx.int_val());
String operand0 = visit(ctx.mul_expr());
String operand1 = visit(ctx.int_val());
String operand0 = visit(ctx.int_val());
String operand1 = visit(ctx.mul_expr());
switch (ctx.OP_MUL().getText().toLowerCase()) {
case "*": return operand0 + " " + operand1 + " MUL";
@ -211,8 +211,8 @@ public class SerpentToAssemblyCompiler extends SerpentBaseVisitor<String> {
if (ctx.add_expr() == null) return visit(ctx.mul_expr());
String operand0 = visit(ctx.add_expr());
String operand1 = visit(ctx.mul_expr());
String operand0 = visit(ctx.mul_expr());
String operand1 = visit(ctx.add_expr());
switch (ctx.OP_ADD().getText().toLowerCase()) {
case "+": return operand0 + " " + operand1 + " ADD";
@ -230,10 +230,10 @@ public class SerpentToAssemblyCompiler extends SerpentBaseVisitor<String> {
String operand1 = visit(ctx.add_expr());
switch (ctx.OP_REL().getText().toLowerCase()) {
case "<": return operand0 + " " + operand1 + " LT";
case ">": return operand0 + " " + operand1 + " GT";
case ">=": return operand0 + " " + operand1 + " LT NOT";
case "<=": return operand0 + " " + operand1 + " GT NOT";
case "<": return operand1 + " " + operand0 + " LT";
case ">": return operand1 + " " + operand0 + " GT";
case ">=": return operand1 + " " + operand0 + " LT NOT";
case "<=": return operand1 + " " + operand0 + " GT NOT";
default: throw new UnknownOperandException(ctx.OP_REL().getText());
}
}
@ -243,8 +243,8 @@ public class SerpentToAssemblyCompiler extends SerpentBaseVisitor<String> {
if (ctx.eq_exp() == null) return visit(ctx.rel_exp());
String operand0 = visit(ctx.eq_exp());
String operand1 = visit(ctx.rel_exp());
String operand0 = visit(ctx.rel_exp());
String operand1 = visit(ctx.eq_exp());
switch (ctx.OP_EQ().getText().toLowerCase()) {
case "==": return operand0 + " " + operand1 + " EQ";
@ -258,8 +258,8 @@ public class SerpentToAssemblyCompiler extends SerpentBaseVisitor<String> {
if (ctx.and_exp() == null) return visit(ctx.eq_exp());
String operand0 = visit(ctx.and_exp());
String operand1 = visit(ctx.eq_exp());
String operand0 = visit(ctx.eq_exp());
String operand1 = visit(ctx.and_exp());
switch (ctx.OP_AND().getText().toLowerCase()) {
case "&": return operand0 + " " + operand1 + " AND";
@ -272,8 +272,8 @@ public class SerpentToAssemblyCompiler extends SerpentBaseVisitor<String> {
if (ctx.ex_or_exp() == null) return visit(ctx.and_exp());
String operand0 = visit(ctx.ex_or_exp());
String operand1 = visit(ctx.and_exp());
String operand0 = visit(ctx.and_exp());
String operand1 = visit(ctx.ex_or_exp());
switch (ctx.OP_EX_OR().getText().toLowerCase()) {
case "xor": return operand0 + " " + operand1 + " XOR";
@ -286,8 +286,8 @@ public class SerpentToAssemblyCompiler extends SerpentBaseVisitor<String> {
if (ctx.in_or_exp() == null) return visit(ctx.ex_or_exp());
String operand0 = visit(ctx.in_or_exp());
String operand1 = visit(ctx.ex_or_exp());
String operand0 = visit(ctx.ex_or_exp());
String operand1 = visit(ctx.in_or_exp());
switch (ctx.OP_IN_OR().getText().toLowerCase()) {
case "|": return operand0 + " " + operand1 + " OR";
@ -300,8 +300,8 @@ public class SerpentToAssemblyCompiler extends SerpentBaseVisitor<String> {
if (ctx.log_and_exp() == null) return visit(ctx.in_or_exp());
String operand0 = visit(ctx.log_and_exp());
String operand1 = visit(ctx.in_or_exp());
String operand0 = visit(ctx.in_or_exp());
String operand1 = visit(ctx.log_and_exp());
switch (ctx.OP_LOG_AND().getText().toLowerCase()) {
case "and": return operand0 + " " + operand1 + " NOT NOT MUL";
@ -315,8 +315,8 @@ public class SerpentToAssemblyCompiler extends SerpentBaseVisitor<String> {
if (ctx.log_or_exp() == null) return visit(ctx.log_and_exp());
String operand0 = visit(ctx.log_or_exp());
String operand1 = visit(ctx.log_and_exp());
String operand0 = visit(ctx.log_and_exp());
String operand1 = visit(ctx.log_or_exp());
switch (ctx.OP_LOG_OR().getText().toLowerCase()) {
case "||": return operand0 + " " + operand1 + " DUP 4 PC ADD JUMPI POP SWAP POP";

View File

@ -688,7 +688,7 @@ public class RLPTest {
String blockRaw = "f8cbf8c7a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a02f4399b08efe68945c1cf90ffe85bbe3ce978959da753f9e649f034015b8817da00000000000000000000000000000000000000000000000000000000000000000834000008080830f4240808080a004994f67dc55b09e814ab7ffc8df3686b4afb2bb53e60eae97ef043fe03fb829c0c0";
byte[] payload = Hex.decode(blockRaw);
final int ITERATIONS = 10000000;
final int ITERATIONS = 1;
RLPList list = null;
DecodeResult result = null;
System.out.println("Starting " + ITERATIONS + " decoding iterations...");