Permalink
Browse files

musing but nowhere near anything

  • Loading branch information...
elucash committed Jul 7, 2017
1 parent ee7c2b8 commit c6a9ccd018f474dbadd87ab18dc820ad3cbc75be
@@ -26,10 +26,10 @@
<classpathentry kind="lib" path="buck-out/gen/lib/jsr305_jar/jsr305-3.0.1.jar" sourcepath="buck-out/gen/lib/jsr305_src/jsr305-3.0.1-sources.jar"/>
<classpathentry kind="lib" path="buck-out/gen/lib/junit_jar/junit-4.12.jar" sourcepath="buck-out/gen/lib/junit_src/junit-4.12-sources.jar"/>
<classpathentry kind="lib" path="buck-out/gen/lib/hamcrest_jar/hamcrest-core-1.3.jar" sourcepath="buck-out/gen/lib/hamcrest_src/hamcrest-core-1.3-sources.jar"/>
<classpathentry kind="lib" path="buck-out/gen/lib/immutables_trees_jar/trees-2.5.2.jar" sourcepath="buck-out/gen/lib/immutables_trees_src/trees-2.5.2-sources.jar"/>
<classpathentry kind="lib" path="buck-out/gen/lib/immutables_ordinal_jar/ordinal-2.5.2.jar" sourcepath="buck-out/gen/lib/immutables_ordinal_src/ordinal-2.5.2-sources.jar"/>
<classpathentry kind="lib" path="buck-out/gen/lib/immutables_annotations_jar/value-2.5.2-annotations.jar" sourcepath="buck-out/gen/lib/immutables_annotations_src/value-2.5.2-annotations-sources.jar"/>
<classpathentry kind="lib" path="buck-out/gen/lib/immutables_generator_jar/generator-processor-2.5.2-luggage.jar" sourcepath="buck-out/gen/lib/immutables_generator_src/generator-processor-2.5.2-luggage-sources.jar"/>
<classpathentry kind="lib" path="buck-out/gen/lib/immutables_trees_jar/trees-2.5.6.jar" sourcepath="buck-out/gen/lib/immutables_trees_src/trees-2.5.6-sources.jar"/>
<classpathentry kind="lib" path="buck-out/gen/lib/immutables_ordinal_jar/ordinal-2.5.6.jar" sourcepath="buck-out/gen/lib/immutables_ordinal_src/ordinal-2.5.6-sources.jar"/>
<classpathentry kind="lib" path="buck-out/gen/lib/immutables_annotations_jar/value-2.5.6-annotations.jar" sourcepath="buck-out/gen/lib/immutables_annotations_src/value-2.5.6-annotations-sources.jar"/>
<classpathentry kind="lib" path="buck-out/gen/lib/immutables_generator_jar/generator-processor-2.5.6-luggage.jar" sourcepath="buck-out/gen/lib/immutables_generator_src/generator-processor-2.5.6-luggage-sources.jar"/>
<classpathentry kind="output" path=".classes"/>
</classpath>
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<factorypath>
<factorypathentry kind="WKSPJAR" id="/nextgen/buck-out/gen/src/metainf_extensions_jar.jar" enabled="true" runInBatchMode="false"/>,
<factorypathentry kind="WKSPJAR" id="/nextgen/buck-out/gen/lib/immutables_jar/value-2.5.2.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="WKSPJAR" id="/nextgen/buck-out/gen/lib/immutables_jar/value-2.5.6.jar" enabled="true" runInBatchMode="false"/>
</factorypath>
@@ -93,16 +93,16 @@ prebuilt_jar(
remote_file(
name = 'immutables_jar',
out = 'value-2.5.2.jar',
url = 'https://repo1.maven.org/maven2/org/immutables/value/2.5.2/value-2.5.2.jar',
sha1 = '585a3c2ebd089ccadce31342c7d7b40d500c931a'
out = 'value-2.5.6.jar',
url = 'https://repo1.maven.org/maven2/org/immutables/value/2.5.6/value-2.5.6.jar',
sha1 = '0dfe48bb1214750b932cd59e6953a32a038b74fd'
)
remote_file(
name = 'immutables_src',
out = 'value-2.5.2-sources.jar',
url = 'https://repo1.maven.org/maven2/org/immutables/value/2.5.2/value-2.5.2-sources.jar',
sha1 = 'd4e122b5a00b1bcbe37b5521933284ac10b71f2b'
out = 'value-2.5.6-sources.jar',
url = 'https://repo1.maven.org/maven2/org/immutables/value/2.5.6/value-2.5.6-sources.jar',
sha1 = '02b7b4d8da9dba792f9e9afc81febd63e4cbc500'
)
prebuilt_jar(
@@ -114,16 +114,16 @@ prebuilt_jar(
remote_file(
name = 'immutables_trees_jar',
out = 'trees-2.5.2.jar',
url = 'https://repo1.maven.org/maven2/org/immutables/trees/2.5.2/trees-2.5.2.jar',
sha1 = '8ee23be4cef75a9c9f2ec0b0cd433e6cb56e8741'
out = 'trees-2.5.6.jar',
url = 'https://repo1.maven.org/maven2/org/immutables/trees/2.5.6/trees-2.5.6.jar',
sha1 = '3c5921d31118720447f70cab5a76fb9e5791f71d'
)
remote_file(
name = 'immutables_trees_src',
out = 'trees-2.5.2-sources.jar',
url = 'https://repo1.maven.org/maven2/org/immutables/trees/2.5.2/trees-2.5.2-sources.jar',
sha1 = '1b6a616defcb2836b446b13d3a2b5a02c401e66b'
out = 'trees-2.5.6-sources.jar',
url = 'https://repo1.maven.org/maven2/org/immutables/trees/2.5.6/trees-2.5.6-sources.jar',
sha1 = '9eed1438eeef67a401db2be3daea3b5dcd8b0d84'
)
prebuilt_jar(
@@ -135,16 +135,16 @@ prebuilt_jar(
remote_file(
name = 'immutables_ordinal_jar',
out = 'ordinal-2.5.2.jar',
url = 'https://repo1.maven.org/maven2/org/immutables/ordinal/2.5.2/ordinal-2.5.2.jar',
sha1 = '27ff49b5106535835b39145330d59170991ad232'
out = 'ordinal-2.5.6.jar',
url = 'https://repo1.maven.org/maven2/org/immutables/ordinal/2.5.6/ordinal-2.5.6.jar',
sha1 = '3713d9be1e86b4ea6169b0ea37a9a5c5db787616'
)
remote_file(
name = 'immutables_ordinal_src',
out = 'ordinal-2.5.2-sources.jar',
url = 'https://repo1.maven.org/maven2/org/immutables/ordinal/2.5.2/ordinal-2.5.2-sources.jar',
sha1 = 'd70e506a99534b0d979d9643035b629c5b1ff387'
out = 'ordinal-2.5.6-sources.jar',
url = 'https://repo1.maven.org/maven2/org/immutables/ordinal/2.5.6/ordinal-2.5.6-sources.jar',
sha1 = 'c7e928d2247cdcf9ef9a5302d63adff8ebb6dee0'
)
prebuilt_jar(
@@ -156,16 +156,16 @@ prebuilt_jar(
remote_file(
name = 'immutables_annotations_jar',
out = 'value-2.5.2-annotations.jar',
url = 'https://repo1.maven.org/maven2/org/immutables/value/2.5.2/value-2.5.2-annotations.jar',
sha1 = '8f015c5d9c27554db6d1746a6f1a8dd8fae792ee'
out = 'value-2.5.6-annotations.jar',
url = 'https://repo1.maven.org/maven2/org/immutables/value/2.5.6/value-2.5.6-annotations.jar',
sha1 = 'b6a247a2b31a87f0d20d854308e48708b203a0e4'
)
remote_file(
name = 'immutables_annotations_src',
out = 'value-2.5.2-annotations-sources.jar',
url = 'https://repo1.maven.org/maven2/org/immutables/value/2.5.2/value-2.5.2-annotations-sources.jar',
sha1 = '382f9817f79ede57155dbac7b34543d1ca1a35c3'
out = 'value-2.5.6-annotations-sources.jar',
url = 'https://repo1.maven.org/maven2/org/immutables/value/2.5.6/value-2.5.6-annotations-sources.jar',
sha1 = '7c2a910c05f63191ada34b193c815bb119e68f6f'
)
prebuilt_jar(
@@ -178,14 +178,14 @@ prebuilt_jar(
remote_file(
name = 'immutables_generator_jar',
out = 'generator-processor-2.5.2-luggage.jar',
url = 'https://repo1.maven.org/maven2/org/immutables/generator-processor/2.5.2/generator-processor-2.5.2-luggage.jar',
sha1 = '5bb8a4fdf28b90288308dd6736c47117f219a0e9'
out = 'generator-processor-2.5.6-luggage.jar',
url = 'https://repo1.maven.org/maven2/org/immutables/generator-processor/2.5.6/generator-processor-2.5.6-luggage.jar',
sha1 = 'b8d70c5b0b34d1d8da21365f315d4e15b0687577'
)
remote_file(
name = 'immutables_generator_src',
out = 'generator-processor-2.5.2-luggage-sources.jar',
url = 'https://repo1.maven.org/maven2/org/immutables/generator-processor/2.5.2/generator-processor-2.5.2-luggage-sources.jar',
sha1 = 'fd719e055aa6b0f0af03775577624908404c7169'
out = 'generator-processor-2.5.6-luggage-sources.jar',
url = 'https://repo1.maven.org/maven2/org/immutables/generator-processor/2.5.6/generator-processor-2.5.6-luggage-sources.jar',
sha1 = '687608df93b7f7d6263cd8f088faa319348f8ae2'
)
12 prj.js
@@ -6,12 +6,12 @@ l.project({
jsr305: 'com.google.code.findbugs:jsr305:3.0.1',
junit: 'junit:junit:4.12',
hamcrest: 'org.hamcrest:hamcrest-core:1.3',
immutables: 'org.immutables:value:2.5.2',
immutables_trees: 'org.immutables:trees:2.5.2',
immutables_ordinal: 'org.immutables:ordinal:2.5.2',
immutables_annotations: 'org.immutables:value:2.5.2:annotations',
immutables_generator: 'org.immutables:generator-processor:2.5.2:luggage',
// immutables_gson: 'org.immutables:gson:2.5.2',
immutables: 'org.immutables:value:2.5.6',
immutables_trees: 'org.immutables:trees:2.5.6',
immutables_ordinal: 'org.immutables:ordinal:2.5.6',
immutables_annotations: 'org.immutables:value:2.5.6:annotations',
immutables_generator: 'org.immutables:generator-processor:2.5.6:luggage',
// immutables_gson: 'org.immutables:gson:2.5.6',
// gson: 'com.google.code.gson:gson:2.8.0',
// jackson: 'com.fasterxml.jackson.core:jackson-core:2.8.5',
// jackson_yaml: 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.8.5',
@@ -1,15 +1,16 @@
package io.immutables.grammar;
package io.immutables;
import java.util.Arrays;
/**
* Ensures capacity for int and long arrays with 2x increase in size and trying to avoid oveflows
* Ensures capacity for arrays by nearest larger power of 2 increase in size and trying to avoid
* oveflows
* until max size for array is reached.
*/
final class Capacity {
public final class Capacity {
private Capacity() {}
static int[] ensure(int[] elements, int limit, int increment) {
public static int[] ensure(int[] elements, int limit, int increment) {
int oldCapacity = elements.length;
// check is made this way to avoid overflow
if (oldCapacity - limit < increment) {
@@ -35,7 +36,33 @@ private Capacity() {}
return elements;
}
static long[] ensure(long[] elements, int limit, int increment) {
public static long[] ensure(long[] elements, int limit, int increment) {
int oldCapacity = elements.length;
// check is made this way to avoid overflow
if (oldCapacity - limit < increment) {
int requiredCapacity = oldCapacity + increment;
int newCapacity;
// checking for overflow
if (requiredCapacity < oldCapacity) {
newCapacity = Integer.MAX_VALUE;
} else {
newCapacity = oldCapacity << 1;
if (newCapacity < requiredCapacity) {
newCapacity = Integer.highestOneBit(requiredCapacity - 1) << 1;
}
if (newCapacity == 0) {
newCapacity = requiredCapacity;
}
if (newCapacity < 0) {
newCapacity = Integer.MAX_VALUE;
}
}
elements = Arrays.copyOf(elements, newCapacity);
}
return elements;
}
public static Object[] ensure(Object[] elements, int limit, int increment) {
int oldCapacity = elements.length;
// check is made this way to avoid overflow
if (oldCapacity - limit < increment) {
@@ -1,5 +1,6 @@
package io.immutables.collect;
import io.immutables.Capacity;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
@@ -24,8 +25,8 @@
/**
* Minimalistic wrapper around array. We use it over ImmutableList because we want monomorphic call
* sites, no unsupported mutation methods, minimum memory overhead, no views, have mini-pattern
* matching, shorter classname.
* sites, no unsupported mutation methods, minimum memory overhead, no views, have simplistic
* pattern matching capability and short classname.
* @param <E> element type
*/
@Immutable
@@ -326,24 +327,7 @@ public String toString() {
}
private void ensureCapacityFor(int increment) {
int oldCapacity = elements.length;
if (oldCapacity - size < increment) {
int requiredCapacity = oldCapacity + increment;
int newCapacity;
// checking for overflow
if (requiredCapacity < oldCapacity) {
newCapacity = Integer.MAX_VALUE;
} else {
newCapacity = oldCapacity + (oldCapacity >> 1) + 1;
if (newCapacity < requiredCapacity) {
newCapacity = Integer.highestOneBit(requiredCapacity - 1) << 1;
}
if (newCapacity < 0) {
newCapacity = Integer.MAX_VALUE;
}
}
elements = Arrays.copyOf(elements, newCapacity);
}
elements = Capacity.ensure(elements, size, increment);
}
public Vect<E> build() {
@@ -2,6 +2,7 @@
import com.google.common.base.Strings;
import com.google.common.primitives.Shorts;
import io.immutables.Capacity;
import java.util.NoSuchElementException;
/**
@@ -2,6 +2,7 @@
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import io.immutables.Capacity;
import io.immutables.Unreachable;
import java.util.Arrays;
import java.util.List;
@@ -1,5 +1,6 @@
package io.immutables.grammar;
import io.immutables.Capacity;
import java.util.NoSuchElementException;
import javax.annotation.concurrent.NotThreadSafe;
import javax.annotation.concurrent.ThreadSafe;
@@ -0,0 +1,27 @@
package io.immutables.lang.type;
import io.immutables.collect.Vect;
import io.immutables.lang.type.Type.Declared;
import org.immutables.value.Value.Immutable;
@Immutable
abstract class DefinedImpl implements Declared {
private final int hashCode = System.identityHashCode(this);
@Override
public DefinedImpl applyArguments(Vect<Type> arguments) {
throw new UnsupportedOperationException();
}
@Override
public boolean equals(Object obj) {
return this == obj;
}
@Override
public int hashCode() {
return hashCode;
}
static final class Builder extends ImmutableDefinedImpl.Builder {}
}
@@ -0,0 +1,7 @@
package io.immutables.lang.type;
interface Resolvers {
public static void main(String... args) {
}
}

This file was deleted.

Oops, something went wrong.
@@ -1,10 +1,16 @@
package io.immutables.lang.type;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
public class TestType {
final Map<Name, Type> types = new HashMap<>();
final Type.Resolver resolver = n -> types.computeIfAbsent(n, k -> Type.Unresolved.of(k));
@Test
public void test() {
// add(Type.Variable.)
}
}
Oops, something went wrong.

0 comments on commit c6a9ccd

Please sign in to comment.