Move classes to separate modules

This commit is contained in:
aNNiMON 2023-08-26 17:19:03 +03:00 committed by Victor Melnik
parent 3aedda0e93
commit 219d654fe5
283 changed files with 722 additions and 714 deletions

View File

@ -6,19 +6,12 @@ import java.util.Map;
public final class functional_foreach implements Function {
private static final int UNKNOWN = -1;
@Override
public Value execute(Value... args) {
Arguments.check(2, args.length);
final Value container = args[0];
final Function consumer = ValueUtils.consumeFunction(args[1], 1);
final int argsCount;
if (consumer instanceof UserDefinedFunction) {
argsCount = ((UserDefinedFunction) consumer).getArgsCount();
} else {
argsCount = UNKNOWN;
}
final int argsCount = consumer.getArgsCount();
switch (container.type()) {
case Types.STRING:

View File

@ -1,6 +1,7 @@
package com.annimon.ownlang.modules.std;
import com.annimon.ownlang.Main;
import com.annimon.ownlang.Shared;
import com.annimon.ownlang.Version;
import com.annimon.ownlang.lib.*;
import com.annimon.ownlang.modules.Module;
@ -13,17 +14,17 @@ public final class std implements Module {
public static void initConstants() {
MapValue ownlang = new MapValue(5);
ownlang.set("PLATFORM", new StringValue("desktop"));
ownlang.set("VERSION", new StringValue(Main.VERSION));
ownlang.set("VERSION_MAJOR", NumberValue.of(Main.VERSION_MAJOR));
ownlang.set("VERSION_MINOR", NumberValue.of(Main.VERSION_MINOR));
ownlang.set("VERSION_PATCH", NumberValue.of(Main.VERSION_PATCH));
ownlang.set("VERSION", new StringValue(Version.VERSION));
ownlang.set("VERSION_MAJOR", NumberValue.of(Version.VERSION_MAJOR));
ownlang.set("VERSION_MINOR", NumberValue.of(Version.VERSION_MINOR));
ownlang.set("VERSION_PATCH", NumberValue.of(Version.VERSION_PATCH));
Variables.define("OwnLang", ownlang);
}
@Override
public void init() {
initConstants();
Variables.define("ARGS", ArrayValue.of(Main.getOwnlangArgs())); // is not constant
Variables.define("ARGS", ArrayValue.of(Shared.getOwnlangArgs())); // is not constant
Functions.set("echo", new std_echo());
Functions.set("readln", new std_readln());
Functions.set("length", new std_length());

View File

@ -22,11 +22,7 @@ public final class std_length implements Function {
break;
case Types.FUNCTION:
final Function func = ((FunctionValue) val).getValue();
if (func instanceof UserDefinedFunction) {
length = ((UserDefinedFunction) func).getArgsCount();
} else {
length = 0;
}
length = func.getArgsCount();
break;
default:
length = 0;

Some files were not shown because too many files have changed in this diff Show More