Skip to content

Commit

Permalink
Minor cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Aug 30, 2018
1 parent 8126c3f commit 98decdc
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
@Option.Group(SqueakLanguageConfig.ID)
public final class SqueakOptions {

private SqueakOptions() {
// no instances
}

//@formatter:off
@Option(category = OptionCategory.USER, help = "Path to image")
public static final OptionKey<String> ImagePath = new OptionKey<>("Squeak.image");
Expand Down Expand Up @@ -48,4 +44,7 @@ public static <T> T getOption(final Env env, final OptionKey<T> key) {
}
return env.getOptions().get(key);
}

private SqueakOptions() { // no instances
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public List<String> getLibraries() {
// `sdl2-config --libs`
return Collections.singletonList("-L/usr/local/lib -lSDL2");
} else {
throw new RuntimeException("Unsupported OS");
throw new UnsupportedOperationException("Unsupported OS");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ final class Target_de_hpi_swa_graal_squeak_io_SqueakDisplay implements SqueakDis
private boolean textureDirty = false;
private int width;
private int height;
private int depth;
private int bpp = 4; // TODO: for 32bit only!

private int lastMouseXPos;
Expand Down Expand Up @@ -135,7 +134,7 @@ public void open(final PointersObject sqDisplay) {
throw new SqueakException("Display bitmap expected to be a words object");
}

depth = (int) (long) sqDisplay.at0(FORM.DEPTH);
final int depth = (int) (long) sqDisplay.at0(FORM.DEPTH);
if (depth != 32) {
throw new SqueakException("Expected 32bit display");
}
Expand Down Expand Up @@ -231,13 +230,10 @@ public void pollEvents() {
} else if (eventType == SDL.EventType.KEYDOWN.getCValue()) {
handleKeyboardEvent();
long[] later = null;
if (!isModifierKey(key)) {
// No TEXTINPUT event for this key will follow, but Squeak needs a KeyStroke
// anyway.
if ((image.os.isLinux() && isControlKey(key)) ||
(!image.os.isLinux() && (isControlKey(key) || (SDL.getModState() & ~SDL.kmodShift()) != 0))) {
later = getNextKeyEvent(KEYBOARD_EVENT.CHAR, time);
}
// No TEXTINPUT event for this key will follow, but Squeak needs a KeyStroke anyway.
if (!isModifierKey(key) && ((image.os.isLinux() && isControlKey(key)) ||
(!image.os.isLinux() && (isControlKey(key) || (SDL.getModState() & ~SDL.kmodShift()) != 0)))) {
later = getNextKeyEvent(KEYBOARD_EVENT.CHAR, time);
}
fixKeyCodeCase();
queueEvent(getNextKeyEvent(KEYBOARD_EVENT.DOWN, time));
Expand Down Expand Up @@ -351,10 +347,8 @@ private void copyPixels(final int start, final int stop) {
}

private void render(final boolean forced) {
if (!forced) {
if (deferUpdates || !textureDirty) {
return;
}
if (!forced && (deferUpdates || !textureDirty)) {
return;
}
textureDirty = false;
unlock();
Expand Down Expand Up @@ -425,7 +419,7 @@ private void handleWindowEvent() {
final int newWidth = windowEvent.data1();
final int newHeight = windowEvent.data2();
if (newWidth != width || newHeight != height) {
// resizeTo(newWidth, newHeight);
// TODO: resizeTo(newWidth, newHeight);
}
fullDamage();
render(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ public final class SqueakImageContext {
@CompilationFinal private NativeObject debugErrorSelector = null; // for testing
@CompilationFinal private NativeObject simulatePrimitiveArgsSelector = null;
@CompilationFinal private PointersObject scheduler = null;
@CompilationFinal private boolean supportsTruffleObject = false;

public SqueakImageContext(final SqueakLanguage squeakLanguage, final SqueakLanguage.Env environment) {
language = squeakLanguage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class SqueakObjectMessageResolution {
public abstract static class BaseSqueakObjectWriteNode extends Node {
@SuppressWarnings("unused")
public Object access(final AbstractSqueakObject receiver, final Object name, final Object value) {
throw new RuntimeException("Not yet implemented");
throw new UnsupportedOperationException("Not yet implemented");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,9 @@ public enum SLOT_IDENTIFIER {
@CompilationFinal(dimensions = 1) protected byte[] bytes;
@CompilationFinal private int numArgs;
@CompilationFinal protected int numLiterals;
@CompilationFinal private boolean isOptimized;
@CompilationFinal private boolean hasPrimitive;
@CompilationFinal protected boolean needsLargeFrame = false;
@CompilationFinal private int numTemps;
@CompilationFinal private long accessModifier;
@CompilationFinal private boolean altInstructionSet;

private final int numCopiedValues; // for block closures

Expand Down Expand Up @@ -188,13 +185,13 @@ protected final void decodeHeader() {
final int hdr = getHeader();
final int[] splitHeader = BitSplitter.splitter(hdr, new int[]{15, 1, 1, 1, 6, 4, 2, 1});
numLiterals = splitHeader[0];
isOptimized = splitHeader[1] == 1;
// TODO: isOptimized = splitHeader[1] == 1;
hasPrimitive = splitHeader[2] == 1;
needsLargeFrame = splitHeader[3] == 1;
numTemps = splitHeader[4];
numArgs = splitHeader[5];
accessModifier = splitHeader[6];
altInstructionSet = splitHeader[7] == 1;
// TODO: accessModifier = splitHeader[6];
// TODO: altInstructionSet = splitHeader[7] == 1;
prepareFrameDescriptor();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@

public final class SocketPlugin extends AbstractPrimitiveFactoryHolder {

private static final EconomicMap<Long, SocketImpl> sockets = EconomicMap.create();
private static final boolean debugPrints = false;

private static byte[] lastNameLookup;
private static String lastAddressLookup;

@SuppressWarnings("unused")
private static final class ResolverStatus {
private static final long Uninitialized = 0;
Expand All @@ -46,9 +52,6 @@ private static final class ResolverStatus {
private static final long Error = 3;
}

private static byte[] lastNameLookup;
private static String lastAddressLookup;

private static final class SocketStatus {
private static final long InvalidSocket = -1;
private static final long Unconnected = 0;
Expand All @@ -63,9 +66,6 @@ private static final class SocketType {
private static final long UDPSocketType = 1;
}

private static final EconomicMap<Long, SocketImpl> sockets = EconomicMap.create();
private static final boolean debugPrints = false;

private static final class Resolver {
@SuppressWarnings("unused")
public static byte[] getLocalAddress() throws UnknownHostException {
Expand All @@ -90,8 +90,8 @@ private static final class SocketImpl {
private Socket acceptedConnection;

private Map<String, Object> options = new TreeMap<>();
boolean listening = false;
long noDataSince = -1;
private boolean listening = false;
private long noDataSince = -1;

SocketImpl(final CompiledCodeObject code, final long netType) {
this.code = code;
Expand Down Expand Up @@ -537,7 +537,7 @@ protected final Object doWork(final Object receiver, final NativeObject hostName
final String hostNameString = hostName.asString();

try {
if (hostNameString.equals("localhost")) {
if ("localhost".equals(hostNameString)) {
lastNameLookup = Resolver.getLocalAddress();
return receiver;
}
Expand Down

0 comments on commit 98decdc

Please sign in to comment.