Skip to content

Commit c78e0c5

Browse files
committed
Remove block, start work on frames.
1 parent 3cfdc1f commit c78e0c5

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright (c) 2022 ByteSkript org (Moderocky)
3+
* View the full licence information and permissions:
4+
* https://github.com/Moderocky/ByteSkript/blob/master/LICENSE
5+
*/
6+
7+
package org.byteskript.skript.compiler.structure;
8+
9+
import mx.kenzie.foundation.Type;
10+
11+
public interface Frame {
12+
13+
int size();
14+
15+
void add(Type... types);
16+
17+
void remove(Type... types);
18+
19+
}

src/main/java/org/byteskript/skript/compiler/structure/PreVariable.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,40 @@
66

77
package org.byteskript.skript.compiler.structure;
88

9+
import mx.kenzie.foundation.Type;
910
import mx.kenzie.foundation.WriteInstruction;
11+
import org.byteskript.skript.compiler.CommonTypes;
12+
13+
import java.util.ArrayList;
14+
import java.util.HashSet;
15+
import java.util.List;
16+
import java.util.Set;
1017

1118
public final class PreVariable {
1219
private final String name;
1320
public boolean parameter;
1421
public boolean internal;
1522
public boolean atomic;
23+
public final List<Type> insight = new ArrayList<>();
1624

1725
public PreVariable(String name) {
1826
if (name == null) this.name = "EMPTY";
1927
else this.name = name;
2028
}
2129

30+
public boolean typeKnown() {
31+
return insight.size() == 1;
32+
}
33+
34+
public Type getType() {
35+
if (insight.size() == 1) return insight.get(0);
36+
else return CommonTypes.OBJECT;
37+
}
38+
39+
public void addTypeInsight(Type type) {
40+
this.insight.add(type);
41+
}
42+
2243
public WriteInstruction load(final int slot) {
2344
return WriteInstruction.loadObject(slot);
2445
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,7 @@ public Skript(SkriptThreadProvider threadProvider, ModifiableCompiler compiler,
122122
this.events = new HashMap<>();
123123
this.converters = new HashMap<>();
124124
skript = this;
125-
if (compiler != null) {
126-
this.converters.putAll(compiler.getConverters());
127-
}
125+
if (compiler != null) this.converters.putAll(compiler.getConverters());
128126
}
129127

130128
@Description("""

0 commit comments

Comments
 (0)