mirror of
https://github.com/corda/corda.git
synced 2025-01-07 13:38:47 +00:00
Adds code to get the Scala REPL working
This commit is contained in:
parent
0c5471d25e
commit
b1eb4b9718
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2012, Avian Contributors
|
||||
/* Copyright (c) 2008-2013, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
@ -16,6 +16,11 @@ public class File implements Serializable {
|
||||
|
||||
public static final String separator = FileSeparator;
|
||||
|
||||
private static final String PathSeparator
|
||||
= System.getProperty("path.separator");
|
||||
|
||||
public static final String pathSeparator = PathSeparator;
|
||||
|
||||
// static {
|
||||
// System.loadLibrary("natives");
|
||||
// }
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008, Avian Contributors
|
||||
/* Copyright (c) 2008-2013, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
@ -94,6 +94,27 @@ public final class Integer extends Number implements Comparable<Integer> {
|
||||
return (double) value;
|
||||
}
|
||||
|
||||
public static int signum(int v) {
|
||||
if (v == 0) return 0;
|
||||
else if (v > 0) return 1;
|
||||
else return -1;
|
||||
}
|
||||
|
||||
// See http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
|
||||
public static int bitCount(int v) {
|
||||
v = v - ((v >> 1) & 0x55555555);
|
||||
v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
|
||||
return ((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
|
||||
}
|
||||
|
||||
public static int reverseBytes(int v) {
|
||||
int byte3 = v >>> 24;
|
||||
int byte2 = (v >>> 8) & 0xFF00;
|
||||
int byte1 = (v << 8) & 0xFF00;
|
||||
int byte0 = v << 24;
|
||||
return (byte0 | byte1 | byte2 | byte3);
|
||||
}
|
||||
|
||||
public static int parseInt(String s) {
|
||||
return parseInt(s, 10);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2008-2010, Avian Contributors
|
||||
/* Copyright (c) 2008-2013, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
@ -126,6 +126,12 @@ public final class Long extends Number implements Comparable<Long> {
|
||||
return (double) value;
|
||||
}
|
||||
|
||||
public static int signum(long v) {
|
||||
if (v == 0) return 0;
|
||||
else if (v > 0) return 1;
|
||||
else return -1;
|
||||
}
|
||||
|
||||
private static long pow(long a, long b) {
|
||||
long c = 1;
|
||||
for (int i = 0; i < b; ++i) c *= a;
|
||||
|
44
classpath/java/math/BigInteger.java
Normal file
44
classpath/java/math/BigInteger.java
Normal file
@ -0,0 +1,44 @@
|
||||
/* Copyright (c) 2013, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
that the above copyright notice and this permission notice appear
|
||||
in all copies.
|
||||
|
||||
There is NO WARRANTY for this software. See license.txt for
|
||||
details. */
|
||||
|
||||
package java.math;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class BigInteger implements Serializable {
|
||||
|
||||
private int sign;
|
||||
private int[] value;
|
||||
|
||||
private BigInteger(int sign, long value) {
|
||||
this.sign = sign;
|
||||
int upperBits = (int) (value >>> 32);
|
||||
if (upperBits == 0)
|
||||
// Array with one element
|
||||
this.value = new int[] { (int) value };
|
||||
else
|
||||
// Array with two elements
|
||||
this.value = new int[] { (int) value, upperBits };
|
||||
}
|
||||
|
||||
public static final BigInteger ZERO = new BigInteger(0, 0);
|
||||
public static final BigInteger ONE = new BigInteger(1, 1);
|
||||
public static final BigInteger TEN = new BigInteger(1, 10);
|
||||
|
||||
public static BigInteger valueOf(long num) {
|
||||
int signum = Long.signum(num);
|
||||
if (signum == 0)
|
||||
return BigInteger.ZERO;
|
||||
else if (signum > 0)
|
||||
return new BigInteger(signum, num);
|
||||
else
|
||||
return new BigInteger(signum, -num);
|
||||
}
|
||||
}
|
71
classpath/java/math/MathContext.java
Normal file
71
classpath/java/math/MathContext.java
Normal file
@ -0,0 +1,71 @@
|
||||
/* Copyright (c) 2013, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
that the above copyright notice and this permission notice appear
|
||||
in all copies.
|
||||
|
||||
There is NO WARRANTY for this software. See license.txt for
|
||||
details. */
|
||||
|
||||
package java.math;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public final class MathContext implements Serializable {
|
||||
|
||||
public static final MathContext DECIMAL32 = new MathContext( 7, RoundingMode.HALF_EVEN);
|
||||
public static final MathContext DECIMAL64 = new MathContext(16, RoundingMode.HALF_EVEN);
|
||||
public static final MathContext DECIMAL128 = new MathContext(34, RoundingMode.HALF_EVEN);
|
||||
public static final MathContext UNLIMITED = new MathContext(0, RoundingMode.HALF_UP);
|
||||
|
||||
private int precision;
|
||||
private RoundingMode roundingMode;
|
||||
|
||||
public MathContext(int precision, RoundingMode roundingMode) {
|
||||
if (precision < 0)
|
||||
throw new IllegalArgumentException();
|
||||
if (roundingMode == null)
|
||||
throw new NullPointerException();
|
||||
this.precision = precision;
|
||||
this.roundingMode = roundingMode;
|
||||
}
|
||||
|
||||
public MathContext(int precision) {
|
||||
this(precision, RoundingMode.HALF_UP);
|
||||
}
|
||||
|
||||
public int getPrecision() {
|
||||
return precision;
|
||||
}
|
||||
|
||||
public RoundingMode getRoundingMode() {
|
||||
return roundingMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
return
|
||||
(that instanceof MathContext) &&
|
||||
(precision == ((MathContext) that).getPrecision()) &&
|
||||
(roundingMode == ((MathContext) that).getRoundingMode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return
|
||||
roundingMode.ordinal() |
|
||||
(precision << 4);
|
||||
}
|
||||
|
||||
private final static String precisionString = "precision=";
|
||||
private final static String roundingModeString = " roundingMode=";
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder(48);
|
||||
sb.append(precisionString).append(precision);
|
||||
sb.append(roundingModeString).append(roundingMode);
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
36
classpath/java/math/RoundingMode.java
Normal file
36
classpath/java/math/RoundingMode.java
Normal file
@ -0,0 +1,36 @@
|
||||
/* Copyright (c) 2013, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
that the above copyright notice and this permission notice appear
|
||||
in all copies.
|
||||
|
||||
There is NO WARRANTY for this software. See license.txt for
|
||||
details. */
|
||||
|
||||
package java.math;
|
||||
|
||||
public enum RoundingMode {
|
||||
|
||||
UP (0),
|
||||
DOWN (1),
|
||||
CEILING (2),
|
||||
FLOOR (3),
|
||||
HALF_UP (4),
|
||||
HALF_DOWN (5),
|
||||
HALF_EVEN (6),
|
||||
UNNECESSARY(7);
|
||||
|
||||
RoundingMode(int rm) {
|
||||
roundingMode = rm;
|
||||
}
|
||||
|
||||
private final int roundingMode;
|
||||
|
||||
public static RoundingMode valueOf(int roundingMode) {
|
||||
final RoundingMode[] values = values();
|
||||
if (roundingMode < 0 || roundingMode >= values.length)
|
||||
throw new IllegalArgumentException();
|
||||
return values[roundingMode];
|
||||
}
|
||||
}
|
27
classpath/java/util/jar/Attributes.java
Normal file
27
classpath/java/util/jar/Attributes.java
Normal file
@ -0,0 +1,27 @@
|
||||
/* Copyright (c) 2013, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
that the above copyright notice and this permission notice appear
|
||||
in all copies.
|
||||
|
||||
There is NO WARRANTY for this software. See license.txt for
|
||||
details. */
|
||||
|
||||
package java.util.jar;
|
||||
|
||||
public class Attributes {
|
||||
public static class Name {
|
||||
private final String name;
|
||||
|
||||
private static final int MAX_NAME_LENGTH = 70;
|
||||
|
||||
public Name(String s) {
|
||||
int len = s.length();
|
||||
if (len == 0 || len > MAX_NAME_LENGTH)
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
name = s;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user