Skip to content

Commit a71710f

Browse files
committed
数据模板成员访问
库的类型读取和函数的初始化修复 编译期编译步骤顺序更改
1 parent fbf5092 commit a71710f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+860
-790
lines changed

.mclib

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
{
2020
"id":"Test",
2121
"parents":[
22-
22+
"mcfpp.lang:DataObject"
2323
],
2424
"field":{
2525
"vars":[
@@ -54,50 +54,6 @@
5454
],
5555
"template":[
5656

57-
]
58-
},
59-
{
60-
"id":"mcfpp",
61-
"functions":[
62-
{
63-
"id":"load",
64-
"normalParams":[
65-
66-
],
67-
"returnType":"void",
68-
"isAbstract":false,
69-
"tags":[
70-
71-
]
72-
},
73-
{
74-
"id":"tick",
75-
"normalParams":[
76-
77-
],
78-
"returnType":"void",
79-
"isAbstract":false,
80-
"tags":[
81-
82-
]
83-
},
84-
{
85-
"id":"init",
86-
"normalParams":[
87-
88-
],
89-
"returnType":"void",
90-
"isAbstract":false,
91-
"tags":[
92-
93-
]
94-
}
95-
],
96-
"classes":[
97-
98-
],
99-
"template":[
100-
10157
]
10258
}
10359
]

mcfpp/lang/mcfpp.lang.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"files": [
3+
"*"
4+
],
5+
"description": "",
6+
"namespace": "mcfpp.lang",
7+
"targetPath": "null",
8+
"ignoreStdLib": false,
9+
"isLib": true
10+
}

mcfpp/sys/.mclib

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@
3737
},
3838
{
3939
"id":"print",
40-
"javaMethod":"top.mcfpp.mni.System#print(top.mcfpp.lang.Var)",
40+
"javaMethod":"top.mcfpp.mni.System#print(top.mcfpp.lang.DataTemplateObject)",
4141
"normalParams":[
4242
{
43-
"id":"a",
44-
"type":"any",
43+
"id":"n",
44+
"type":"mcfpp.lang:DataObject",
4545
"isStatic":false
4646
}
4747
],
@@ -50,34 +50,16 @@
5050
"tags":[
5151

5252
]
53-
}
54-
],
55-
"classes":[
56-
57-
],
58-
"template":[
59-
60-
]
61-
},
62-
{
63-
"id":"default",
64-
"functions":[
65-
66-
],
67-
"classes":[
68-
69-
],
70-
"template":[
71-
72-
]
73-
},
74-
{
75-
"id":"mcfpp",
76-
"functions":[
53+
},
7754
{
78-
"id":"load",
55+
"id":"print",
56+
"javaMethod":"top.mcfpp.mni.System#print(top.mcfpp.lang.NBTBasedData)",
7957
"normalParams":[
80-
58+
{
59+
"id":"n",
60+
"type":"nbt",
61+
"isStatic":false
62+
}
8163
],
8264
"returnType":"void",
8365
"isAbstract":false,
@@ -86,9 +68,14 @@
8668
]
8769
},
8870
{
89-
"id":"tick",
71+
"id":"print",
72+
"javaMethod":"top.mcfpp.mni.System#print(top.mcfpp.lang.Var)",
9073
"normalParams":[
91-
74+
{
75+
"id":"a",
76+
"type":"any",
77+
"isStatic":false
78+
}
9279
],
9380
"returnType":"void",
9481
"isAbstract":false,
@@ -97,7 +84,8 @@
9784
]
9885
},
9986
{
100-
"id":"init",
87+
"id":"debug",
88+
"javaMethod":"top.mcfpp.mni.System#debug()",
10189
"normalParams":[
10290

10391
],
@@ -113,6 +101,18 @@
113101
],
114102
"template":[
115103

104+
]
105+
},
106+
{
107+
"id":"default",
108+
"functions":[
109+
110+
],
111+
"classes":[
112+
113+
],
114+
"template":[
115+
116116
]
117117
}
118118
]

mcfpp/sys/mcfpp.sys.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
"description": "",
66
"namespace": "mcfpp.sys",
77
"targetPath": "null",
8-
"ignoreStdLib": true
8+
"ignoreStdLib": true,
9+
"isLib": true
910
}

