Skip to content

Commit

Permalink
spartanize project part2
Browse files Browse the repository at this point in the history
  • Loading branch information
ravivos committed Jun 4, 2017
1 parent 424cc6d commit 81a9175
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ public static void storeDefaultEntries() {
store().setToDefault(PreferencesResources.WIDGET_OPERATION_CONFIGURATION);
}
@SuppressWarnings("unchecked") public static List<WidgetOperationEntry> readEntries() {
final String forString = store().getString(PreferencesResources.WIDGET_OPERATION_CONFIGURATION);
final byte[] theOutBarr = Base64.getDecoder().decode(forString);
final byte[] theOutBarr = Base64.getDecoder().decode(store().getString(PreferencesResources.WIDGET_OPERATION_CONFIGURATION));
final ByteArrayInputStream in = new ByteArrayInputStream(theOutBarr);
List<WidgetOperationEntry> $ = null;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ boolean collect(final AbstractTypeDeclaration in) {
final int length = in.getLength(), tokens = metrics.tokens(in + ""), nodes = countOf.nodes(in), body = metrics.bodySize(in),
tide = clean(in + "").length(), essence = Essence.of(in + "").length();
final String out = interactiveSpartanizer.fixedPoint(in + "");
final int length2 = out.length(), tokens2 = metrics.tokens(out), tide2 = clean(out + "").length(), essence2 = Essence.of(out + "").length(),
wordCount = system.wc(Essence.of(out + ""));
final int length2 = out.length(), tokens2 = metrics.tokens(out), tide2 = clean(out).length(), essence2 = Essence.of(out).length(),
wordCount = system.wc(Essence.of(out));
final ASTNode from = makeAST.COMPILATION_UNIT.from(out);
final int nodes2 = countOf.nodes(from), body2 = metrics.bodySize(from);
System.err.println(++classesDone + " " + extract.category(in) + " " + extract.name(in));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ Namespace spawn(final String childName) {
return addChild(new Namespace(this, childName));
}
@Override public String toString() {
return name + "" + flat;
return name + flat;
}
static boolean init(final Namespace n, final Iterable<? extends ASTNode> children) {
children.forEach(n::fillScope);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static void launchWidget(final Function<Point, Point> startLocation) {
final Button closeButton = new Button(shell, SWT.PUSH | SWT.WRAP);
closeButton.setText("close");
expandControl(closeButton, MINIMAL_BUTTON_SIZE);
closeButton.setLocation(R / 2 + r, 2 * R - closeButton.getSize().y / 2 + r);
closeButton.setLocation(r + R / 2, r + (2 * R - closeButton.getSize().y / 2));
closeButton.addListener(SWT.Selection, __ -> {
shell.close();
active.set(false);
Expand All @@ -79,7 +79,7 @@ public static void launchWidget(final Function<Point, Point> startLocation) {
setControl(canvas, setSolid, setTransparent);
setMovable(display, canvas, shell);
final Region region = new Region();
region.add(circle(R, R + r, R + r));
region.add(circle(R, r + R, r + R));
region.add(closeButton.getBounds());
final Rectangle size = region.getBounds();
shell.setSize(size.width, size.height);
Expand Down Expand Up @@ -129,11 +129,11 @@ private static boolean setUpR() {
R = widgetSize;
circles = new Point[] { //
new Point(2 * r, 2 * R)//
, new Point(r, R + r)//
, new Point(r, r + R)//
, new Point(2 * r, 2 * r)//
, new Point(R + r, r)//
, new Point(r + R, r)//
, new Point(2 * R, 2 * r)//
, new Point(2 * R + r, R + r)//
, new Point(r + 2 * R, r + R)//
, new Point(2 * R, 2 * R)//
};
return true;
Expand Down Expand Up @@ -188,9 +188,9 @@ static int[] circle(@SuppressWarnings("hiding") final int r, final int offsetX,
final int[] $ = new int[8 * r + 4];
for (int i = 0; i <= 2 * r; ++i) {
final int x = i - r, y = (int) Math.sqrt(r * r - x * x);
$[2 * i] = offsetX + x;
$[2 * i + 1] = offsetY + y;
$[8 * r - 2 * i - 2] = offsetX + x;
$[2 * i] = x + offsetX;
$[2 * i + 1] = y + offsetY;
$[8 * r - 2 * i - 2] = x + offsetX;
$[8 * r - 2 * i - 1] = offsetY - y;
}
return $;
Expand All @@ -209,7 +209,7 @@ static Canvas createImage(final Shell s) {
¢.gc.drawImage(i, 0, 0);
$.setSize(w, h);
});
$.setLocation(R / 2 + r, R / 2 + r);
$.setLocation(r + R / 2, r + R / 2);
$.pack();
return $;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ public final class AtomicConversionsTest {
assert !atomic.isDouble(1L);
assert atomic.isLong(1L);
assert atomic.isFloat(2F);
assert atomic.isFloat(2F + f);
assert atomic.isFloat(f + 2F);
assert atomic.isFloat(1L + 2F);
}
@Test public void mod() {
assert atomic.isLong(l / i);
assert atomic.isLong(l + i);
assert atomic.isLong(i + l);
assert atomic.isLong(l % i);
assert atomic.isLong(i % l);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class FixtureCatchBlock extends MetaFixture {
} finally {
@foreign("$") final int a = hashCode() * hashCode();
@knows("a") final int z = a * a + hashCode();
f(a * z + z + hashCode());
f(z + a * z + hashCode());
}
return 3;
}
Expand All @@ -72,11 +72,11 @@ void simple() {
@knows({ "a2", "x" }) @foreign("r") final int a2 = hashCode() * hashCode();
f(a2 * x.hashCode());
@knows({ "a2", "x" }) final int r = hashCode();
f(r * a2 * a2 + r);
f(r + r * a2 * a2);
} finally {
@foreign("r") final int a = hashCode() * hashCode();
@knows("a") final int r = hashCode();
f(a * a * r + r);
f(r + a * a * r);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ int f(final int[] a) {
for (@knows({ "f/1", "$", "i" }) int i = 0; i < a.length; ++i)
for (@knows({ "f/1", "$", "i", "j" }) int j = 0; j < a.length; ++j) {
@knows({ "f/1", "$", "i", "j", "f" }) final int f = hashCode();
$ += f * i * j + f;
$ += f + f * i * j;
}
return $;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ public class FixtureTryResources extends MetaFixture {
}
@foreign("$") final int x = hashCode() >>> 3;
@knows("$") final int $ = 100 * hashCode() >>> 3;
return f() == x ? x + $ : 2 * hashCode();
return f() == x ? $ + x : 2 * hashCode();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ public static Double g(final double y) {
public static int g(final int x, final int y) {
@knows({ "x", "y", "$" }) final int $ = x * y;
@knows({ "x", "y", "z", "$" }) final int z = $ * (x + y);
return x * z + y + $;
return $ + y + x * z;
}
public static int h(final int x, final int y) {
@knows({ "x", "y", "$" }) final int $ = x * y;
@knows({ "x", "y", "z", "$" }) final int z = $ * (x + y);
return x * z + y + $;
return $ + y + x * z;
}

final String repository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class NamespaceFixture {
l = $ * k;
@knows("k") int s = l + k * k * l;
s *= s + 2;
f(k + s * hashCode() + l + $ * s);
f(k + l + $ * s + s * hashCode());
}

int f(final int a) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ class ZZZ___Fixture_ModelClass {
return ¢ + "";
};
for (@ScopeSize(1) @foreach final char ¢ : (this + "").toCharArray())
return sum(super.hashCode(), hashCode() * $.hashCode() + ¢);
return sum(super.hashCode(), ¢ + hashCode() * $.hashCode());
return sum(super.hashCode(), hashCode() * $.hashCode()) + something.hashCode();
}
@ScopeSize(4) @method int sum(@ScopeSize(1) @parameter final int a, @ScopeSize(1) @parameter final int b) {
Expand All @@ -469,7 +469,7 @@ class ZZZ___Fixture_ModelClass {
@local final int c0 = localVariableInTryBlock - localVariableNewClass;
--localVariableNewClass;
localVariableNewClass ^= localVariableInTryBlock;
@ScopeSize(5) @knows({ "localVariableNewClass", "raisin" }) @local int raisin = localVariableInTryBlock + localVariableNewClass;
@ScopeSize(5) @knows({ "localVariableNewClass", "raisin" }) @local int raisin = localVariableNewClass + localVariableInTryBlock;
@ScopeSize(3) @local int c8;
++localVariableNewClass;
c8 = ++raisin;
Expand All @@ -490,17 +490,16 @@ class ZZZ___Fixture_ModelClass {
}
for (@knows("carrot") final int carrot : toString().toCharArray()) {
@knows("carrot") final int cherry = 2 * carrot * (carrot - 21) + 2;
q(carrot * cherry + cherry);
q(cherry + carrot * cherry);
}
for (@ScopeSize(6) @for¢ int melon = 0, ¢ = 0 + melon; ¢ < 10 * melon; melon *= 2, --melon, ¢ = melon) {
for (@ScopeSize(6) @for¢ int melon = 0, ¢ = melon; ¢ < 10 * melon; melon *= 2, --melon, ¢ = melon) {
@knows({ "melon", "¢" }) final int variableInPlainFor = 2 * melon + hashCode();
q(melon * hashCode() + variableInPlainFor * variableInPlainFor);
¢ += melon;
q(melon * hashCode() + variableInPlainFor * variableInPlainFor);
}
for (@ScopeSize(8) @for¢ int pear, j = 0, variableInPlainFor = 12, ¢ = 0 + j; ¢ < 10 * j; j *= 2, --j, ¢ = j) {
@knows({ "variableInPlainFor", "pear", "j", "anotherVariableInAnotherPlainFor" }) int anotherVariableInAnotherPlainFor = 2 * hashCode() + j
+ variableInPlainFor;
for (@ScopeSize(8) @for¢ int pear, j = 0, variableInPlainFor = 12, ¢ = j; ¢ < 10 * j; j *= 2, --j, ¢ = j) {
@knows({ "variableInPlainFor", "pear", "j", "anotherVariableInAnotherPlainFor" }) int anotherVariableInAnotherPlainFor = j + variableInPlainFor + 2 * hashCode();
pear = hashCode() * anotherVariableInAnotherPlainFor;
anotherVariableInAnotherPlainFor >>>= pear;
¢ += j + anotherVariableInAnotherPlainFor;
Expand Down

0 comments on commit 81a9175

Please sign in to comment.