mirror of
https://github.com/aNNiMON/Own-Programming-Language-Tutorial.git
synced 2024-09-20 08:44:20 +03:00
Ускорена инициализация констант
This commit is contained in:
parent
24b598a0b3
commit
8077b643bf
@ -32,12 +32,12 @@ public final class canvas implements Module {
|
||||
private static ArrayValue mouseHover;
|
||||
|
||||
public static void initConstants() {
|
||||
Variables.set("VK_UP", NumberValue.of(KeyEvent.VK_UP));
|
||||
Variables.set("VK_DOWN", NumberValue.of(KeyEvent.VK_DOWN));
|
||||
Variables.set("VK_LEFT", NumberValue.of(KeyEvent.VK_LEFT));
|
||||
Variables.set("VK_RIGHT", NumberValue.of(KeyEvent.VK_RIGHT));
|
||||
Variables.set("VK_FIRE", NumberValue.of(KeyEvent.VK_ENTER));
|
||||
Variables.set("VK_ESCAPE", NumberValue.of(KeyEvent.VK_ESCAPE));
|
||||
Variables.define("VK_UP", NumberValue.of(KeyEvent.VK_UP));
|
||||
Variables.define("VK_DOWN", NumberValue.of(KeyEvent.VK_DOWN));
|
||||
Variables.define("VK_LEFT", NumberValue.of(KeyEvent.VK_LEFT));
|
||||
Variables.define("VK_RIGHT", NumberValue.of(KeyEvent.VK_RIGHT));
|
||||
Variables.define("VK_FIRE", NumberValue.of(KeyEvent.VK_ENTER));
|
||||
Variables.define("VK_ESCAPE", NumberValue.of(KeyEvent.VK_ESCAPE));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -101,67 +101,67 @@ public final class canvasfx implements Module {
|
||||
colors.put(new StringValue("rgb"), new FunctionValue(new rgbColor()));
|
||||
colors.put(new StringValue("hsb"), new FunctionValue(new hsbColor()));
|
||||
colors.put(new StringValue("web"), new FunctionValue(new webColor()));
|
||||
Variables.set("Color", new MapValue(colors));
|
||||
Variables.define("Color", new MapValue(colors));
|
||||
|
||||
final MapValue arcType = new MapValue(ArcType.values().length);
|
||||
for (ArcType value : ArcType.values()) {
|
||||
arcType.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
|
||||
}
|
||||
Variables.set("ArcType", arcType);
|
||||
Variables.define("ArcType", arcType);
|
||||
|
||||
final MapValue fillRule = new MapValue(FillRule.values().length);
|
||||
for (FillRule value : FillRule.values()) {
|
||||
fillRule.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
|
||||
}
|
||||
Variables.set("FillRule", fillRule);
|
||||
Variables.define("FillRule", fillRule);
|
||||
|
||||
final MapValue blendMode = new MapValue(BlendMode.values().length);
|
||||
for (BlendMode value : BlendMode.values()) {
|
||||
blendMode.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
|
||||
}
|
||||
Variables.set("BlendMode", blendMode);
|
||||
Variables.define("BlendMode", blendMode);
|
||||
|
||||
final MapValue lineCap = new MapValue(StrokeLineCap.values().length);
|
||||
for (StrokeLineCap value : StrokeLineCap.values()) {
|
||||
lineCap.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
|
||||
}
|
||||
Variables.set("StrokeLineCap", lineCap);
|
||||
Variables.define("StrokeLineCap", lineCap);
|
||||
|
||||
final MapValue lineJoin = new MapValue(StrokeLineJoin.values().length);
|
||||
for (StrokeLineJoin value : StrokeLineJoin.values()) {
|
||||
lineJoin.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
|
||||
}
|
||||
Variables.set("StrokeLineJoin", lineJoin);
|
||||
Variables.define("StrokeLineJoin", lineJoin);
|
||||
|
||||
final MapValue textAlignment = new MapValue(TextAlignment.values().length);
|
||||
for (TextAlignment value : TextAlignment.values()) {
|
||||
textAlignment.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
|
||||
}
|
||||
Variables.set("TextAlignment", textAlignment);
|
||||
Variables.define("TextAlignment", textAlignment);
|
||||
|
||||
final MapValue vPos = new MapValue(VPos.values().length);
|
||||
for (VPos value : VPos.values()) {
|
||||
vPos.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
|
||||
}
|
||||
Variables.set("VPos", vPos);
|
||||
Variables.define("VPos", vPos);
|
||||
|
||||
final MapValue events = new MapValue(Events.values().length);
|
||||
for (Events value : Events.values()) {
|
||||
events.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
|
||||
}
|
||||
Variables.set("Events", events);
|
||||
Variables.define("Events", events);
|
||||
|
||||
final MapValue mouseButton = new MapValue(MouseButton.values().length);
|
||||
for (MouseButton value : MouseButton.values()) {
|
||||
mouseButton.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
|
||||
}
|
||||
Variables.set("MouseButton", mouseButton);
|
||||
Variables.define("MouseButton", mouseButton);
|
||||
|
||||
final MapValue keyCodes = new MapValue(KeyCode.values().length);
|
||||
for (KeyCode value : KeyCode.values()) {
|
||||
keyCodes.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
|
||||
}
|
||||
Variables.set("KeyCode", keyCodes);
|
||||
Variables.define("KeyCode", keyCodes);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -29,10 +29,10 @@ public final class date implements Module {
|
||||
MILLISECOND = new StringValue("millisecond");
|
||||
|
||||
public static void initConstants() {
|
||||
Variables.set("STYLE_FULL", NumberValue.of(DateFormat.FULL));
|
||||
Variables.set("STYLE_LONG", NumberValue.of(DateFormat.LONG));
|
||||
Variables.set("STYLE_MEDIUM", NumberValue.of(DateFormat.MEDIUM));
|
||||
Variables.set("STYLE_SHORT", NumberValue.of(DateFormat.SHORT));
|
||||
Variables.define("STYLE_FULL", NumberValue.of(DateFormat.FULL));
|
||||
Variables.define("STYLE_LONG", NumberValue.of(DateFormat.LONG));
|
||||
Variables.define("STYLE_MEDIUM", NumberValue.of(DateFormat.MEDIUM));
|
||||
Variables.define("STYLE_SHORT", NumberValue.of(DateFormat.SHORT));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -27,13 +27,13 @@ public final class files implements Module {
|
||||
private static Map<Integer, FileInfo> files;
|
||||
|
||||
public static void initConstants() {
|
||||
Variables.define("FILES_COMPARATOR", new FunctionValue(new filesComparatorFunction()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
files = new HashMap<>();
|
||||
initConstants();
|
||||
Variables.set("FILES_COMPARATOR", new FunctionValue(new filesComparatorFunction()));
|
||||
|
||||
Functions.set("fopen", new fopen());
|
||||
Functions.set("flush", new flush());
|
||||
|
@ -12,7 +12,7 @@ import com.annimon.ownlang.lib.modules.functions.*;
|
||||
public final class functional implements Module {
|
||||
|
||||
public static void initConstants() {
|
||||
Variables.set("IDENTITY", new FunctionValue(args -> args[0]));
|
||||
Variables.define("IDENTITY", new FunctionValue(args -> args[0]));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -17,8 +17,8 @@ public final class math implements Module {
|
||||
private static final DoubleFunction<NumberValue> doubleToNumber = NumberValue::of;
|
||||
|
||||
public static void initConstants() {
|
||||
Variables.set("PI", NumberValue.of(Math.PI));
|
||||
Variables.set("E", NumberValue.of(Math.E));
|
||||
Variables.define("PI", NumberValue.of(Math.PI));
|
||||
Variables.define("E", NumberValue.of(Math.E));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,15 +32,15 @@ public final class robot implements Module {
|
||||
private static Robot awtRobot;
|
||||
|
||||
public static void initConstants() {
|
||||
Variables.set("VK_DOWN", NumberValue.of(KeyEvent.VK_DOWN));
|
||||
Variables.set("VK_LEFT", NumberValue.of(KeyEvent.VK_LEFT));
|
||||
Variables.set("VK_RIGHT", NumberValue.of(KeyEvent.VK_RIGHT));
|
||||
Variables.set("VK_FIRE", NumberValue.of(KeyEvent.VK_ENTER));
|
||||
Variables.set("VK_ESCAPE", NumberValue.of(KeyEvent.VK_ESCAPE));
|
||||
Variables.define("VK_DOWN", NumberValue.of(KeyEvent.VK_DOWN));
|
||||
Variables.define("VK_LEFT", NumberValue.of(KeyEvent.VK_LEFT));
|
||||
Variables.define("VK_RIGHT", NumberValue.of(KeyEvent.VK_RIGHT));
|
||||
Variables.define("VK_FIRE", NumberValue.of(KeyEvent.VK_ENTER));
|
||||
Variables.define("VK_ESCAPE", NumberValue.of(KeyEvent.VK_ESCAPE));
|
||||
|
||||
Variables.set("BUTTON1", NumberValue.of(InputEvent.BUTTON1_MASK));
|
||||
Variables.set("BUTTON2", NumberValue.of(InputEvent.BUTTON2_MASK));
|
||||
Variables.set("BUTTON3", NumberValue.of(InputEvent.BUTTON3_MASK));
|
||||
Variables.define("BUTTON1", NumberValue.of(InputEvent.BUTTON1_MASK));
|
||||
Variables.define("BUTTON2", NumberValue.of(InputEvent.BUTTON2_MASK));
|
||||
Variables.define("BUTTON3", NumberValue.of(InputEvent.BUTTON3_MASK));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -13,7 +13,7 @@ import com.annimon.ownlang.lib.modules.functions.*;
|
||||
public final class std implements Module {
|
||||
|
||||
public static void initConstants() {
|
||||
Variables.set("ARGS", ArrayValue.of(Main.getOwnlangArgs()));
|
||||
Variables.define("ARGS", ArrayValue.of(Main.getOwnlangArgs()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -11,12 +11,12 @@ import com.annimon.ownlang.lib.*;
|
||||
public final class types implements Module {
|
||||
|
||||
public static void initConstants() {
|
||||
Variables.set("OBJECT", NumberValue.of(Types.OBJECT));
|
||||
Variables.set("NUMBER", NumberValue.of(Types.NUMBER));
|
||||
Variables.set("STRING", NumberValue.of(Types.STRING));
|
||||
Variables.set("ARRAY", NumberValue.of(Types.ARRAY));
|
||||
Variables.set("MAP", NumberValue.of(Types.MAP));
|
||||
Variables.set("FUNCTION", NumberValue.of(Types.FUNCTION));
|
||||
Variables.define("OBJECT", NumberValue.of(Types.OBJECT));
|
||||
Variables.define("NUMBER", NumberValue.of(Types.NUMBER));
|
||||
Variables.define("STRING", NumberValue.of(Types.STRING));
|
||||
Variables.define("ARRAY", NumberValue.of(Types.ARRAY));
|
||||
Variables.define("MAP", NumberValue.of(Types.MAP));
|
||||
Variables.define("FUNCTION", NumberValue.of(Types.FUNCTION));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user