mcfpp/sys/sys.mcfpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
func print(int i) = top.mcfpp.mni.System.print;
22
func print(string s) = top.mcfpp.mni.System.print;
3+
func print(DataObject n) = top.mcfpp.mni.System.print;
4+
func print(nbt n) = top.mcfpp.mni.System.print;
35
func print(any a) = top.mcfpp.mni.System.print;
4-
#func insert(string i) = top.mcfpp.mni.System.insert;
6+
7+
#func insert(string i) = top.mcfpp.mni.System.insert;
8+
func debug() = top.mcfpp.mni.System.debug;

src/main/antlr/mcfppParser.g4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ selector
350350
;
351351

352352
arguments
353-
: readOnlyArgs? normalArgs
353+
: readOnlyArgs? normalArgs?
354354
;
355355

356356
readOnlyArgs

src/main/java/top/mcfpp/mni/NBTListConcreteData.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,19 +130,19 @@ public static void insert(MCInt index, Var<?> e, NBTListConcrete caller){
130130
new Command("data modify " +
131131
"entity @s " +
132132
"data." + caller.getIdentifier() + " " +
133-
"insert").build("", "$" + index.getIdentifier()).build ("value " + SNBTUtil.toSNBT(tag))
133+
"insert").build("", "$" + index.getIdentifier(), true).build ("value " + SNBTUtil.toSNBT(tag), true)
134134
);
135135
Function.Companion.addCommand(command[0]);
136136
var f = Commands.INSTANCE.buildMacroCommand(command[1]).build("with storage mcfpp:system " +
137-
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]");
137+
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]", true);
138138
Function.Companion.addCommand(f);
139139
} else {
140140
var command = new Command("data modify " +
141141
"storage mcfpp:system " +
142142
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]." + caller.getIdentifier() + " " +
143-
"insert").build("", "$" + index.getIdentifier()).build("value " + SNBTUtil.toSNBT(tag));
143+
"insert").build("", "$" + index.getIdentifier(), true).build("value " + SNBTUtil.toSNBT(tag), true);
144144
var f = Commands.INSTANCE.buildMacroCommand(command).build("with storage mcfpp:system " +
145-
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]");
145+
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]", true);
146146
Function.Companion.addCommand(f);
147147
}
148148
} catch (IOException ex) {
@@ -157,20 +157,20 @@ public static void insert(MCInt index, Var<?> e, NBTListConcrete caller){
157157
command = Commands.INSTANCE.selectRun(caller.getParent(), new Command("data modify " +
158158
"entity @s " +
159159
"data." + caller.getIdentifier() + " " +
160-
"insert").build("", "$" + index.getIdentifier()).build ("from " +
160+
"insert").build("", "$" + index.getIdentifier(), true).build ("from " +
161161
"storage mcfpp:system " +
162-
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]." + e.getIdentifier()));
162+
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]." + e.getIdentifier(), true));
163163
} else {
164164
command = new Command[] {new Command("data modify " +
165165
"storage mcfpp:system " +
166166
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]." + caller.getIdentifier() + " " +
167-
"insert").build("", "$" + index.getIdentifier()).build("from " +
167+
"insert").build("", "$" + index.getIdentifier(), true).build("from " +
168168
"storage mcfpp:system " +
169-
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]." + e.getIdentifier())};
169+
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]." + e.getIdentifier(), true)};
170170
}
171171
if(command.length == 2) Function.Companion.addCommand(command[0]);
172172
var f = Commands.INSTANCE.buildMacroCommand(command[command.length - 1]).build("with storage mcfpp:system " +
173-
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]");
173+
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]", true);
174174
Function.Companion.addCommand(f);
175175
}
176176
}

