Skip to content

Commit 300bf22

Browse files
committed
Clean up some changes.
1 parent 5ba42a2 commit 300bf22

File tree

8 files changed

+48
-51
lines changed

8 files changed

+48
-51
lines changed

src/main/java/org/byteskript/skript/compiler/Context.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ public void setStoredVariableName(String storedVariableName) {
6565

6666
public abstract MethodBuilder getMethod();
6767

68-
public abstract MethodBuilder getTriggerMethod();
69-
7068
public abstract void setMethod(MethodBuilder method);
7169

70+
public abstract MethodBuilder getTriggerMethod();
71+
7272
public abstract void setMethod(MethodBuilder method, boolean trigger);
7373

7474
public abstract FieldBuilder getField();

src/main/java/org/byteskript/skript/compiler/ElementTree.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.util.*;
1919

2020
public final class ElementTree {
21+
public final Map<String, Object> metadata = new HashMap<>();
2122
private final SyntaxElement current;
2223
private final Pattern.Match match;
2324
public boolean compile = true;
@@ -26,7 +27,6 @@ public final class ElementTree {
2627
public Type wanted = null;
2728
public HandlerType type = StandardHandlers.GET;
2829
private ElementTree[] nested;
29-
public final Map<String, Object> metadata = new HashMap<>();
3030

3131
public ElementTree(SyntaxElement current, Pattern.Match match, ElementTree... nested) {
3232
this.current = current;

src/main/java/org/byteskript/skript/compiler/FileContext.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,13 @@ public MethodBuilder getMethod() {
196196
}
197197

198198
@Override
199-
public MethodBuilder getTriggerMethod() {
200-
return triggerMethod;
199+
public void setMethod(MethodBuilder method) {
200+
this.setMethod(method, false);
201201
}
202202

203203
@Override
204-
public void setMethod(MethodBuilder method) {
205-
this.setMethod(method, false);
204+
public MethodBuilder getTriggerMethod() {
205+
return triggerMethod;
206206
}
207207

208208
@Override

src/main/java/org/byteskript/skript/compiler/SimpleSkriptCompiler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ public ElementTree assembleStatement(final String statement, final FileContext c
244244
if (current == null) {
245245
if (details.expression != null)
246246
throw new ScriptParseError(context.lineNumber(), details.clone(), "No syntax match found for expression '" + details.expression + "'", null);
247-
else throw new ScriptParseError(context.lineNumber(), details.clone(), "No syntax match found for statement '" + statement + "'", null);
247+
else
248+
throw new ScriptParseError(context.lineNumber(), details.clone(), "No syntax match found for statement '" + statement + "'", null);
248249
}
249250
return current;
250251
}

src/main/java/org/byteskript/skript/lang/syntax/flow/execute/RunAsyncEffect.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ public void compile(Context context, Pattern.Match match) throws Throwable {
9292
.parameterTypes());
9393
final MethodErasure bootstrap = new MethodErasure(LambdaMetafactory.class.getMethod("metafactory", MethodHandles.Lookup.class, String.class, MethodType.class, MethodType.class, MethodHandle.class, MethodType.class));
9494
method.writeCode((writer, visitor) -> visitor.visitInvokeDynamicInsn("run", creator.getDescriptor(), new Handle(Opcodes.H_INVOKESTATIC, "java/lang/invoke/LambdaMetafactory", bootstrap.name(), bootstrap.getDescriptor(), false), org.objectweb.asm.Type.getType("()V"), new Handle(6, internal, runnable.name(), runnable.getDescriptor(), false), org.objectweb.asm.Type.getType("()V")));
95-
// todo hold synchronicity to following sleep
96-
// todo error protection?
9795
}
9896
final Method target = ExtractedSyntaxCalls.class.getMethod("runOnAsyncThread", Runnable.class);
9997
this.writeCall(method, target, context);

src/main/java/org/byteskript/skript/lang/syntax/flow/execute/WaitForEffect.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ public void compile(Context context, Pattern.Match match) throws Throwable {
132132
visitor.visitVarInsn(25, error);
133133
visitor.visitInsn(Opcodes.ATHROW);
134134
visitor.visitInsn(Opcodes.RETURN);
135-
136135
});
137136
child.writeCode(WriteInstruction.returnEmpty());
138137
final String internal = context.getType().internalName();

src/main/java/org/byteskript/skript/lang/syntax/generic/PrintEffect.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
import org.byteskript.skript.lang.element.StandardElements;
1818
import org.byteskript.skript.runtime.internal.ExtractedSyntaxCalls;
1919

20-
import java.io.PrintStream;
21-
2220
@Documentation(
2321
name = "Print",
2422
description = """

src/main/java/org/byteskript/skript/runtime/Skript.java

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -455,22 +455,6 @@ public Future<?> runScript(final ScriptRunner runner, final Event event) {
455455
return future;
456456
}
457457

458-
@Description("""
459-
Trigger all event handlers that can deal with this event.
460-
Each handler will spawn its own process.
461-
""")
462-
@GenerateExample
463-
public boolean runEvent(final Event event) {
464-
boolean run = false;
465-
for (Map.Entry<Class<? extends Event>, EventHandler> entry : events.entrySet()) {
466-
final Class<? extends Event> key = entry.getKey();
467-
if (!key.isAssignableFrom(event.getClass())) continue;
468-
run = true;
469-
entry.getValue().run(this, event);
470-
}
471-
return run;
472-
}
473-
474458
@Description("""
475459
Trigger all event handlers that can deal with this event.
476460
Each handler will spawn its own process.
@@ -764,6 +748,22 @@ public void unloadScript(Script script) {
764748
this.runEvent(unload);
765749
}
766750

751+
@Description("""
752+
Trigger all event handlers that can deal with this event.
753+
Each handler will spawn its own process.
754+
""")
755+
@GenerateExample
756+
public boolean runEvent(final Event event) {
757+
boolean run = false;
758+
for (Map.Entry<Class<? extends Event>, EventHandler> entry : events.entrySet()) {
759+
final Class<? extends Event> key = entry.getKey();
760+
if (!key.isAssignableFrom(event.getClass())) continue;
761+
run = true;
762+
entry.getValue().run(this, event);
763+
}
764+
return run;
765+
}
766+
767767
@Description("""
768768
This is designed for internal use.
769769
""")
@@ -784,18 +784,6 @@ public Script compileLoad(InputStream stream, String name) {
784784
return loadScript(compileScript(stream, name));
785785
}
786786

787-
@Description("""
788-
Loads a script from compiled source code.
789-
""")
790-
@GenerateExample
791-
public Script loadScript(final PostCompileClass[] data) {
792-
final Class<?>[] classes = new Class[data.length];
793-
for (int i = 0; i < data.length; i++) {
794-
classes[i] = this.loadClass(data[i].name(), data[i].code());
795-
}
796-
return this.loadScript(classes);
797-
}
798-
799787
@Description("""
800788
Loads a script from compiled source code.
801789
""")
@@ -804,16 +792,6 @@ public Script loadScript(final PostCompileClass datum) {
804792
return this.loadScript(this.loadClass(datum.name(), datum.code()));
805793
}
806794

807-
@Description("""
808-
Loads a script from defined classes.
809-
""")
810-
@GenerateExample
811-
public Script loadScript(final Class<?>[] loaded) {
812-
final Script script = new Script(this, null, loaded);
813-
this.scripts.add(script);
814-
return script;
815-
}
816-
817795
@Description("""
818796
Loads a script from a defined class.
819797
""")
@@ -834,6 +812,28 @@ private SkriptMirror createLoader() {
834812
return new SkriptMirror(loader);
835813
}
836814

815+
@Description("""
816+
Loads a script from compiled source code.
817+
""")
818+
@GenerateExample
819+
public Script loadScript(final PostCompileClass[] data) {
820+
final Class<?>[] classes = new Class[data.length];
821+
for (int i = 0; i < data.length; i++) {
822+
classes[i] = this.loadClass(data[i].name(), data[i].code());
823+
}
824+
return this.loadScript(classes);
825+
}
826+
827+
@Description("""
828+
Loads a script from defined classes.
829+
""")
830+
@GenerateExample
831+
public Script loadScript(final Class<?>[] loaded) {
832+
final Script script = new Script(this, null, loaded);
833+
this.scripts.add(script);
834+
return script;
835+
}
836+
837837
public Script getScript(final Class<?> part) {
838838
for (final Script script : this.scripts) {
839839
if (script.ownsClass(part)) return script;
@@ -989,6 +989,7 @@ public Script loadScript(final File source, final String name)
989989
}
990990

991991
//region Output
992+
992993
/**
993994
* Set the current print stream used by the `print` effect.
994995
* This can be used to redirect output in a particular state.

0 commit comments

Comments
 (0)