Skip to content

Commit

Permalink
Remove several unused ValueFactory methods
Browse files Browse the repository at this point in the history
  • Loading branch information
SquidDev committed Aug 31, 2023
1 parent 612b5eb commit e0d7690
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 89 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cc.tweaked.internal.string;
package cc.tweaked.cobalt.internal.string;

/**
* Various properties on characters, as used by the lexer and
* Various properties on characters, as used by the lexer, and other parsers within the codebase.
*/
public final class CharProperties {
private CharProperties() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cc.tweaked.internal.string;
package cc.tweaked.cobalt.internal.string;

import org.squiddev.cobalt.lib.StringLib;

Expand Down
4 changes: 1 addition & 3 deletions src/main/java/org/squiddev/cobalt/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public class Constants {
/**
* LuaValue constant corresponding to a {@link Varargs} list of no values
*/
public static final Varargs NONE = None._NONE;
public static final Varargs NONE = new None();

/**
* LuaValue number constant equal to 0
Expand Down Expand Up @@ -268,8 +268,6 @@ public class Constants {
* @see Constants#NONE
*/
private static final class None extends Varargs {
static None _NONE = new None();

@Override
public LuaValue arg(int i) {
return NIL;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/squiddev/cobalt/LuaString.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
package org.squiddev.cobalt;

import cc.tweaked.internal.string.NumberParser;
import cc.tweaked.cobalt.internal.string.NumberParser;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.framework.qual.DefaultQualifier;

Expand Down
77 changes: 0 additions & 77 deletions src/main/java/org/squiddev/cobalt/ValueFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,6 @@ public static LuaTable tableOf() {
return new LuaTable();
}

/**
* Construct an empty {@link LuaTable} preallocated to hold array and hashed elements
*
* @param narray Number of array elements to preallocate
* @param nhash Number of hash elements to preallocate
* @return new {@link LuaTable} instance with no values and no metatable, but preallocated for array and hashed elements.
*/
public static LuaTable tableOf(int narray, int nhash) {
return new LuaTable(narray, nhash);
}

/**
* Construct a {@link LuaTable} initialized with supplied array values.
*
Expand All @@ -124,18 +113,6 @@ public static LuaTable listOf(LuaValue... unnamedValues) {
return new LuaTable(null, unnamedValues, null);
}

/**
* Construct a {@link LuaTable} initialized with supplied array values.
*
* @param unnamedValues array of {@link LuaValue} containing the first values to use in initialization
* @param lastarg {@link Varargs} containing additional values to use in initialization
* to be put after the last unnamedValues element
* @return new {@link LuaTable} instance with sequential elements coming from the array and varargs.
*/
public static LuaTable listOf(LuaValue[] unnamedValues, Varargs lastarg) {
return new LuaTable(null, unnamedValues, lastarg);
}

/**
* Construct a {@link LuaTable} initialized with supplied named values.
*
Expand All @@ -147,38 +124,6 @@ public static LuaTable tableOf(LuaValue... namedValues) {
return new LuaTable(namedValues, null, null);
}

/**
* Construct a {@link LuaTable} initialized with supplied named values and sequential elements.
* The named values will be assigned first, and the sequential elements will be assigned later,
* possibly overwriting named values at the same slot if there are conflicts.
*
* @param namedValues array of {@link LuaValue} containing the keys and values to use in initialization
* in order {@code {key-a, value-a, key-b, value-b, ...} }
* @param unnamedValues array of {@link LuaValue} containing the sequenctial elements to use in initialization
* in order {@code {value-1, value-2, ...} }, or null if there are none
* @return new {@link LuaTable} instance with named and sequential values supplied.
*/
public static LuaTable tableOf(LuaValue[] namedValues, LuaValue[] unnamedValues) {
return new LuaTable(namedValues, unnamedValues, null);
}

/**
* Construct a {@link LuaTable} initialized with supplied named values and sequential elements in an array part and as varargs.
* The named values will be assigned first, and the sequential elements will be assigned later,
* possibly overwriting named values at the same slot if there are conflicts.
*
* @param namedValues array of {@link LuaValue} containing the keys and values to use in initialization
* in order {@code {key-a, value-a, key-b, value-b, ...} }
* @param unnamedValues array of {@link LuaValue} containing the first sequenctial elements to use in initialization
* in order {@code {value-1, value-2, ...} }, or null if there are none
* @param lastarg {@link Varargs} containing additional values to use in the sequential part of the initialization,
* to be put after the last unnamedValues element
* @return new {@link LuaTable} instance with named and sequential values supplied.
*/
public static LuaTable tableOf(LuaValue[] namedValues, LuaValue[] unnamedValues, Varargs lastarg) {
return new LuaTable(namedValues, unnamedValues, lastarg);
}

/**
* Construct a LuaUserdata for an object.
*
Expand Down Expand Up @@ -246,27 +191,6 @@ public static Varargs varargsOf(final List<LuaValue> v) {
};
}

/**
* Construct a {@link Varargs} around an array of {@link LuaValue}s.
*
* @param v The array of {@link LuaValue}s
* @param r {@link Varargs} contain values to include at the end
* @return {@link Varargs} wrapping the supplied values.
* @see ValueFactory#varargsOf(LuaValue[])
* @see ValueFactory#varargsOfCopy(LuaValue[], int, int, Varargs)
*/
public static Varargs varargsOf(final LuaValue[] v, Varargs r) {
if (v.length == 0) return r;

if (Varargs.DepthVarargs.depth(r) > MAX_DEPTH) {
LuaValue[] values = Arrays.copyOf(v, v.length + r.count());
r.fill(values, v.length);
return new LuaValue.ArrayVarargs(values, Constants.NONE);
}

return v.length == 1 ? new LuaValue.PairVarargs(v[0], r) : new LuaValue.ArrayVarargs(v, r);
}

/**
* Construct a {@link Varargs} around an array of {@link LuaValue}s.
*
Expand Down Expand Up @@ -294,7 +218,6 @@ public static Varargs varargsOfCopy(final LuaValue[] v, final int offset, final
* @param length number of values to include from the array
* @param more {@link Varargs} contain values to include at the end
* @return {@link Varargs} wrapping the supplied values.
* @see ValueFactory#varargsOf(LuaValue[], Varargs)
* @see ValueFactory#varargsOfCopy(LuaValue[], int, int)
*/
public static Varargs varargsOfCopy(final LuaValue[] v, final int offset, final int length, Varargs more) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/squiddev/cobalt/compiler/Lex.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.squiddev.cobalt.compiler;

import cc.tweaked.internal.string.CharProperties;
import cc.tweaked.internal.string.NumberParser;
import cc.tweaked.cobalt.internal.string.CharProperties;
import cc.tweaked.cobalt.internal.string.NumberParser;
import org.squiddev.cobalt.*;
import org.squiddev.cobalt.lib.Utf8Lib;
import org.squiddev.cobalt.unwind.AutoUnwind;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/squiddev/cobalt/lib/FormatDesc.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
package org.squiddev.cobalt.lib;

import cc.tweaked.cobalt.internal.doubles.DoubleToStringConverter;
import cc.tweaked.internal.string.CharProperties;
import cc.tweaked.cobalt.internal.string.CharProperties;
import org.squiddev.cobalt.Buffer;
import org.squiddev.cobalt.LuaError;
import org.squiddev.cobalt.LuaString;
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/org/squiddev/cobalt/lib/StringMatch.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.squiddev.cobalt.lib;

import cc.tweaked.cobalt.internal.string.CharProperties;
import org.squiddev.cobalt.*;
import org.squiddev.cobalt.function.VarArgFunction;

Expand Down Expand Up @@ -32,10 +33,10 @@ class StringMatch {
for (int i = 0; i < 256; ++i) {
byte mask = 0;
if (i <= ' ' || i == 0x7f) mask |= MASK_CONTROL;
if (i >= '0' && i <= '9') mask |= MASK_DIGIT;
if (CharProperties.isDigit(i)) mask |= MASK_DIGIT;
if (i >= 'a' && i <= 'z') mask |= MASK_LOWERCASE;
if (i >= 'A' && i <= 'Z') mask |= MASK_UPPERCASE;
if ((i >= 'a' && i <= 'f') || (i >= 'A' && i <= 'F') || (i >= '0' && i <= '9')) mask |= MASK_HEXDIGIT;
if (CharProperties.isHex(i)) mask |= MASK_HEXDIGIT;
if ((i >= '!' && i <= '/') || (i >= ':' && i <= '@') || (i >= '[' && i <= '`') || (i >= '{' && i <= '~')) {
mask |= MASK_PUNCT;
}
Expand Down

0 comments on commit e0d7690

Please sign in to comment.