src/main/java/top/mcfpp/mni/NBTListData.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -148,18 +148,18 @@ public static void insert(MCInt index, Var<?> e, NBTList caller){
148148
var command = Commands.INSTANCE.selectRun(caller.getParent(), new Command("data modify " +
149149
"entity @s " +
150150
"data." + caller.getIdentifier() + " " +
151-
"insert ").buildMacro(index.getIdentifier()).build ("value " + SNBTUtil.toSNBT(tag)));
151+
"insert ").buildMacro(index.getIdentifier(), true).build ("value " + SNBTUtil.toSNBT(tag), true));
152152
Function.Companion.addCommand(command[0]);
153153
var f = Commands.INSTANCE.buildMacroCommand(command[1]).build("with storage mcfpp:system " +
154-
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]");
154+
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]", true);
155155
Function.Companion.addCommand(f);
156156
} else {
157157
var command = new Command("data modify " +
158158
"storage mcfpp:system " +
159159
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]." + caller.getIdentifier() + " " +
160-
"insert ").buildMacro(index.getIdentifier()).build("value " + SNBTUtil.toSNBT(tag));
160+
"insert ").buildMacro(index.getIdentifier(), true).build("value " + SNBTUtil.toSNBT(tag), true);
161161
var f = Commands.INSTANCE.buildMacroCommand(command).build("with storage mcfpp:system " +
162-
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]");
162+
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]", true);
163163
Function.Companion.addCommand(f);
164164
}
165165
} catch (IOException ex) {
@@ -172,22 +172,22 @@ public static void insert(MCInt index, Var<?> e, NBTList caller){
172172
var command = Commands.INSTANCE.selectRun(caller.getParent(), new Command("data modify " +
173173
"entity @s " +
174174
"data." + caller.getIdentifier() + " " +
175-
"insert ").buildMacro(index.getIdentifier())
175+
"insert ").buildMacro(index.getIdentifier(), true)
176176
.build (" from storage mcfpp:system " +
177-
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]." + e.getIdentifier()));
177+
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]." + e.getIdentifier(), true));
178178
Function.Companion.addCommand(command[0]);
179179
var f = Commands.INSTANCE.buildMacroCommand(command[1]).build("with storage mcfpp:system " +
180-
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]");
180+
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]", true);
181181
Function.Companion.addCommand(f);
182182
} else {
183183
var command = new Command("data modify " +
184184
"storage mcfpp:system " +
185185
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]." + caller.getIdentifier() + " " +
186-
"insert ").buildMacro(index.getIdentifier())
186+
"insert ").buildMacro(index.getIdentifier(), true)
187187
.build("from storage mcfpp:system " +
188-
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]." + e.getIdentifier());
188+
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]." + e.getIdentifier(), true);
189189
var f = Commands.INSTANCE.buildMacroCommand(command).build("with storage mcfpp:system " +
190-
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]");
190+
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]", true);
191191
Function.Companion.addCommand(f);
192192
}
193193
}
@@ -217,17 +217,17 @@ public static void removeAt(MCInt index, NBTList caller){
217217
if(caller.getParent() != null){
218218
var command = Commands.INSTANCE.selectRun(caller.getParent(), new Command(
219219
"data remove entity @s " +
220-
"data." + caller.getIdentifier() + "[").buildMacro(index.getIdentifier()).build("]"));
220+
"data." + caller.getIdentifier() + "[").buildMacro(index.getIdentifier(), true).build("]", true));
221221
Function.Companion.addCommand(command[0]);
222222
var f = Commands.INSTANCE.buildMacroCommand(command[1]).build("with storage mcfpp:system " +
223-
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]");
223+
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]", true);
224224
Function.Companion.addCommand(f);
225225
}else {
226226
var command = new Command(
227227
"data remove storage mcfpp:system " +
228-
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]." + caller.getIdentifier() + "[").buildMacro(index.getIdentifier()).build("]");
228+
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]." + caller.getIdentifier() + "[").buildMacro(index.getIdentifier(), true).build("]", true);
229229
var f = Commands.INSTANCE.buildMacroCommand(command).build("with storage mcfpp:system " +
230-
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]");
230+
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]", true);
231231
Function.Companion.addCommand(f);
232232
}
233233
}

src/main/java/top/mcfpp/mni/System.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,21 @@ public static void print(@NotNull MCString var) {
6161
//TODO
6262
}
6363
}
64+
65+
@InsertCommand
66+
@MNIRegister(normalParams = {"DataObject o"})
67+
public static void print(@NotNull DataTemplateObject object){
68+
if(object instanceof DataTemplateObjectConcrete objectConcrete){
69+
Function.Companion.addCommand("tellraw @a \"" + objectConcrete.getValue().valueToString());
70+
}else {
71+
//TODO
72+
Function.Companion.addCommand("TODO: tellraw templateData");
73+
}
74+
}
75+
76+
@MNIRegister
77+
public static void debug(){
78+
//噢,在这里断点,这样就可以断点编译了
79+
int i = 0;
80+
}
6481
}

src/main/kotlin/top/mcfpp/CompileSettings.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@ object CompileSettings {
1010
* 是否忽略标准库
1111
*/
1212
var ignoreStdLib: Boolean = false
13+
14+
/**
15+
* 是否是库(不用包含入口函数)
16+
*/
17+
var isLib: Boolean = false
1318
}

0 commit comments

Comments
 (0)