mirror of
https://github.com/octoleo/plantuml.git
synced 2025-01-24 23:58:33 +00:00
chore: improve error message when missing stdlib
https://github.com/plantuml/plantuml/pull/1692#issuecomment-1952831187
This commit is contained in:
parent
5fe5cafe70
commit
2a961129f2
@ -332,6 +332,9 @@ public class Stdlib {
|
||||
private static Collection<String> getAll() throws IOException {
|
||||
final Set<String> result = new TreeSet<>();
|
||||
final InputStream home = getInternalInputStream("home", ".repx");
|
||||
if (home == null)
|
||||
throw new IOException("Cannot access to /stdlib/*.repx files");
|
||||
|
||||
final BufferedReader br = new BufferedReader(new InputStreamReader(home));
|
||||
String name;
|
||||
while ((name = br.readLine()) != null)
|
||||
|
@ -69,6 +69,7 @@ public class TFunctionImpl implements TFunction {
|
||||
this.functionType = functionType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArguments) {
|
||||
for (String n : namedArguments)
|
||||
if (signature.getNamedArguments().contains(n) == false)
|
||||
@ -140,8 +141,9 @@ public class TFunctionImpl implements TFunction {
|
||||
context.executeLines(copy, body, TFunctionType.PROCEDURE, false);
|
||||
}
|
||||
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> args,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location,
|
||||
List<TValue> args, Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
if (functionType == TFunctionType.LEGACY_DEFINE)
|
||||
return executeReturnLegacyDefine(location, context, memory, args);
|
||||
|
||||
|
@ -52,10 +52,12 @@ public class AlwaysFalse extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%false", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
return TValue.fromBoolean(false);
|
||||
|
@ -52,10 +52,12 @@ public class AlwaysTrue extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%true", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
return TValue.fromBoolean(true);
|
||||
|
@ -53,10 +53,12 @@ public class CallUserFunction extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%call_user_func", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
final String fname = values.get(0).toString();
|
||||
|
@ -52,10 +52,12 @@ public class Chr extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%chr", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
try {
|
||||
|
@ -56,10 +56,12 @@ public class Darken extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%darken", 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
final String colorString = values.get(0).toString();
|
||||
|
@ -54,10 +54,12 @@ public class DateFunction extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%date", 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 0 || nbArg == 1 || nbArg == 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
if (values.size() == 0)
|
||||
|
@ -52,10 +52,12 @@ public class Dec2hex extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%dec2hex", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
try {
|
||||
|
@ -59,10 +59,12 @@ public class Dirpath extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%dirpath", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
if (value == null) {
|
||||
|
@ -53,10 +53,12 @@ public class Eval extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%eval", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
final String exp = values.get(0).toString();
|
||||
|
@ -52,10 +52,12 @@ public class Feature extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%feature", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
final String arg = values.get(0).toString();
|
||||
|
@ -53,10 +53,12 @@ public class FileExists extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%file_exists", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
// ::comment when __CORE__
|
||||
|
@ -59,10 +59,12 @@ public class Filename extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%filename", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
if (value == null) {
|
||||
|
@ -53,10 +53,12 @@ public class FunctionExists extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%function_exists", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
final String name = values.get(0).toString();
|
||||
|
@ -56,10 +56,12 @@ public class GetAllTheme extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%get_all_theme", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
final JsonArray result = new JsonArray();
|
||||
|
@ -55,10 +55,12 @@ public class GetJsonKey extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%get_json_keys", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
final TValue data = values.get(0);
|
||||
|
@ -53,10 +53,12 @@ public class GetJsonType extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%get_json_type", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
final TValue data = values.get(0);
|
||||
|
@ -52,10 +52,12 @@ public class GetVariableValue extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%get_variable_value", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
final String name = values.get(0).toString();
|
||||
|
@ -53,10 +53,12 @@ public class GetVersion extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%version", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
return TValue.fromString(Version.versionString());
|
||||
|
@ -53,10 +53,12 @@ public class Getenv extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%getenv", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
// ::comment when __CORE__
|
||||
|
@ -52,10 +52,12 @@ public class Hex2dec extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%hex2dec", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
try {
|
||||
|
@ -55,10 +55,12 @@ public class HslColor extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%hsl_color", 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 3 || nbArg == 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
final int h = values.get(0).toInt();
|
||||
|
@ -53,10 +53,12 @@ public class IntVal extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%intval", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
final String s = values.get(0).toString();
|
||||
|
@ -54,6 +54,7 @@ public class InvokeProcedure implements TFunction {
|
||||
return new TFunctionSignature("%invoke_procedure", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg > 0;
|
||||
}
|
||||
@ -75,6 +76,7 @@ public class InvokeProcedure implements TFunction {
|
||||
func.executeProcedureInternal(context, memory, sublist, named);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) {
|
||||
throw new UnsupportedOperationException();
|
||||
|
@ -56,10 +56,12 @@ public class IsDark extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%is_dark", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
final String colorString = values.get(0).toString();
|
||||
|
@ -56,10 +56,12 @@ public class IsLight extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%is_light", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
final String colorString = values.get(0).toString();
|
||||
|
@ -54,10 +54,12 @@ public class JsonKeyExists extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%json_key_exists", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
final TValue arg0 = values.get(0);
|
||||
|
@ -56,10 +56,12 @@ public class Lighten extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%lighten", 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
final String colorString = values.get(0).toString();
|
||||
|
@ -102,10 +102,12 @@ public class LoadJson extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%load_json", 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 1 || nbArg == 2 || nbArg == 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
final String path = values.get(0).toString();
|
||||
|
@ -52,10 +52,12 @@ public class LogicalAnd extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%and", 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg >= 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
for (TValue v : values)
|
||||
|
@ -52,10 +52,12 @@ public class LogicalNand extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%nand", 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg >= 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
for (TValue v : values)
|
||||
|
@ -52,10 +52,12 @@ public class LogicalNor extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%nor", 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg >= 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
for (TValue v : values)
|
||||
|
@ -52,10 +52,12 @@ public class LogicalNot extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%not", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
final boolean arg = values.get(0).toBoolean();
|
||||
|
@ -52,10 +52,12 @@ public class LogicalNxor extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%nxor", 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg >= 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
int cpt = 0;
|
||||
|
@ -52,10 +52,12 @@ public class LogicalOr extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%or", 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg >= 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
for (TValue v : values)
|
||||
|
@ -52,10 +52,12 @@ public class LogicalXor extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%xor", 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg >= 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
int cpt = 0;
|
||||
|
@ -50,10 +50,12 @@ public class Lower extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%lower", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) {
|
||||
return TValue.fromString(values.get(0).toString().toLowerCase());
|
||||
|
@ -50,10 +50,12 @@ public class Newline extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%newline", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) {
|
||||
return TValue.fromString("\n");
|
||||
|
@ -52,10 +52,12 @@ public class Now extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%now", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
final long now = System.currentTimeMillis() / 1000L;
|
||||
|
@ -52,10 +52,12 @@ public class Ord extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%ord", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
try {
|
||||
|
@ -53,12 +53,14 @@ public class RandomFunction extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%random", 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 0 || nbArg == 1 || nbArg == 2;
|
||||
}
|
||||
|
||||
private final Random random = new Random();
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
switch (values.size()) {
|
||||
|
@ -54,10 +54,12 @@ public class RetrieveProcedure extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%retrieve_procedure", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
final String fname = values.get(0).toString();
|
||||
|
@ -55,10 +55,12 @@ public class ReverseColor extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%reverse_color", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
final String colorString = values.get(0).toString();
|
||||
|
@ -55,10 +55,12 @@ public class ReverseHsluvColor extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%reverse_hsluv_color", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
final String colorString = values.get(0).toString();
|
||||
|
@ -53,10 +53,12 @@ public class SetVariableValue extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%set_variable_value", 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
// if (memory instanceof TMemoryLocal) {
|
||||
|
@ -55,10 +55,12 @@ public class Size extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%size", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
final TValue value = values.get(0);
|
||||
|
@ -54,10 +54,12 @@ public class SplitStr extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%splitstr", 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
final JsonArray result = new JsonArray();
|
||||
|
@ -50,10 +50,12 @@ public class StringFunction extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%string", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) {
|
||||
return TValue.fromString(values.get(0).toString());
|
||||
|
@ -52,10 +52,12 @@ public class Strlen extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%strlen", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
return TValue.fromInt(values.get(0).toString().length());
|
||||
|
@ -52,10 +52,12 @@ public class Strpos extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%strpos", 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
final String full = values.get(0).toString();
|
||||
|
@ -52,10 +52,12 @@ public class Substr extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%substr", 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 2 || nbArg == 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
final String full = values.get(0).toString();
|
||||
|
@ -50,10 +50,12 @@ public class Upper extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%upper", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) {
|
||||
return TValue.fromString(values.get(0).toString().toUpperCase());
|
||||
|
@ -52,10 +52,12 @@ public class VariableExists extends SimpleReturnFunction {
|
||||
return new TFunctionSignature("%variable_exists", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCover(int nbArg, Set<String> namedArgument) {
|
||||
return nbArg == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||
final String name = values.get(0).toString();
|
||||
|
Loading…
x
Reference in New Issue
Block a user