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;
|
private static ArrayValue mouseHover;
|
||||||
|
|
||||||
public static void initConstants() {
|
public static void initConstants() {
|
||||||
Variables.set("VK_UP", NumberValue.of(KeyEvent.VK_UP));
|
Variables.define("VK_UP", NumberValue.of(KeyEvent.VK_UP));
|
||||||
Variables.set("VK_DOWN", NumberValue.of(KeyEvent.VK_DOWN));
|
Variables.define("VK_DOWN", NumberValue.of(KeyEvent.VK_DOWN));
|
||||||
Variables.set("VK_LEFT", NumberValue.of(KeyEvent.VK_LEFT));
|
Variables.define("VK_LEFT", NumberValue.of(KeyEvent.VK_LEFT));
|
||||||
Variables.set("VK_RIGHT", NumberValue.of(KeyEvent.VK_RIGHT));
|
Variables.define("VK_RIGHT", NumberValue.of(KeyEvent.VK_RIGHT));
|
||||||
Variables.set("VK_FIRE", NumberValue.of(KeyEvent.VK_ENTER));
|
Variables.define("VK_FIRE", NumberValue.of(KeyEvent.VK_ENTER));
|
||||||
Variables.set("VK_ESCAPE", NumberValue.of(KeyEvent.VK_ESCAPE));
|
Variables.define("VK_ESCAPE", NumberValue.of(KeyEvent.VK_ESCAPE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -101,67 +101,67 @@ public final class canvasfx implements Module {
|
|||||||
colors.put(new StringValue("rgb"), new FunctionValue(new rgbColor()));
|
colors.put(new StringValue("rgb"), new FunctionValue(new rgbColor()));
|
||||||
colors.put(new StringValue("hsb"), new FunctionValue(new hsbColor()));
|
colors.put(new StringValue("hsb"), new FunctionValue(new hsbColor()));
|
||||||
colors.put(new StringValue("web"), new FunctionValue(new webColor()));
|
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);
|
final MapValue arcType = new MapValue(ArcType.values().length);
|
||||||
for (ArcType value : ArcType.values()) {
|
for (ArcType value : ArcType.values()) {
|
||||||
arcType.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
|
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);
|
final MapValue fillRule = new MapValue(FillRule.values().length);
|
||||||
for (FillRule value : FillRule.values()) {
|
for (FillRule value : FillRule.values()) {
|
||||||
fillRule.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
|
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);
|
final MapValue blendMode = new MapValue(BlendMode.values().length);
|
||||||
for (BlendMode value : BlendMode.values()) {
|
for (BlendMode value : BlendMode.values()) {
|
||||||
blendMode.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
|
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);
|
final MapValue lineCap = new MapValue(StrokeLineCap.values().length);
|
||||||
for (StrokeLineCap value : StrokeLineCap.values()) {
|
for (StrokeLineCap value : StrokeLineCap.values()) {
|
||||||
lineCap.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
|
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);
|
final MapValue lineJoin = new MapValue(StrokeLineJoin.values().length);
|
||||||
for (StrokeLineJoin value : StrokeLineJoin.values()) {
|
for (StrokeLineJoin value : StrokeLineJoin.values()) {
|
||||||
lineJoin.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
|
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);
|
final MapValue textAlignment = new MapValue(TextAlignment.values().length);
|
||||||
for (TextAlignment value : TextAlignment.values()) {
|
for (TextAlignment value : TextAlignment.values()) {
|
||||||
textAlignment.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
|
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);
|
final MapValue vPos = new MapValue(VPos.values().length);
|
||||||
for (VPos value : VPos.values()) {
|
for (VPos value : VPos.values()) {
|
||||||
vPos.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
|
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);
|
final MapValue events = new MapValue(Events.values().length);
|
||||||
for (Events value : Events.values()) {
|
for (Events value : Events.values()) {
|
||||||
events.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
|
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);
|
final MapValue mouseButton = new MapValue(MouseButton.values().length);
|
||||||
for (MouseButton value : MouseButton.values()) {
|
for (MouseButton value : MouseButton.values()) {
|
||||||
mouseButton.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
|
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);
|
final MapValue keyCodes = new MapValue(KeyCode.values().length);
|
||||||
for (KeyCode value : KeyCode.values()) {
|
for (KeyCode value : KeyCode.values()) {
|
||||||
keyCodes.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
|
keyCodes.set(new StringValue(value.name()), NumberValue.of(value.ordinal()));
|
||||||
}
|
}
|
||||||
Variables.set("KeyCode", keyCodes);
|
Variables.define("KeyCode", keyCodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -29,10 +29,10 @@ public final class date implements Module {
|
|||||||
MILLISECOND = new StringValue("millisecond");
|
MILLISECOND = new StringValue("millisecond");
|
||||||
|
|
||||||
public static void initConstants() {
|
public static void initConstants() {
|
||||||
Variables.set("STYLE_FULL", NumberValue.of(DateFormat.FULL));
|
Variables.define("STYLE_FULL", NumberValue.of(DateFormat.FULL));
|
||||||
Variables.set("STYLE_LONG", NumberValue.of(DateFormat.LONG));
|
Variables.define("STYLE_LONG", NumberValue.of(DateFormat.LONG));
|
||||||
Variables.set("STYLE_MEDIUM", NumberValue.of(DateFormat.MEDIUM));
|
Variables.define("STYLE_MEDIUM", NumberValue.of(DateFormat.MEDIUM));
|
||||||
Variables.set("STYLE_SHORT", NumberValue.of(DateFormat.SHORT));
|
Variables.define("STYLE_SHORT", NumberValue.of(DateFormat.SHORT));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,13 +27,13 @@ public final class files implements Module {
|
|||||||
private static Map<Integer, FileInfo> files;
|
private static Map<Integer, FileInfo> files;
|
||||||
|
|
||||||
public static void initConstants() {
|
public static void initConstants() {
|
||||||
|
Variables.define("FILES_COMPARATOR", new FunctionValue(new filesComparatorFunction()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
files = new HashMap<>();
|
files = new HashMap<>();
|
||||||
initConstants();
|
initConstants();
|
||||||
Variables.set("FILES_COMPARATOR", new FunctionValue(new filesComparatorFunction()));
|
|
||||||
|
|
||||||
Functions.set("fopen", new fopen());
|
Functions.set("fopen", new fopen());
|
||||||
Functions.set("flush", new flush());
|
Functions.set("flush", new flush());
|
||||||
|
@ -12,7 +12,7 @@ import com.annimon.ownlang.lib.modules.functions.*;
|
|||||||
public final class functional implements Module {
|
public final class functional implements Module {
|
||||||
|
|
||||||
public static void initConstants() {
|
public static void initConstants() {
|
||||||
Variables.set("IDENTITY", new FunctionValue(args -> args[0]));
|
Variables.define("IDENTITY", new FunctionValue(args -> args[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -17,8 +17,8 @@ public final class math implements Module {
|
|||||||
private static final DoubleFunction<NumberValue> doubleToNumber = NumberValue::of;
|
private static final DoubleFunction<NumberValue> doubleToNumber = NumberValue::of;
|
||||||
|
|
||||||
public static void initConstants() {
|
public static void initConstants() {
|
||||||
Variables.set("PI", NumberValue.of(Math.PI));
|
Variables.define("PI", NumberValue.of(Math.PI));
|
||||||
Variables.set("E", NumberValue.of(Math.E));
|
Variables.define("E", NumberValue.of(Math.E));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -32,15 +32,15 @@ public final class robot implements Module {
|
|||||||
private static Robot awtRobot;
|
private static Robot awtRobot;
|
||||||
|
|
||||||
public static void initConstants() {
|
public static void initConstants() {
|
||||||
Variables.set("VK_DOWN", NumberValue.of(KeyEvent.VK_DOWN));
|
Variables.define("VK_DOWN", NumberValue.of(KeyEvent.VK_DOWN));
|
||||||
Variables.set("VK_LEFT", NumberValue.of(KeyEvent.VK_LEFT));
|
Variables.define("VK_LEFT", NumberValue.of(KeyEvent.VK_LEFT));
|
||||||
Variables.set("VK_RIGHT", NumberValue.of(KeyEvent.VK_RIGHT));
|
Variables.define("VK_RIGHT", NumberValue.of(KeyEvent.VK_RIGHT));
|
||||||
Variables.set("VK_FIRE", NumberValue.of(KeyEvent.VK_ENTER));
|
Variables.define("VK_FIRE", NumberValue.of(KeyEvent.VK_ENTER));
|
||||||
Variables.set("VK_ESCAPE", NumberValue.of(KeyEvent.VK_ESCAPE));
|
Variables.define("VK_ESCAPE", NumberValue.of(KeyEvent.VK_ESCAPE));
|
||||||
|
|
||||||
Variables.set("BUTTON1", NumberValue.of(InputEvent.BUTTON1_MASK));
|
Variables.define("BUTTON1", NumberValue.of(InputEvent.BUTTON1_MASK));
|
||||||
Variables.set("BUTTON2", NumberValue.of(InputEvent.BUTTON2_MASK));
|
Variables.define("BUTTON2", NumberValue.of(InputEvent.BUTTON2_MASK));
|
||||||
Variables.set("BUTTON3", NumberValue.of(InputEvent.BUTTON3_MASK));
|
Variables.define("BUTTON3", NumberValue.of(InputEvent.BUTTON3_MASK));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -13,7 +13,7 @@ import com.annimon.ownlang.lib.modules.functions.*;
|
|||||||
public final class std implements Module {
|
public final class std implements Module {
|
||||||
|
|
||||||
public static void initConstants() {
|
public static void initConstants() {
|
||||||
Variables.set("ARGS", ArrayValue.of(Main.getOwnlangArgs()));
|
Variables.define("ARGS", ArrayValue.of(Main.getOwnlangArgs()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -11,12 +11,12 @@ import com.annimon.ownlang.lib.*;
|
|||||||
public final class types implements Module {
|
public final class types implements Module {
|
||||||
|
|
||||||
public static void initConstants() {
|
public static void initConstants() {
|
||||||
Variables.set("OBJECT", NumberValue.of(Types.OBJECT));
|
Variables.define("OBJECT", NumberValue.of(Types.OBJECT));
|
||||||
Variables.set("NUMBER", NumberValue.of(Types.NUMBER));
|
Variables.define("NUMBER", NumberValue.of(Types.NUMBER));
|
||||||
Variables.set("STRING", NumberValue.of(Types.STRING));
|
Variables.define("STRING", NumberValue.of(Types.STRING));
|
||||||
Variables.set("ARRAY", NumberValue.of(Types.ARRAY));
|
Variables.define("ARRAY", NumberValue.of(Types.ARRAY));
|
||||||
Variables.set("MAP", NumberValue.of(Types.MAP));
|
Variables.define("MAP", NumberValue.of(Types.MAP));
|
||||||
Variables.set("FUNCTION", NumberValue.of(Types.FUNCTION));
|
Variables.define("FUNCTION", NumberValue.of(Types.FUNCTION));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user