リビジョン | 550812c9ac994c7dca0335f440402501fdee457d (tree) |
---|---|
日時 | 2015-11-09 08:14:57 |
作者 | MirrgieRiana |
コミッター | MirrgieRiana |
mirrg/game/math/wulfenite/script2: 名前を色々変更
@@ -28,9 +28,9 @@ | ||
28 | 28 | import mirrg.event.nitrogen.INitrogenEventRegistry; |
29 | 29 | import mirrg.game.math.wulfenite.events.NitrogenEventWulfenite; |
30 | 30 | import mirrg.game.math.wulfenite.events.NitrogenEventWulfeniteFrameFormula; |
31 | -import mirrg.game.math.wulfenite.script2.ArgumentsValidateWS2; | |
32 | -import mirrg.game.math.wulfenite.script2.ResponseCompileWS2; | |
33 | -import mirrg.game.math.wulfenite.script2.WulfeniteScript2; | |
31 | +import mirrg.game.math.wulfenite.script2.ArgumentsValidate; | |
32 | +import mirrg.game.math.wulfenite.script2.ResponseCompile; | |
33 | +import mirrg.game.math.wulfenite.script2.HWulfeniteScript2; | |
34 | 34 | import mirrg.struct.hydrogen.Struct1; |
35 | 35 | |
36 | 36 | public class FrameFormula extends FrameBase |
@@ -300,7 +300,7 @@ | ||
300 | 300 | |
301 | 301 | protected void compile() throws InterruptedException |
302 | 302 | { |
303 | - ResponseCompileWS2 resultCompile = WulfeniteScript2.compile(textAreaSource.getText()); | |
303 | + ResponseCompile resultCompile = HWulfeniteScript2.compile(textAreaSource.getText()); | |
304 | 304 | |
305 | 305 | if (!resultCompile.isSuccessed()) { |
306 | 306 |
@@ -322,7 +322,7 @@ | ||
322 | 322 | |
323 | 323 | } else { |
324 | 324 | |
325 | - ArgumentsValidateWS2 argumentsValidate = new ArgumentsValidateWS2(resultCompile); | |
325 | + ArgumentsValidate argumentsValidate = new ArgumentsValidate(resultCompile); | |
326 | 326 | argumentsValidate.stackFrameRoot.getStackFrame().defineVariable("_"); |
327 | 327 | |
328 | 328 | if (!resultCompile.response.node.validate(argumentsValidate)) { |
@@ -15,7 +15,7 @@ | ||
15 | 15 | import mirrg.applet.mathematics.zinc.core.ZincTransform; |
16 | 16 | import mirrg.game.math.wulfenite.events.NitrogenEventWulfenite; |
17 | 17 | import mirrg.game.math.wulfenite.events.NitrogenEventWulfeniteFrameFormula; |
18 | -import mirrg.game.math.wulfenite.script2.WulfeniteScript2; | |
18 | +import mirrg.game.math.wulfenite.script2.HWulfeniteScript2; | |
19 | 19 | |
20 | 20 | public class FrameWulfenite extends FrameBase |
21 | 21 | { |
@@ -184,7 +184,7 @@ | ||
184 | 184 | menuItem.setMnemonic('C'); |
185 | 185 | menu.add(menuItem); |
186 | 186 | |
187 | - menuItem.addActionListener(event -> WulfeniteScript2.init()); | |
187 | + menuItem.addActionListener(event -> HWulfeniteScript2.init()); | |
188 | 188 | } |
189 | 189 | |
190 | 190 | } |
@@ -9,8 +9,8 @@ | ||
9 | 9 | import mirrg.complex.hydrogen.StructureComplex; |
10 | 10 | import mirrg.event.nitrogen.INitrogenEventRegistry; |
11 | 11 | import mirrg.game.math.wulfenite.events.NitrogenEventWulfenite; |
12 | -import mirrg.game.math.wulfenite.script2.ArgumentsInvokeWS2; | |
13 | -import mirrg.game.math.wulfenite.script2.tnode.TNodeRootWS2; | |
12 | +import mirrg.game.math.wulfenite.script2.ArgumentsInvoke; | |
13 | +import mirrg.game.math.wulfenite.script2.tnode.TNodeRoot; | |
14 | 14 | |
15 | 15 | public class PanelWulfenite extends JPanel |
16 | 16 | { |
@@ -18,8 +18,8 @@ | ||
18 | 18 | private static final long serialVersionUID = 5385717383156369664L; |
19 | 19 | protected final AppletZinc applet; |
20 | 20 | |
21 | - protected ArgumentsInvokeWS2 argumentInvoke; | |
22 | - protected TNodeRootWS2 wulfeniteScript; | |
21 | + protected ArgumentsInvoke argumentInvoke; | |
22 | + protected TNodeRoot wulfeniteScript; | |
23 | 23 | |
24 | 24 | public PanelWulfenite(INitrogenEventRegistry eventRegistry) |
25 | 25 | { |
@@ -66,7 +66,7 @@ | ||
66 | 66 | |
67 | 67 | if (event.formula != null) { |
68 | 68 | wulfeniteScript = event.formula.result.response.node; |
69 | - argumentInvoke = new ArgumentsInvokeWS2(event.formula.argumentValidate); | |
69 | + argumentInvoke = new ArgumentsInvoke(event.formula.argumentValidate); | |
70 | 70 | } |
71 | 71 | |
72 | 72 | }); |
@@ -1,15 +1,15 @@ | ||
1 | 1 | package mirrg.game.math.wulfenite.events; |
2 | 2 | |
3 | -import mirrg.game.math.wulfenite.script2.ArgumentsValidateWS2; | |
4 | -import mirrg.game.math.wulfenite.script2.ResponseCompileWS2; | |
3 | +import mirrg.game.math.wulfenite.script2.ArgumentsValidate; | |
4 | +import mirrg.game.math.wulfenite.script2.ResponseCompile; | |
5 | 5 | |
6 | 6 | public class NitrogenEventWulfeniteFrameFormula |
7 | 7 | { |
8 | 8 | |
9 | - public ResponseCompileWS2 result; | |
9 | + public ResponseCompile result; | |
10 | 10 | |
11 | 11 | public NitrogenEventWulfeniteFrameFormula( |
12 | - ResponseCompileWS2 result) | |
12 | + ResponseCompile result) | |
13 | 13 | { |
14 | 14 | this.result = result; |
15 | 15 | } |
@@ -18,7 +18,7 @@ | ||
18 | 18 | { |
19 | 19 | |
20 | 20 | public SyntaxError( |
21 | - ResponseCompileWS2 result) | |
21 | + ResponseCompile result) | |
22 | 22 | { |
23 | 23 | super(result); |
24 | 24 | } |
@@ -28,11 +28,11 @@ | ||
28 | 28 | public static class SyntaxSuccess extends NitrogenEventWulfeniteFrameFormula |
29 | 29 | { |
30 | 30 | |
31 | - public ArgumentsValidateWS2 argumentValidate; | |
31 | + public ArgumentsValidate argumentValidate; | |
32 | 32 | |
33 | 33 | public SyntaxSuccess( |
34 | - ResponseCompileWS2 result, | |
35 | - ArgumentsValidateWS2 argumentValidate) | |
34 | + ResponseCompile result, | |
35 | + ArgumentsValidate argumentValidate) | |
36 | 36 | { |
37 | 37 | super(result); |
38 | 38 | this.argumentValidate = argumentValidate; |
@@ -44,8 +44,8 @@ | ||
44 | 44 | { |
45 | 45 | |
46 | 46 | public Success( |
47 | - ResponseCompileWS2 result, | |
48 | - ArgumentsValidateWS2 argumentValidate) | |
47 | + ResponseCompile result, | |
48 | + ArgumentsValidate argumentValidate) | |
49 | 49 | { |
50 | 50 | super(result, argumentValidate); |
51 | 51 | } |
@@ -56,8 +56,8 @@ | ||
56 | 56 | { |
57 | 57 | |
58 | 58 | public CompileError( |
59 | - ResponseCompileWS2 result, | |
60 | - ArgumentsValidateWS2 argumentValidate) | |
59 | + ResponseCompile result, | |
60 | + ArgumentsValidate argumentValidate) | |
61 | 61 | { |
62 | 62 | super(result, argumentValidate); |
63 | 63 | } |
@@ -0,0 +1,15 @@ | ||
1 | +package mirrg.game.math.wulfenite.script2; | |
2 | + | |
3 | +public class ArgumentsInvoke | |
4 | +{ | |
5 | + | |
6 | + public ArgumentsValidate argumentsValidate; | |
7 | + public VirtualMachine virtualMachine; | |
8 | + | |
9 | + public ArgumentsInvoke(ArgumentsValidate argumentsValidate) | |
10 | + { | |
11 | + this.argumentsValidate = argumentsValidate; | |
12 | + virtualMachine = new VirtualMachine(argumentsValidate); | |
13 | + } | |
14 | + | |
15 | +} |
@@ -1,15 +0,0 @@ | ||
1 | -package mirrg.game.math.wulfenite.script2; | |
2 | - | |
3 | -public class ArgumentsInvokeWS2 | |
4 | -{ | |
5 | - | |
6 | - public ArgumentsValidateWS2 argumentsValidate; | |
7 | - public VirtualMachineWS2 virtualMachine; | |
8 | - | |
9 | - public ArgumentsInvokeWS2(ArgumentsValidateWS2 argumentsValidate) | |
10 | - { | |
11 | - this.argumentsValidate = argumentsValidate; | |
12 | - virtualMachine = new VirtualMachineWS2(argumentsValidate); | |
13 | - } | |
14 | - | |
15 | -} |
@@ -0,0 +1,215 @@ | ||
1 | +package mirrg.game.math.wulfenite.script2; | |
2 | + | |
3 | +import java.util.ArrayList; | |
4 | +import java.util.stream.Collectors; | |
5 | + | |
6 | +import mirrg.compile.bromine.syntaxes.TagString; | |
7 | +import mirrg.struct.hydrogen.Tuple; | |
8 | +import mirrg.util.hydrogen.HString; | |
9 | +import mirrg.util.hydrogen.HString.LineProvider; | |
10 | + | |
11 | +public class ArgumentsValidate | |
12 | +{ | |
13 | + | |
14 | + public final ResponseCompile resultCompile; | |
15 | + | |
16 | + public ArgumentsValidate(ResponseCompile resultCompile) | |
17 | + { | |
18 | + this.resultCompile = resultCompile; | |
19 | + } | |
20 | + | |
21 | + //////////////////////////////////////////////////////////////////////////////////////////// | |
22 | + | |
23 | + private ArrayList<Tuple<TagString, String>> messages = new ArrayList<>(); | |
24 | + | |
25 | + public void addMessage(TagString tag, String message) | |
26 | + { | |
27 | + messages.add(new Tuple<>(tag, message)); | |
28 | + } | |
29 | + | |
30 | + public String getMessageString() | |
31 | + { | |
32 | + LineProvider lineProvider = HString.getLineProvider(resultCompile.source); | |
33 | + | |
34 | + return messages.stream() | |
35 | + .map(message -> { | |
36 | + int start = message.getX().start; | |
37 | + Tuple<Integer, Integer> linePosition = resultCompile.getLinePosition(start); | |
38 | + int row = linePosition.getX(); | |
39 | + int column = linePosition.getY(); | |
40 | + String line = lineProvider.getContent(row); | |
41 | + | |
42 | + String left = line.substring(Math.max(column - 20, 0), column); | |
43 | + String right = line.substring(column, Math.min(column + 20, line.length())); | |
44 | + | |
45 | + return String.format( | |
46 | + "(L:%s, C:%s) '%s#%s' %s", | |
47 | + row, | |
48 | + column, | |
49 | + left, | |
50 | + right, | |
51 | + message.getY()); | |
52 | + }) | |
53 | + .collect(Collectors.joining("\n")); | |
54 | + } | |
55 | + | |
56 | + //////////////////////////////////////////////////////////////////////////////////////////// | |
57 | + | |
58 | + public StackFrameRoot stackFrameRoot = new StackFrameRoot(); | |
59 | + | |
60 | + /** | |
61 | + * 行やフレームを超えて利用するための変数を管理する。 | |
62 | + */ | |
63 | + public static class StackFrameRoot | |
64 | + { | |
65 | + | |
66 | + private StackFrame stackFrame = new StackFrame(this, null); | |
67 | + | |
68 | + public int maxVariableCount = 0; | |
69 | + | |
70 | + public StackFrame getStackFrame() | |
71 | + { | |
72 | + return stackFrame; | |
73 | + } | |
74 | + | |
75 | + public void pushStackFrame() | |
76 | + { | |
77 | + stackFrame = new StackFrame(this, stackFrame); | |
78 | + } | |
79 | + | |
80 | + public void popStackFrame() | |
81 | + { | |
82 | + stackFrame = stackFrame.parent; | |
83 | + } | |
84 | + | |
85 | + } | |
86 | + | |
87 | + public static class StackFrame | |
88 | + { | |
89 | + | |
90 | + private StackFrameRoot stackFrameRoot; | |
91 | + public StackFrame parent; | |
92 | + private ArrayList<String> variables = new ArrayList<>(); | |
93 | + | |
94 | + public StackFrame(StackFrameRoot stackFrameRoot, StackFrame parent) | |
95 | + { | |
96 | + this.stackFrameRoot = stackFrameRoot; | |
97 | + this.parent = parent; | |
98 | + } | |
99 | + | |
100 | + /** | |
101 | + * ここまでで全ての利用可能な変数の中に特定の名前が有るかどうか。 | |
102 | + */ | |
103 | + public boolean containsVariable(String name) | |
104 | + { | |
105 | + if (variables.contains(name)) return true; | |
106 | + return parent == null ? false : parent.containsVariable(name); | |
107 | + } | |
108 | + | |
109 | + /** | |
110 | + * このスタックフレームで変数名の占有を宣言。 | |
111 | + * | |
112 | + * @return | |
113 | + * その変数のインデックス。 | |
114 | + * その変数名が利用可能でなかった場合、null。 | |
115 | + */ | |
116 | + public Integer defineVariable(String name) | |
117 | + { | |
118 | + if (containsVariable(name)) return null; | |
119 | + variables.add(name); | |
120 | + | |
121 | + int index = getVariablesCount(); | |
122 | + | |
123 | + if (stackFrameRoot.maxVariableCount < index) { | |
124 | + stackFrameRoot.maxVariableCount = index; | |
125 | + } | |
126 | + | |
127 | + return index - 1; | |
128 | + } | |
129 | + | |
130 | + /** | |
131 | + * ここまでで全ての利用可能な変数の個数。 | |
132 | + */ | |
133 | + public int getVariablesCount() | |
134 | + { | |
135 | + return variables.size() + (parent == null ? 0 : parent.getVariablesCount()); | |
136 | + } | |
137 | + | |
138 | + /** | |
139 | + * ここまでで全ての利用可能な変数のなかで、 | |
140 | + * その変数が宣言された時点で利用可能であった変数の個数。 | |
141 | + */ | |
142 | + public Integer getVariableIndex(String name) | |
143 | + { | |
144 | + int index = variables.indexOf(name); | |
145 | + if (index != -1) { | |
146 | + return index + (parent == null ? 0 : parent.getVariablesCount()); | |
147 | + } | |
148 | + return parent == null ? null : parent.getVariableIndex(name); | |
149 | + } | |
150 | + | |
151 | + } | |
152 | + | |
153 | + public RegisterFrameRoot registerFrameRoot = new RegisterFrameRoot(); | |
154 | + | |
155 | + /** | |
156 | + * 演算子などが計算実行の度にnewしなくてもいいように一時的な作業用領域を提供する。 | |
157 | + */ | |
158 | + public static class RegisterFrameRoot | |
159 | + { | |
160 | + | |
161 | + private RegisterFrame registerFrame = new RegisterFrame(this, null); | |
162 | + | |
163 | + public int maxRegisterCount = 0; | |
164 | + | |
165 | + public RegisterFrame getRegisterFrame() | |
166 | + { | |
167 | + return registerFrame; | |
168 | + } | |
169 | + | |
170 | + public void pushRegisterFrame() | |
171 | + { | |
172 | + registerFrame = new RegisterFrame(this, registerFrame); | |
173 | + } | |
174 | + | |
175 | + public void popRegisterFrame() | |
176 | + { | |
177 | + registerFrame = registerFrame.parent; | |
178 | + } | |
179 | + | |
180 | + } | |
181 | + | |
182 | + public static class RegisterFrame | |
183 | + { | |
184 | + | |
185 | + private RegisterFrameRoot registerFrameRoot; | |
186 | + public RegisterFrame parent; | |
187 | + private int registerCount; | |
188 | + | |
189 | + public RegisterFrame(RegisterFrameRoot registerFrameRoot, RegisterFrame parent) | |
190 | + { | |
191 | + this.registerFrameRoot = registerFrameRoot; | |
192 | + this.parent = parent; | |
193 | + } | |
194 | + | |
195 | + public int defineRegister() | |
196 | + { | |
197 | + registerCount++; | |
198 | + | |
199 | + int index = getRegisterCount(); | |
200 | + | |
201 | + if (registerFrameRoot.maxRegisterCount < index) { | |
202 | + registerFrameRoot.maxRegisterCount = index; | |
203 | + } | |
204 | + | |
205 | + return index - 1; | |
206 | + } | |
207 | + | |
208 | + public int getRegisterCount() | |
209 | + { | |
210 | + return registerCount + (parent == null ? 0 : parent.getRegisterCount()); | |
211 | + } | |
212 | + | |
213 | + } | |
214 | + | |
215 | +} |
@@ -1,215 +0,0 @@ | ||
1 | -package mirrg.game.math.wulfenite.script2; | |
2 | - | |
3 | -import java.util.ArrayList; | |
4 | -import java.util.stream.Collectors; | |
5 | - | |
6 | -import mirrg.compile.bromine.syntaxes.TagString; | |
7 | -import mirrg.struct.hydrogen.Tuple; | |
8 | -import mirrg.util.hydrogen.HString; | |
9 | -import mirrg.util.hydrogen.HString.LineProvider; | |
10 | - | |
11 | -public class ArgumentsValidateWS2 | |
12 | -{ | |
13 | - | |
14 | - public final ResponseCompileWS2 resultCompile; | |
15 | - | |
16 | - public ArgumentsValidateWS2(ResponseCompileWS2 resultCompile) | |
17 | - { | |
18 | - this.resultCompile = resultCompile; | |
19 | - } | |
20 | - | |
21 | - //////////////////////////////////////////////////////////////////////////////////////////// | |
22 | - | |
23 | - private ArrayList<Tuple<TagString, String>> messages = new ArrayList<>(); | |
24 | - | |
25 | - public void addMessage(TagString tag, String message) | |
26 | - { | |
27 | - messages.add(new Tuple<>(tag, message)); | |
28 | - } | |
29 | - | |
30 | - public String getMessageString() | |
31 | - { | |
32 | - LineProvider lineProvider = HString.getLineProvider(resultCompile.source); | |
33 | - | |
34 | - return messages.stream() | |
35 | - .map(message -> { | |
36 | - int start = message.getX().start; | |
37 | - Tuple<Integer, Integer> linePosition = resultCompile.getLinePosition(start); | |
38 | - int row = linePosition.getX(); | |
39 | - int column = linePosition.getY(); | |
40 | - String line = lineProvider.getContent(row); | |
41 | - | |
42 | - String left = line.substring(Math.max(column - 20, 0), column); | |
43 | - String right = line.substring(column, Math.min(column + 20, line.length())); | |
44 | - | |
45 | - return String.format( | |
46 | - "(L:%s, C:%s) '%s#%s' %s", | |
47 | - row, | |
48 | - column, | |
49 | - left, | |
50 | - right, | |
51 | - message.getY()); | |
52 | - }) | |
53 | - .collect(Collectors.joining("\n")); | |
54 | - } | |
55 | - | |
56 | - //////////////////////////////////////////////////////////////////////////////////////////// | |
57 | - | |
58 | - public StackFrameRoot stackFrameRoot = new StackFrameRoot(); | |
59 | - | |
60 | - /** | |
61 | - * 行やフレームを超えて利用するための変数を管理する。 | |
62 | - */ | |
63 | - public static class StackFrameRoot | |
64 | - { | |
65 | - | |
66 | - private StackFrame stackFrame = new StackFrame(this, null); | |
67 | - | |
68 | - public int maxVariableCount = 0; | |
69 | - | |
70 | - public StackFrame getStackFrame() | |
71 | - { | |
72 | - return stackFrame; | |
73 | - } | |
74 | - | |
75 | - public void pushStackFrame() | |
76 | - { | |
77 | - stackFrame = new StackFrame(this, stackFrame); | |
78 | - } | |
79 | - | |
80 | - public void popStackFrame() | |
81 | - { | |
82 | - stackFrame = stackFrame.parent; | |
83 | - } | |
84 | - | |
85 | - } | |
86 | - | |
87 | - public static class StackFrame | |
88 | - { | |
89 | - | |
90 | - private StackFrameRoot stackFrameRoot; | |
91 | - public StackFrame parent; | |
92 | - private ArrayList<String> variables = new ArrayList<>(); | |
93 | - | |
94 | - public StackFrame(StackFrameRoot stackFrameRoot, StackFrame parent) | |
95 | - { | |
96 | - this.stackFrameRoot = stackFrameRoot; | |
97 | - this.parent = parent; | |
98 | - } | |
99 | - | |
100 | - /** | |
101 | - * ここまでで全ての利用可能な変数の中に特定の名前が有るかどうか。 | |
102 | - */ | |
103 | - public boolean containsVariable(String name) | |
104 | - { | |
105 | - if (variables.contains(name)) return true; | |
106 | - return parent == null ? false : parent.containsVariable(name); | |
107 | - } | |
108 | - | |
109 | - /** | |
110 | - * このスタックフレームで変数名の占有を宣言。 | |
111 | - * | |
112 | - * @return | |
113 | - * その変数のインデックス。 | |
114 | - * その変数名が利用可能でなかった場合、null。 | |
115 | - */ | |
116 | - public Integer defineVariable(String name) | |
117 | - { | |
118 | - if (containsVariable(name)) return null; | |
119 | - variables.add(name); | |
120 | - | |
121 | - int index = getVariablesCount(); | |
122 | - | |
123 | - if (stackFrameRoot.maxVariableCount < index) { | |
124 | - stackFrameRoot.maxVariableCount = index; | |
125 | - } | |
126 | - | |
127 | - return index - 1; | |
128 | - } | |
129 | - | |
130 | - /** | |
131 | - * ここまでで全ての利用可能な変数の個数。 | |
132 | - */ | |
133 | - public int getVariablesCount() | |
134 | - { | |
135 | - return variables.size() + (parent == null ? 0 : parent.getVariablesCount()); | |
136 | - } | |
137 | - | |
138 | - /** | |
139 | - * ここまでで全ての利用可能な変数のなかで、 | |
140 | - * その変数が宣言された時点で利用可能であった変数の個数。 | |
141 | - */ | |
142 | - public Integer getVariableIndex(String name) | |
143 | - { | |
144 | - int index = variables.indexOf(name); | |
145 | - if (index != -1) { | |
146 | - return index + (parent == null ? 0 : parent.getVariablesCount()); | |
147 | - } | |
148 | - return parent == null ? null : parent.getVariableIndex(name); | |
149 | - } | |
150 | - | |
151 | - } | |
152 | - | |
153 | - public RegisterFrameRoot registerFrameRoot = new RegisterFrameRoot(); | |
154 | - | |
155 | - /** | |
156 | - * 演算子などが計算実行の度にnewしなくてもいいように一時的な作業用領域を提供する。 | |
157 | - */ | |
158 | - public static class RegisterFrameRoot | |
159 | - { | |
160 | - | |
161 | - private RegisterFrame registerFrame = new RegisterFrame(this, null); | |
162 | - | |
163 | - public int maxRegisterCount = 0; | |
164 | - | |
165 | - public RegisterFrame getRegisterFrame() | |
166 | - { | |
167 | - return registerFrame; | |
168 | - } | |
169 | - | |
170 | - public void pushRegisterFrame() | |
171 | - { | |
172 | - registerFrame = new RegisterFrame(this, registerFrame); | |
173 | - } | |
174 | - | |
175 | - public void popRegisterFrame() | |
176 | - { | |
177 | - registerFrame = registerFrame.parent; | |
178 | - } | |
179 | - | |
180 | - } | |
181 | - | |
182 | - public static class RegisterFrame | |
183 | - { | |
184 | - | |
185 | - private RegisterFrameRoot registerFrameRoot; | |
186 | - public RegisterFrame parent; | |
187 | - private int registerCount; | |
188 | - | |
189 | - public RegisterFrame(RegisterFrameRoot registerFrameRoot, RegisterFrame parent) | |
190 | - { | |
191 | - this.registerFrameRoot = registerFrameRoot; | |
192 | - this.parent = parent; | |
193 | - } | |
194 | - | |
195 | - public int defineRegister() | |
196 | - { | |
197 | - registerCount++; | |
198 | - | |
199 | - int index = getRegisterCount(); | |
200 | - | |
201 | - if (registerFrameRoot.maxRegisterCount < index) { | |
202 | - registerFrameRoot.maxRegisterCount = index; | |
203 | - } | |
204 | - | |
205 | - return index - 1; | |
206 | - } | |
207 | - | |
208 | - public int getRegisterCount() | |
209 | - { | |
210 | - return registerCount + (parent == null ? 0 : parent.getRegisterCount()); | |
211 | - } | |
212 | - | |
213 | - } | |
214 | - | |
215 | -} |
@@ -0,0 +1,85 @@ | ||
1 | +package mirrg.game.math.wulfenite.script2; | |
2 | + | |
3 | +import java.io.IOException; | |
4 | +import java.util.Hashtable; | |
5 | +import java.util.function.Supplier; | |
6 | + | |
7 | +import mirrg.compile.bromine.util.CompilerBromine; | |
8 | +import mirrg.compile.lithiumbromide.HLithiumBromide; | |
9 | +import mirrg.compile.lithiumbromide.ITNode; | |
10 | +import mirrg.compile.lithiumbromide.node.ArgumentsCreateCompiler; | |
11 | +import mirrg.compile.lithiumbromide.node.ArgumentsValidate; | |
12 | +import mirrg.compile.lithiumbromide.node.ArgumentsValidatePost; | |
13 | +import mirrg.compile.lithiumbromide.nodes.NodeLines; | |
14 | +import mirrg.game.math.wulfenite.script2.tnode.TNodeRoot; | |
15 | +import mirrg.game.math.wulfenite.script2.tnode.TNodes; | |
16 | + | |
17 | +public class HWulfeniteScript2 | |
18 | +{ | |
19 | + | |
20 | + private static CompilerBromine<TNodeRoot> compiler; | |
21 | + | |
22 | + public static ResponseCompile compile(String source) | |
23 | + { | |
24 | + if (compiler == null) init(); | |
25 | + return new ResponseCompile(compiler.getResponse(source), source); | |
26 | + } | |
27 | + | |
28 | + public static void init() | |
29 | + { | |
30 | + compiler = createCompiler(); | |
31 | + } | |
32 | + | |
33 | + private static CompilerBromine<TNodeRoot> createCompiler() | |
34 | + { | |
35 | + Hashtable<String, Supplier<ITNode>> tableCreator = TNodes.getTableCreator(); | |
36 | + | |
37 | + // 構文定義ファイルを構文解析 | |
38 | + NodeLines node; | |
39 | + try { | |
40 | + node = HLithiumBromide.getCompiler().compile(TNodes.getSource()); | |
41 | + } catch (IOException e) { | |
42 | + throw new RuntimeException(e); | |
43 | + } | |
44 | + | |
45 | + // 構文定義ファイルのルートに対してValidate | |
46 | + ArgumentsValidate argumentsValidate = new ArgumentsValidate() { | |
47 | + | |
48 | + @Override | |
49 | + public void validateIdentifier(String identifierClass) throws Exception | |
50 | + { | |
51 | + if (!tableCreator.containsKey(identifierClass)) { | |
52 | + throw new RuntimeException("No such identifier: " + identifierClass); | |
53 | + } | |
54 | + } | |
55 | + | |
56 | + }; | |
57 | + try { | |
58 | + node.validate(argumentsValidate); | |
59 | + } catch (Exception e) { | |
60 | + throw new RuntimeException(e); | |
61 | + } | |
62 | + | |
63 | + // 構文定義ファイルのルートに対してCreateCompiler | |
64 | + ArgumentsCreateCompiler argumentsCreateCompiler = new ArgumentsCreateCompiler(argumentsValidate) { | |
65 | + | |
66 | + @Override | |
67 | + public ITNode createTNode(String identifierClass) | |
68 | + { | |
69 | + return tableCreator.get(identifierClass).get(); | |
70 | + } | |
71 | + | |
72 | + }; | |
73 | + CompilerBromine<Object> cmpiler = node.createCompiler(argumentsCreateCompiler); | |
74 | + | |
75 | + // 構文定義ファイルのルートに対してValidatePost | |
76 | + try { | |
77 | + node.validatePost(new ArgumentsValidatePost(argumentsCreateCompiler)); | |
78 | + } catch (Exception e) { | |
79 | + throw new RuntimeException(e); | |
80 | + } | |
81 | + | |
82 | + return (CompilerBromine<TNodeRoot>) (CompilerBromine) cmpiler; | |
83 | + } | |
84 | + | |
85 | +} |
@@ -0,0 +1,60 @@ | ||
1 | +package mirrg.game.math.wulfenite.script2; | |
2 | + | |
3 | +import java.util.stream.Collectors; | |
4 | + | |
5 | +import mirrg.compile.bromine.ResponseParse; | |
6 | +import mirrg.game.math.wulfenite.script2.tnode.TNodeRoot; | |
7 | +import mirrg.struct.hydrogen.Tuple; | |
8 | +import mirrg.util.hydrogen.HString; | |
9 | +import mirrg.util.hydrogen.HString.LineProvider; | |
10 | + | |
11 | +public class ResponseCompile | |
12 | +{ | |
13 | + | |
14 | + public ResponseParse<TNodeRoot> response; | |
15 | + public String source; | |
16 | + | |
17 | + private LineProvider lineProvider; | |
18 | + | |
19 | + public ResponseCompile(ResponseParse<TNodeRoot> response, String source) | |
20 | + { | |
21 | + this.response = response; | |
22 | + this.source = source; | |
23 | + } | |
24 | + | |
25 | + public boolean isSuccessed() | |
26 | + { | |
27 | + return response.node != null; | |
28 | + } | |
29 | + | |
30 | + private LineProvider getLineProvider() | |
31 | + { | |
32 | + if (lineProvider == null) lineProvider = HString.getLineProvider(source); | |
33 | + return lineProvider; | |
34 | + } | |
35 | + | |
36 | + /** | |
37 | + * @return Tuple(行番号, 列番号) | |
38 | + */ | |
39 | + public Tuple<Integer, Integer> getLinePosition(int index) | |
40 | + { | |
41 | + int row = getLineProvider().getLineNumber(index); | |
42 | + int column = index - getLineProvider().getStartIndex(row); | |
43 | + return new Tuple<>(row, column); | |
44 | + } | |
45 | + | |
46 | + /** | |
47 | + * 構文候補 | |
48 | + */ | |
49 | + public String getMessageString() | |
50 | + { | |
51 | + Tuple<Integer, Integer> linePosition = getLinePosition(response.argumentsParse.currentIndex); | |
52 | + return response.argumentsParse.hints.stream() | |
53 | + .map(string -> String.format("(L: %s, C: %s) %s", | |
54 | + linePosition.getX(), | |
55 | + linePosition.getY(), | |
56 | + string)) | |
57 | + .collect(Collectors.joining(System.lineSeparator())); | |
58 | + } | |
59 | + | |
60 | +} |
@@ -1,60 +0,0 @@ | ||
1 | -package mirrg.game.math.wulfenite.script2; | |
2 | - | |
3 | -import java.util.stream.Collectors; | |
4 | - | |
5 | -import mirrg.compile.bromine.ResponseParse; | |
6 | -import mirrg.game.math.wulfenite.script2.tnode.TNodeRootWS2; | |
7 | -import mirrg.struct.hydrogen.Tuple; | |
8 | -import mirrg.util.hydrogen.HString; | |
9 | -import mirrg.util.hydrogen.HString.LineProvider; | |
10 | - | |
11 | -public class ResponseCompileWS2 | |
12 | -{ | |
13 | - | |
14 | - public ResponseParse<TNodeRootWS2> response; | |
15 | - public String source; | |
16 | - | |
17 | - private LineProvider lineProvider; | |
18 | - | |
19 | - public ResponseCompileWS2(ResponseParse<TNodeRootWS2> response, String source) | |
20 | - { | |
21 | - this.response = response; | |
22 | - this.source = source; | |
23 | - } | |
24 | - | |
25 | - public boolean isSuccessed() | |
26 | - { | |
27 | - return response.node != null; | |
28 | - } | |
29 | - | |
30 | - private LineProvider getLineProvider() | |
31 | - { | |
32 | - if (lineProvider == null) lineProvider = HString.getLineProvider(source); | |
33 | - return lineProvider; | |
34 | - } | |
35 | - | |
36 | - /** | |
37 | - * @return Tuple(行番号, 列番号) | |
38 | - */ | |
39 | - public Tuple<Integer, Integer> getLinePosition(int index) | |
40 | - { | |
41 | - int row = getLineProvider().getLineNumber(index); | |
42 | - int column = index - getLineProvider().getStartIndex(row); | |
43 | - return new Tuple<>(row, column); | |
44 | - } | |
45 | - | |
46 | - /** | |
47 | - * 構文候補 | |
48 | - */ | |
49 | - public String getMessageString() | |
50 | - { | |
51 | - Tuple<Integer, Integer> linePosition = getLinePosition(response.argumentsParse.currentIndex); | |
52 | - return response.argumentsParse.hints.stream() | |
53 | - .map(string -> String.format("(L: %s, C: %s) %s", | |
54 | - linePosition.getX(), | |
55 | - linePosition.getY(), | |
56 | - string)) | |
57 | - .collect(Collectors.joining(System.lineSeparator())); | |
58 | - } | |
59 | - | |
60 | -} |
@@ -0,0 +1,57 @@ | ||
1 | +package mirrg.game.math.wulfenite.script2; | |
2 | + | |
3 | +import java.util.ArrayList; | |
4 | + | |
5 | +import mirrg.complex.hydrogen.StructureComplex; | |
6 | +import mirrg.game.math.wulfenite.script2.ArgumentsValidate.RegisterFrameRoot; | |
7 | +import mirrg.game.math.wulfenite.script2.ArgumentsValidate.StackFrameRoot; | |
8 | + | |
9 | +public class VirtualMachine | |
10 | +{ | |
11 | + | |
12 | + public ArrayList<String> messages = new ArrayList<>(); | |
13 | + public Stack stack; | |
14 | + public Register register; | |
15 | + | |
16 | + public VirtualMachine(ArgumentsValidate argumentsValidate) | |
17 | + { | |
18 | + this.stack = new Stack(argumentsValidate.stackFrameRoot); | |
19 | + this.register = new Register(argumentsValidate.registerFrameRoot); | |
20 | + } | |
21 | + | |
22 | + public void addMessage(String message) | |
23 | + { | |
24 | + messages.add(message); | |
25 | + } | |
26 | + | |
27 | + public static class Stack | |
28 | + { | |
29 | + | |
30 | + public StructureComplex[] variables; | |
31 | + | |
32 | + public Stack(StackFrameRoot stackFrameRoot) | |
33 | + { | |
34 | + variables = new StructureComplex[stackFrameRoot.maxVariableCount]; | |
35 | + for (int i = 0; i < variables.length; i++) { | |
36 | + variables[i] = new StructureComplex(); | |
37 | + } | |
38 | + } | |
39 | + | |
40 | + } | |
41 | + | |
42 | + public static class Register | |
43 | + { | |
44 | + | |
45 | + public StructureComplex[] registers; | |
46 | + | |
47 | + public Register(RegisterFrameRoot registerFrameRoot) | |
48 | + { | |
49 | + registers = new StructureComplex[registerFrameRoot.maxRegisterCount]; | |
50 | + for (int i = 0; i < registers.length; i++) { | |
51 | + registers[i] = new StructureComplex(); | |
52 | + } | |
53 | + } | |
54 | + | |
55 | + } | |
56 | + | |
57 | +} |
@@ -1,57 +0,0 @@ | ||
1 | -package mirrg.game.math.wulfenite.script2; | |
2 | - | |
3 | -import java.util.ArrayList; | |
4 | - | |
5 | -import mirrg.complex.hydrogen.StructureComplex; | |
6 | -import mirrg.game.math.wulfenite.script2.ArgumentsValidateWS2.RegisterFrameRoot; | |
7 | -import mirrg.game.math.wulfenite.script2.ArgumentsValidateWS2.StackFrameRoot; | |
8 | - | |
9 | -public class VirtualMachineWS2 | |
10 | -{ | |
11 | - | |
12 | - public ArrayList<String> messages = new ArrayList<>(); | |
13 | - public Stack stack; | |
14 | - public Register register; | |
15 | - | |
16 | - public VirtualMachineWS2(ArgumentsValidateWS2 argumentsValidate) | |
17 | - { | |
18 | - this.stack = new Stack(argumentsValidate.stackFrameRoot); | |
19 | - this.register = new Register(argumentsValidate.registerFrameRoot); | |
20 | - } | |
21 | - | |
22 | - public void addMessage(String message) | |
23 | - { | |
24 | - messages.add(message); | |
25 | - } | |
26 | - | |
27 | - public static class Stack | |
28 | - { | |
29 | - | |
30 | - public StructureComplex[] variables; | |
31 | - | |
32 | - public Stack(StackFrameRoot stackFrameRoot) | |
33 | - { | |
34 | - variables = new StructureComplex[stackFrameRoot.maxVariableCount]; | |
35 | - for (int i = 0; i < variables.length; i++) { | |
36 | - variables[i] = new StructureComplex(); | |
37 | - } | |
38 | - } | |
39 | - | |
40 | - } | |
41 | - | |
42 | - public static class Register | |
43 | - { | |
44 | - | |
45 | - public StructureComplex[] registers; | |
46 | - | |
47 | - public Register(RegisterFrameRoot registerFrameRoot) | |
48 | - { | |
49 | - registers = new StructureComplex[registerFrameRoot.maxRegisterCount]; | |
50 | - for (int i = 0; i < registers.length; i++) { | |
51 | - registers[i] = new StructureComplex(); | |
52 | - } | |
53 | - } | |
54 | - | |
55 | - } | |
56 | - | |
57 | -} |
@@ -1,85 +0,0 @@ | ||
1 | -package mirrg.game.math.wulfenite.script2; | |
2 | - | |
3 | -import java.io.IOException; | |
4 | -import java.util.Hashtable; | |
5 | -import java.util.function.Supplier; | |
6 | - | |
7 | -import mirrg.compile.bromine.util.CompilerBromine; | |
8 | -import mirrg.compile.lithiumbromide.HLithiumBromide; | |
9 | -import mirrg.compile.lithiumbromide.ITNode; | |
10 | -import mirrg.compile.lithiumbromide.node.ArgumentsCreateCompiler; | |
11 | -import mirrg.compile.lithiumbromide.node.ArgumentsValidate; | |
12 | -import mirrg.compile.lithiumbromide.node.ArgumentsValidatePost; | |
13 | -import mirrg.compile.lithiumbromide.nodes.NodeLines; | |
14 | -import mirrg.game.math.wulfenite.script2.tnode.TNodeRootWS2; | |
15 | -import mirrg.game.math.wulfenite.script2.tnode.TNodesWS2; | |
16 | - | |
17 | -public class WulfeniteScript2 | |
18 | -{ | |
19 | - | |
20 | - private static CompilerBromine<TNodeRootWS2> compiler; | |
21 | - | |
22 | - public static ResponseCompileWS2 compile(String source) | |
23 | - { | |
24 | - if (compiler == null) init(); | |
25 | - return new ResponseCompileWS2(compiler.getResponse(source), source); | |
26 | - } | |
27 | - | |
28 | - public static void init() | |
29 | - { | |
30 | - compiler = createCompiler(); | |
31 | - } | |
32 | - | |
33 | - private static CompilerBromine<TNodeRootWS2> createCompiler() | |
34 | - { | |
35 | - Hashtable<String, Supplier<ITNode>> tableCreator = TNodesWS2.getTableCreator(); | |
36 | - | |
37 | - // 構文定義ファイルを構文解析 | |
38 | - NodeLines node; | |
39 | - try { | |
40 | - node = HLithiumBromide.getCompiler().compile(TNodesWS2.getSource()); | |
41 | - } catch (IOException e) { | |
42 | - throw new RuntimeException(e); | |
43 | - } | |
44 | - | |
45 | - // 構文定義ファイルのルートに対してValidate | |
46 | - ArgumentsValidate argumentsValidate = new ArgumentsValidate() { | |
47 | - | |
48 | - @Override | |
49 | - public void validateIdentifier(String identifierClass) throws Exception | |
50 | - { | |
51 | - if (!tableCreator.containsKey(identifierClass)) { | |
52 | - throw new RuntimeException("No such identifier: " + identifierClass); | |
53 | - } | |
54 | - } | |
55 | - | |
56 | - }; | |
57 | - try { | |
58 | - node.validate(argumentsValidate); | |
59 | - } catch (Exception e) { | |
60 | - throw new RuntimeException(e); | |
61 | - } | |
62 | - | |
63 | - // 構文定義ファイルのルートに対してCreateCompiler | |
64 | - ArgumentsCreateCompiler argumentsCreateCompiler = new ArgumentsCreateCompiler(argumentsValidate) { | |
65 | - | |
66 | - @Override | |
67 | - public ITNode createTNode(String identifierClass) | |
68 | - { | |
69 | - return tableCreator.get(identifierClass).get(); | |
70 | - } | |
71 | - | |
72 | - }; | |
73 | - CompilerBromine<Object> cmpiler = node.createCompiler(argumentsCreateCompiler); | |
74 | - | |
75 | - // 構文定義ファイルのルートに対してValidatePost | |
76 | - try { | |
77 | - node.validatePost(new ArgumentsValidatePost(argumentsCreateCompiler)); | |
78 | - } catch (Exception e) { | |
79 | - throw new RuntimeException(e); | |
80 | - } | |
81 | - | |
82 | - return (CompilerBromine<TNodeRootWS2>) (CompilerBromine) cmpiler; | |
83 | - } | |
84 | - | |
85 | -} |
@@ -1,13 +0,0 @@ | ||
1 | -package mirrg.game.math.wulfenite.script2.tnode; | |
2 | - | |
3 | -import mirrg.game.math.wulfenite.script2.ArgumentsInvokeWS2; | |
4 | -import mirrg.game.math.wulfenite.script2.ArgumentsValidateWS2; | |
5 | - | |
6 | -public interface IRoutine | |
7 | -{ | |
8 | - | |
9 | - public boolean validate(ArgumentsValidateWS2 argumentsValidate); | |
10 | - | |
11 | - public void invoke(ArgumentsInvokeWS2 argumentsInvoke); | |
12 | - | |
13 | -} |
@@ -0,0 +1,13 @@ | ||
1 | +package mirrg.game.math.wulfenite.script2.tnode; | |
2 | + | |
3 | +import mirrg.game.math.wulfenite.script2.ArgumentsInvoke; | |
4 | +import mirrg.game.math.wulfenite.script2.ArgumentsValidate; | |
5 | + | |
6 | +public interface ITNodeRoutine | |
7 | +{ | |
8 | + | |
9 | + public boolean validate(ArgumentsValidate argumentsValidate); | |
10 | + | |
11 | + public void invoke(ArgumentsInvoke argumentsInvoke); | |
12 | + | |
13 | +} |
@@ -0,0 +1,25 @@ | ||
1 | +package mirrg.game.math.wulfenite.script2.tnode; | |
2 | + | |
3 | +import mirrg.compile.lithiumbromide.util.TNodeBase; | |
4 | +import mirrg.game.math.wulfenite.script2.ArgumentsInvoke; | |
5 | +import mirrg.game.math.wulfenite.script2.ArgumentsValidate; | |
6 | +import mirrg.game.math.wulfenite.script2.tnode.TNodes.Routines; | |
7 | + | |
8 | +public class TNodeRoot extends TNodeBase implements ITNodeRoutine | |
9 | +{ | |
10 | + | |
11 | + public Routines routines; | |
12 | + | |
13 | + @Override | |
14 | + public boolean validate(ArgumentsValidate argumentsValidate) | |
15 | + { | |
16 | + return routines.validate(argumentsValidate); | |
17 | + } | |
18 | + | |
19 | + @Override | |
20 | + public void invoke(ArgumentsInvoke argumentsInvoke) | |
21 | + { | |
22 | + routines.invoke(argumentsInvoke); | |
23 | + } | |
24 | + | |
25 | +} |
@@ -1,25 +0,0 @@ | ||
1 | -package mirrg.game.math.wulfenite.script2.tnode; | |
2 | - | |
3 | -import mirrg.compile.lithiumbromide.util.TNodeBase; | |
4 | -import mirrg.game.math.wulfenite.script2.ArgumentsInvokeWS2; | |
5 | -import mirrg.game.math.wulfenite.script2.ArgumentsValidateWS2; | |
6 | -import mirrg.game.math.wulfenite.script2.tnode.TNodesWS2.Routines; | |
7 | - | |
8 | -public class TNodeRootWS2 extends TNodeBase implements IRoutine | |
9 | -{ | |
10 | - | |
11 | - public Routines routines; | |
12 | - | |
13 | - @Override | |
14 | - public boolean validate(ArgumentsValidateWS2 argumentsValidate) | |
15 | - { | |
16 | - return routines.validate(argumentsValidate); | |
17 | - } | |
18 | - | |
19 | - @Override | |
20 | - public void invoke(ArgumentsInvokeWS2 argumentsInvoke) | |
21 | - { | |
22 | - routines.invoke(argumentsInvoke); | |
23 | - } | |
24 | - | |
25 | -} |
@@ -0,0 +1,745 @@ | ||
1 | +package mirrg.game.math.wulfenite.script2.tnode; | |
2 | + | |
3 | +import java.io.BufferedReader; | |
4 | +import java.io.IOException; | |
5 | +import java.io.InputStreamReader; | |
6 | +import java.lang.reflect.Constructor; | |
7 | +import java.lang.reflect.InvocationTargetException; | |
8 | +import java.lang.reflect.Modifier; | |
9 | +import java.util.ArrayList; | |
10 | +import java.util.Hashtable; | |
11 | +import java.util.function.Supplier; | |
12 | +import java.util.stream.Collectors; | |
13 | + | |
14 | +import org.eclipse.jdt.annotation.Nullable; | |
15 | + | |
16 | +import mirrg.compile.bromine.syntaxes.TagString; | |
17 | +import mirrg.compile.lithiumbromide.ITNode; | |
18 | +import mirrg.compile.lithiumbromide.nodes.NodeOperation.Operation; | |
19 | +import mirrg.compile.lithiumbromide.util.TNodeBase; | |
20 | +import mirrg.complex.hydrogen.StructureComplex; | |
21 | +import mirrg.complex.hydrogen.functions.Exponential; | |
22 | +import mirrg.game.math.wulfenite.script2.ArgumentsInvoke; | |
23 | +import mirrg.game.math.wulfenite.script2.ArgumentsValidate; | |
24 | + | |
25 | +public class TNodes | |
26 | +{ | |
27 | + | |
28 | + public static String getSource() throws IOException | |
29 | + { | |
30 | + return new BufferedReader(new InputStreamReader( | |
31 | + TNodes.class.getResource("test.libr").openStream())).lines() | |
32 | + .collect(Collectors.joining(System.lineSeparator())); | |
33 | + } | |
34 | + | |
35 | + public static Hashtable<String, Supplier<ITNode>> getTableCreator() | |
36 | + { | |
37 | + Hashtable<String, Supplier<ITNode>> hash = new Hashtable<>(); | |
38 | + | |
39 | + try { | |
40 | + | |
41 | + for (Class<?> clazz : TNodes.class.getClasses()) { | |
42 | + if (clazz.isInterface()) { | |
43 | + continue; | |
44 | + } | |
45 | + if (Modifier.isAbstract(clazz.getModifiers())) { | |
46 | + continue; | |
47 | + } | |
48 | + if (!ITNode.class.isAssignableFrom(clazz)) { | |
49 | + throw new ClassCastException(clazz.getName() + " is not " + ITNode.class.getName()); | |
50 | + } | |
51 | + @SuppressWarnings("unchecked") | |
52 | + Class<? extends ITNode> clazz2 = (Class<? extends ITNode>) clazz; | |
53 | + Constructor<? extends ITNode> constructor = clazz2.getConstructor(); | |
54 | + hash.put(clazz2.getSimpleName(), () -> { | |
55 | + try { | |
56 | + return constructor.newInstance(); | |
57 | + } catch (InvocationTargetException | IllegalAccessException | InstantiationException e) { | |
58 | + throw new RuntimeException(e); | |
59 | + } | |
60 | + }); | |
61 | + } | |
62 | + | |
63 | + } catch (NoSuchMethodException | SecurityException e) { | |
64 | + throw new RuntimeException(e); | |
65 | + } | |
66 | + | |
67 | + hash.put("Root", TNodeRoot::new); | |
68 | + | |
69 | + return hash; | |
70 | + } | |
71 | + | |
72 | + public static class Comments extends TNodeBase | |
73 | + { | |
74 | + | |
75 | + public ArrayList<TagString> strings; | |
76 | + | |
77 | + } | |
78 | + | |
79 | + public static class Identifier extends TNodeBase | |
80 | + { | |
81 | + | |
82 | + public TagString string; | |
83 | + | |
84 | + } | |
85 | + | |
86 | + public static class Sign extends TNodeBase | |
87 | + { | |
88 | + | |
89 | + public TagString string; | |
90 | + | |
91 | + } | |
92 | + | |
93 | + public static class IntegerUnsigned extends TNodeBase | |
94 | + { | |
95 | + | |
96 | + public TagString string; | |
97 | + | |
98 | + public Integer value; | |
99 | + | |
100 | + public int get() | |
101 | + { | |
102 | + if (value == null) value = Integer.parseInt(string.string, 10); | |
103 | + return value; | |
104 | + } | |
105 | + | |
106 | + } | |
107 | + | |
108 | + public static class IntegerSigned extends TNodeBase | |
109 | + { | |
110 | + | |
111 | + public @Nullable Sign sign; | |
112 | + public IntegerUnsigned integer; | |
113 | + | |
114 | + public Integer value; | |
115 | + | |
116 | + public int get() | |
117 | + { | |
118 | + if (value == null) value = sign != null && sign.string.string.equals("-") ? -integer.get() : integer.get(); | |
119 | + return value; | |
120 | + } | |
121 | + | |
122 | + } | |
123 | + | |
124 | + public static class Fraction extends TNodeBase | |
125 | + { | |
126 | + | |
127 | + public TagString string; | |
128 | + | |
129 | + } | |
130 | + | |
131 | + public static class Exponent extends TNodeBase | |
132 | + { | |
133 | + | |
134 | + public IntegerSigned integer; | |
135 | + | |
136 | + } | |
137 | + | |
138 | + public static class Real extends TNodeBase | |
139 | + { | |
140 | + | |
141 | + public IntegerSigned significand; | |
142 | + public @Nullable Fraction fraction; | |
143 | + public @Nullable Exponent exponent; | |
144 | + | |
145 | + public Double value; | |
146 | + | |
147 | + public double get() | |
148 | + { | |
149 | + if (value == null) value = Double.parseDouble(String.format("%s%s%s", | |
150 | + significand.get(), | |
151 | + fraction == null ? "" : "." + fraction.string.string, | |
152 | + exponent == null ? "" : "E" + exponent.integer.get())); | |
153 | + return value; | |
154 | + } | |
155 | + | |
156 | + } | |
157 | + | |
158 | + public static class Imaginary extends TNodeBase | |
159 | + { | |
160 | + | |
161 | + public Real real; | |
162 | + | |
163 | + } | |
164 | + | |
165 | + public static class TokenIdentifier extends TNodeBase | |
166 | + { | |
167 | + | |
168 | + public Identifier node; | |
169 | + | |
170 | + } | |
171 | + | |
172 | + public static class TokenDecimal extends TNodeBase implements IExpression | |
173 | + { | |
174 | + | |
175 | + public IntegerSigned node; | |
176 | + | |
177 | + @Override | |
178 | + public boolean validate(ArgumentsValidate argumentsValidate) | |
179 | + { | |
180 | + return true; | |
181 | + } | |
182 | + | |
183 | + @Override | |
184 | + public void calculate(ArgumentsInvoke argumentsInvoke, StructureComplex complex) | |
185 | + { | |
186 | + complex.re = node.get(); | |
187 | + complex.im = 0; | |
188 | + } | |
189 | + | |
190 | + } | |
191 | + | |
192 | + public static class TokenInteger extends TNodeBase implements IExpression | |
193 | + { | |
194 | + | |
195 | + public IntegerUnsigned radix; | |
196 | + public TagString string; | |
197 | + | |
198 | + public Integer value; | |
199 | + | |
200 | + public double get() | |
201 | + { | |
202 | + if (value == null) value = Integer.parseInt(string.string, radix.get() == 0 ? 16 : radix.get()); | |
203 | + return value; | |
204 | + } | |
205 | + | |
206 | + @Override | |
207 | + public boolean validate(ArgumentsValidate argumentsValidate) | |
208 | + { | |
209 | + if (radix.get() > 36) { | |
210 | + argumentsValidate.addMessage(radix.string, "基数は0~36でなければなりません: " + radix.get()); | |
211 | + return false; | |
212 | + } | |
213 | + | |
214 | + return true; | |
215 | + } | |
216 | + | |
217 | + @Override | |
218 | + public void calculate(ArgumentsInvoke argumentsInvoke, StructureComplex complex) | |
219 | + { | |
220 | + complex.re = get(); | |
221 | + complex.im = 0; | |
222 | + } | |
223 | + | |
224 | + } | |
225 | + | |
226 | + public static class TokenReal extends TNodeBase implements IExpression | |
227 | + { | |
228 | + | |
229 | + public Real node; | |
230 | + | |
231 | + @Override | |
232 | + public boolean validate(ArgumentsValidate argumentsValidate) | |
233 | + { | |
234 | + return true; | |
235 | + } | |
236 | + | |
237 | + @Override | |
238 | + public void calculate(ArgumentsInvoke argumentsInvoke, StructureComplex complex) | |
239 | + { | |
240 | + complex.re = node.get(); | |
241 | + complex.im = 0; | |
242 | + } | |
243 | + | |
244 | + } | |
245 | + | |
246 | + public static class TokenImaginary extends TNodeBase implements IExpression | |
247 | + { | |
248 | + | |
249 | + public Imaginary node; | |
250 | + | |
251 | + @Override | |
252 | + public boolean validate(ArgumentsValidate argumentsValidate) | |
253 | + { | |
254 | + return true; | |
255 | + } | |
256 | + | |
257 | + @Override | |
258 | + public void calculate(ArgumentsInvoke argumentsInvoke, StructureComplex complex) | |
259 | + { | |
260 | + complex.re = 0; | |
261 | + complex.im = node.real.get(); | |
262 | + } | |
263 | + | |
264 | + } | |
265 | + | |
266 | + public static class Variable extends TNodeBase implements IExpression | |
267 | + { | |
268 | + | |
269 | + public TokenIdentifier token; | |
270 | + | |
271 | + public int index; | |
272 | + | |
273 | + @Override | |
274 | + public boolean validate(ArgumentsValidate argumentsValidate) | |
275 | + { | |
276 | + String name = token.node.string.string; | |
277 | + | |
278 | + Integer index2 = argumentsValidate.stackFrameRoot.getStackFrame().getVariableIndex(name); | |
279 | + if (index2 == null) { | |
280 | + argumentsValidate.addMessage(token.node.string, "未宣言の変数です: " + name); | |
281 | + return false; | |
282 | + } else { | |
283 | + index = index2; | |
284 | + } | |
285 | + | |
286 | + return true; | |
287 | + } | |
288 | + | |
289 | + @Override | |
290 | + public void calculate(ArgumentsInvoke argumentsInvoke, StructureComplex complex) | |
291 | + { | |
292 | + complex.set(argumentsInvoke.virtualMachine.stack.variables[index]); | |
293 | + } | |
294 | + | |
295 | + } | |
296 | + | |
297 | + public static class LiteralNumeric extends TNodeBase implements IExpression | |
298 | + { | |
299 | + | |
300 | + public IExpression token; | |
301 | + | |
302 | + @Override | |
303 | + public boolean validate(ArgumentsValidate argumentsValidate) | |
304 | + { | |
305 | + return token.validate(argumentsValidate); | |
306 | + } | |
307 | + | |
308 | + @Override | |
309 | + public void calculate(ArgumentsInvoke argumentsInvoke, StructureComplex complex) | |
310 | + { | |
311 | + token.calculate(argumentsInvoke, complex); | |
312 | + } | |
313 | + | |
314 | + } | |
315 | + | |
316 | + public static class Bracket extends TNodeBase implements IExpression | |
317 | + { | |
318 | + | |
319 | + public IExpression expression; | |
320 | + | |
321 | + @Override | |
322 | + public boolean validate(ArgumentsValidate argumentsValidate) | |
323 | + { | |
324 | + return expression.validate(argumentsValidate); | |
325 | + } | |
326 | + | |
327 | + @Override | |
328 | + public void calculate(ArgumentsInvoke argumentsInvoke, StructureComplex complex) | |
329 | + { | |
330 | + expression.calculate(argumentsInvoke, complex); | |
331 | + } | |
332 | + | |
333 | + } | |
334 | + | |
335 | + public static class ExpressionSingle extends TNodeBase implements IExpression | |
336 | + { | |
337 | + | |
338 | + public ArrayList<Operator> operators; | |
339 | + public IExpression expression; | |
340 | + | |
341 | + @Override | |
342 | + public boolean validate(ArgumentsValidate argumentsValidate) | |
343 | + { | |
344 | + if (!expression.validate(argumentsValidate)) return false; | |
345 | + | |
346 | + for (int i = operators.size() - 1; i >= 0; i--) { | |
347 | + String operator = operators.get(i).string.string; | |
348 | + switch (operator) { | |
349 | + case "+": | |
350 | + break; | |
351 | + case "-": | |
352 | + break; | |
353 | + case "~": | |
354 | + break; | |
355 | + default: | |
356 | + argumentsValidate.addMessage(operators.get(i).string, "未知の演算子です: " + operator); | |
357 | + return false; | |
358 | + } | |
359 | + } | |
360 | + | |
361 | + return true; | |
362 | + } | |
363 | + | |
364 | + @Override | |
365 | + public void calculate(ArgumentsInvoke argumentsInvoke, StructureComplex complex) | |
366 | + { | |
367 | + expression.calculate(argumentsInvoke, complex); | |
368 | + | |
369 | + for (int i = operators.size() - 1; i >= 0; i--) { | |
370 | + String operator = operators.get(i).string.string; | |
371 | + switch (operator) { | |
372 | + case "+": | |
373 | + break; | |
374 | + case "-": | |
375 | + complex.neg(); | |
376 | + break; | |
377 | + case "~": | |
378 | + complex.con(); | |
379 | + break; | |
380 | + default: | |
381 | + throw new RuntimeException(); | |
382 | + } | |
383 | + } | |
384 | + } | |
385 | + | |
386 | + } | |
387 | + | |
388 | + public static class Operator extends TNodeBase | |
389 | + { | |
390 | + | |
391 | + public TagString string; | |
392 | + | |
393 | + } | |
394 | + | |
395 | + public static class Operations extends TNodeBase implements IExpression | |
396 | + { | |
397 | + | |
398 | + public Operation operations; | |
399 | + public boolean isRight; | |
400 | + public int indexRegister; | |
401 | + | |
402 | + public Operations() | |
403 | + { | |
404 | + this(false); | |
405 | + } | |
406 | + | |
407 | + public Operations(boolean isRight) | |
408 | + { | |
409 | + this.isRight = isRight; | |
410 | + } | |
411 | + | |
412 | + @Override | |
413 | + public boolean validate(ArgumentsValidate argumentsValidate) | |
414 | + { | |
415 | + if (isRight) { | |
416 | + if (!((IExpression) operations.operands.get(operations.operators.size())).validate(argumentsValidate)) { | |
417 | + return false; | |
418 | + } | |
419 | + | |
420 | + for (int i = operations.operators.size() - 1; i >= 0; i--) { | |
421 | + | |
422 | + IExpression operand = (IExpression) operations.operands.get(i); | |
423 | + if (!operand.validate(argumentsValidate)) { | |
424 | + return false; | |
425 | + } | |
426 | + | |
427 | + Operator operator = (Operator) operations.operators.get(i); | |
428 | + if (!validateOperator(argumentsValidate, operator)) { | |
429 | + return false; | |
430 | + } | |
431 | + } | |
432 | + | |
433 | + } else { | |
434 | + if (!((IExpression) operations.operands.get(0)).validate(argumentsValidate)) { | |
435 | + return false; | |
436 | + } | |
437 | + | |
438 | + for (int i = 0; i < operations.operators.size(); i++) { | |
439 | + | |
440 | + IExpression operand = (IExpression) operations.operands.get(i + 1); | |
441 | + if (!operand.validate(argumentsValidate)) { | |
442 | + return false; | |
443 | + } | |
444 | + | |
445 | + Operator operator = (Operator) operations.operators.get(i); | |
446 | + if (!validateOperator(argumentsValidate, operator)) { | |
447 | + return false; | |
448 | + } | |
449 | + } | |
450 | + | |
451 | + } | |
452 | + | |
453 | + // define register | |
454 | + indexRegister = argumentsValidate.registerFrameRoot.getRegisterFrame().defineRegister(); | |
455 | + | |
456 | + return true; | |
457 | + } | |
458 | + | |
459 | + @Override | |
460 | + public void calculate(ArgumentsInvoke argumentsInvoke, StructureComplex complex) | |
461 | + { | |
462 | + if (isRight) { | |
463 | + ((IExpression) operations.operands.get(operations.operators.size())).calculate(argumentsInvoke, complex); | |
464 | + | |
465 | + StructureComplex register = argumentsInvoke.virtualMachine.register.registers[indexRegister]; | |
466 | + for (int i = operations.operators.size() - 1; i >= 0; i--) { | |
467 | + | |
468 | + IExpression operand = (IExpression) operations.operands.get(i); | |
469 | + operand.calculate(argumentsInvoke, register); | |
470 | + | |
471 | + Operator operator = (Operator) operations.operators.get(i); | |
472 | + operate(operator, register, complex); | |
473 | + } | |
474 | + | |
475 | + } else { | |
476 | + ((IExpression) operations.operands.get(0)).calculate(argumentsInvoke, complex); | |
477 | + | |
478 | + StructureComplex register = argumentsInvoke.virtualMachine.register.registers[indexRegister]; | |
479 | + for (int i = 0; i < operations.operators.size(); i++) { | |
480 | + | |
481 | + IExpression operand = (IExpression) operations.operands.get(i + 1); | |
482 | + operand.calculate(argumentsInvoke, register); | |
483 | + | |
484 | + Operator operator = (Operator) operations.operators.get(i); | |
485 | + operate(operator, complex, register); | |
486 | + } | |
487 | + | |
488 | + } | |
489 | + } | |
490 | + | |
491 | + private boolean validateOperator(ArgumentsValidate argumentsValidate, Operator operator) | |
492 | + { | |
493 | + switch (operator.string.string) { | |
494 | + case "^": | |
495 | + break; | |
496 | + case "*": | |
497 | + break; | |
498 | + case "/": | |
499 | + break; | |
500 | + case "+": | |
501 | + break; | |
502 | + case "-": | |
503 | + break; | |
504 | + default: | |
505 | + argumentsValidate.addMessage(operator.string, "未知の演算子です: " + operator); | |
506 | + return false; | |
507 | + } | |
508 | + | |
509 | + return true; | |
510 | + } | |
511 | + | |
512 | + private void operate(Operator operator, StructureComplex left, StructureComplex right) | |
513 | + { | |
514 | + | |
515 | + switch (operator.string.string) { | |
516 | + case "^": | |
517 | + Exponential.exp(right, left); | |
518 | + break; | |
519 | + case "*": | |
520 | + left.mul(right); | |
521 | + break; | |
522 | + case "/": | |
523 | + left.div(right); | |
524 | + break; | |
525 | + case "+": | |
526 | + left.add(right); | |
527 | + break; | |
528 | + case "-": | |
529 | + left.sub(right); | |
530 | + break; | |
531 | + default: | |
532 | + throw new RuntimeException(); | |
533 | + } | |
534 | + } | |
535 | + | |
536 | + } | |
537 | + | |
538 | + public static class OperationsRight extends Operations | |
539 | + { | |
540 | + | |
541 | + public OperationsRight() | |
542 | + { | |
543 | + super(true); | |
544 | + } | |
545 | + | |
546 | + } | |
547 | + | |
548 | + public static interface IExpression | |
549 | + { | |
550 | + | |
551 | + public boolean validate(ArgumentsValidate argumentsValidate); | |
552 | + | |
553 | + public void calculate(ArgumentsInvoke argumentsInvoke, StructureComplex complex); | |
554 | + | |
555 | + } | |
556 | + | |
557 | + public static abstract class RoutineAssignmentBase extends TNodeBase implements ITNodeRoutine | |
558 | + { | |
559 | + | |
560 | + public int indexVariable; | |
561 | + public int indexRegister; | |
562 | + public IExpression expression; | |
563 | + | |
564 | + @Override | |
565 | + public boolean validate(ArgumentsValidate argumentsValidate) | |
566 | + { | |
567 | + String name = getNameVariable(); | |
568 | + | |
569 | + Integer indexVariable2 = argumentsValidate.stackFrameRoot.getStackFrame().getVariableIndex(name); | |
570 | + if (indexVariable2 == null) { | |
571 | + argumentsValidate.addMessage(getToken(), "未宣言の変数です: " + name); | |
572 | + return false; | |
573 | + } else { | |
574 | + indexVariable = indexVariable2; | |
575 | + } | |
576 | + | |
577 | + if (!expression.validate(argumentsValidate)) return false; | |
578 | + | |
579 | + // define register | |
580 | + indexRegister = argumentsValidate.registerFrameRoot.getRegisterFrame().defineRegister(); | |
581 | + | |
582 | + return true; | |
583 | + } | |
584 | + | |
585 | + @Override | |
586 | + public void invoke(ArgumentsInvoke argumentsInvoke) | |
587 | + { | |
588 | + StructureComplex register = argumentsInvoke.virtualMachine.register.registers[indexRegister]; | |
589 | + expression.calculate(argumentsInvoke, register); | |
590 | + argumentsInvoke.virtualMachine.stack.variables[indexVariable].set(register); | |
591 | + } | |
592 | + | |
593 | + protected abstract String getNameVariable(); | |
594 | + | |
595 | + protected abstract TagString getToken(); | |
596 | + | |
597 | + } | |
598 | + | |
599 | + public static class RoutineExpression extends RoutineAssignmentBase | |
600 | + { | |
601 | + | |
602 | + // TODO ";"にあっているのをなんとかする | |
603 | + public TagString token; | |
604 | + | |
605 | + @Override | |
606 | + protected String getNameVariable() | |
607 | + { | |
608 | + return "_"; | |
609 | + } | |
610 | + | |
611 | + @Override | |
612 | + protected TagString getToken() | |
613 | + { | |
614 | + return token; | |
615 | + } | |
616 | + | |
617 | + } | |
618 | + | |
619 | + public static class RoutineAssignment extends RoutineAssignmentBase | |
620 | + { | |
621 | + | |
622 | + public TokenIdentifier identifier; | |
623 | + | |
624 | + @Override | |
625 | + protected String getNameVariable() | |
626 | + { | |
627 | + return identifier.node.string.string; | |
628 | + } | |
629 | + | |
630 | + @Override | |
631 | + protected TagString getToken() | |
632 | + { | |
633 | + return identifier.node.string; | |
634 | + } | |
635 | + | |
636 | + } | |
637 | + | |
638 | + public static class RoutineDefinitionVariable extends TNodeBase implements ITNodeRoutine | |
639 | + { | |
640 | + | |
641 | + public TokenIdentifier identifier; | |
642 | + public int index; | |
643 | + | |
644 | + @Override | |
645 | + public boolean validate(ArgumentsValidate argumentsValidate) | |
646 | + { | |
647 | + String name = identifier.node.string.string; | |
648 | + | |
649 | + Integer index2 = argumentsValidate.stackFrameRoot.getStackFrame().getVariableIndex(name); | |
650 | + if (index2 != null) { | |
651 | + argumentsValidate.addMessage(identifier.node.string, "重複する変数名です: " + name); | |
652 | + return false; | |
653 | + } | |
654 | + | |
655 | + index = argumentsValidate.stackFrameRoot.getStackFrame().defineVariable(name); | |
656 | + | |
657 | + return true; | |
658 | + } | |
659 | + | |
660 | + @Override | |
661 | + public void invoke(ArgumentsInvoke argumentsInvoke) | |
662 | + { | |
663 | + // nothing to do | |
664 | + } | |
665 | + | |
666 | + } | |
667 | + | |
668 | + public static class RoutineDefinitionAndAssignmentVariable extends RoutineAssignmentBase | |
669 | + { | |
670 | + | |
671 | + public TokenIdentifier identifier; | |
672 | + | |
673 | + @Override | |
674 | + protected String getNameVariable() | |
675 | + { | |
676 | + return identifier.node.string.string; | |
677 | + } | |
678 | + | |
679 | + @Override | |
680 | + protected TagString getToken() | |
681 | + { | |
682 | + return identifier.node.string; | |
683 | + } | |
684 | + | |
685 | + @Override | |
686 | + public boolean validate(ArgumentsValidate argumentsValidate) | |
687 | + { | |
688 | + String name = getNameVariable(); | |
689 | + | |
690 | + Integer indexVariable2 = argumentsValidate.stackFrameRoot.getStackFrame().getVariableIndex(name); | |
691 | + if (indexVariable2 != null) { | |
692 | + argumentsValidate.addMessage(identifier.node.string, "重複する変数名です: " + name); | |
693 | + return false; | |
694 | + } | |
695 | + | |
696 | + indexVariable = argumentsValidate.stackFrameRoot.getStackFrame().defineVariable(name); | |
697 | + | |
698 | + if (!expression.validate(argumentsValidate)) return false; | |
699 | + | |
700 | + // define register | |
701 | + indexRegister = argumentsValidate.registerFrameRoot.getRegisterFrame().defineRegister(); | |
702 | + | |
703 | + return true; | |
704 | + } | |
705 | + | |
706 | + @Override | |
707 | + public void invoke(ArgumentsInvoke argumentsInvoke) | |
708 | + { | |
709 | + StructureComplex register = argumentsInvoke.virtualMachine.register.registers[indexRegister]; | |
710 | + expression.calculate(argumentsInvoke, register); | |
711 | + argumentsInvoke.virtualMachine.stack.variables[indexVariable].set(register); | |
712 | + } | |
713 | + | |
714 | + } | |
715 | + | |
716 | + public static class Routines extends TNodeBase implements ITNodeRoutine | |
717 | + { | |
718 | + | |
719 | + public ArrayList<ITNodeRoutine> routines; | |
720 | + | |
721 | + @Override | |
722 | + public boolean validate(ArgumentsValidate argumentsValidate) | |
723 | + { | |
724 | + for (ITNodeRoutine routine : routines) { | |
725 | + if (!routine.validate(argumentsValidate)) return false; | |
726 | + } | |
727 | + return true; | |
728 | + } | |
729 | + | |
730 | + @Override | |
731 | + public void invoke(ArgumentsInvoke argumentsInvoke) | |
732 | + { | |
733 | + for (ITNodeRoutine routine : routines) { | |
734 | + routine.invoke(argumentsInvoke); | |
735 | + } | |
736 | + } | |
737 | + | |
738 | + } | |
739 | + | |
740 | + public static class ExpressionRoutined extends TNodeBase | |
741 | + { | |
742 | + // TODO | |
743 | + } | |
744 | + | |
745 | +} |
@@ -1,745 +0,0 @@ | ||
1 | -package mirrg.game.math.wulfenite.script2.tnode; | |
2 | - | |
3 | -import java.io.BufferedReader; | |
4 | -import java.io.IOException; | |
5 | -import java.io.InputStreamReader; | |
6 | -import java.lang.reflect.Constructor; | |
7 | -import java.lang.reflect.InvocationTargetException; | |
8 | -import java.lang.reflect.Modifier; | |
9 | -import java.util.ArrayList; | |
10 | -import java.util.Hashtable; | |
11 | -import java.util.function.Supplier; | |
12 | -import java.util.stream.Collectors; | |
13 | - | |
14 | -import org.eclipse.jdt.annotation.Nullable; | |
15 | - | |
16 | -import mirrg.compile.bromine.syntaxes.TagString; | |
17 | -import mirrg.compile.lithiumbromide.ITNode; | |
18 | -import mirrg.compile.lithiumbromide.nodes.NodeOperation.Operation; | |
19 | -import mirrg.compile.lithiumbromide.util.TNodeBase; | |
20 | -import mirrg.complex.hydrogen.StructureComplex; | |
21 | -import mirrg.complex.hydrogen.functions.Exponential; | |
22 | -import mirrg.game.math.wulfenite.script2.ArgumentsInvokeWS2; | |
23 | -import mirrg.game.math.wulfenite.script2.ArgumentsValidateWS2; | |
24 | - | |
25 | -public class TNodesWS2 | |
26 | -{ | |
27 | - | |
28 | - public static String getSource() throws IOException | |
29 | - { | |
30 | - return new BufferedReader(new InputStreamReader( | |
31 | - TNodesWS2.class.getResource("test.libr").openStream())).lines() | |
32 | - .collect(Collectors.joining(System.lineSeparator())); | |
33 | - } | |
34 | - | |
35 | - public static Hashtable<String, Supplier<ITNode>> getTableCreator() | |
36 | - { | |
37 | - Hashtable<String, Supplier<ITNode>> hash = new Hashtable<>(); | |
38 | - | |
39 | - try { | |
40 | - | |
41 | - for (Class<?> clazz : TNodesWS2.class.getClasses()) { | |
42 | - if (clazz.isInterface()) { | |
43 | - continue; | |
44 | - } | |
45 | - if (Modifier.isAbstract(clazz.getModifiers())) { | |
46 | - continue; | |
47 | - } | |
48 | - if (!ITNode.class.isAssignableFrom(clazz)) { | |
49 | - throw new ClassCastException(clazz.getName() + " is not " + ITNode.class.getName()); | |
50 | - } | |
51 | - @SuppressWarnings("unchecked") | |
52 | - Class<? extends ITNode> clazz2 = (Class<? extends ITNode>) clazz; | |
53 | - Constructor<? extends ITNode> constructor = clazz2.getConstructor(); | |
54 | - hash.put(clazz2.getSimpleName(), () -> { | |
55 | - try { | |
56 | - return constructor.newInstance(); | |
57 | - } catch (InvocationTargetException | IllegalAccessException | InstantiationException e) { | |
58 | - throw new RuntimeException(e); | |
59 | - } | |
60 | - }); | |
61 | - } | |
62 | - | |
63 | - } catch (NoSuchMethodException | SecurityException e) { | |
64 | - throw new RuntimeException(e); | |
65 | - } | |
66 | - | |
67 | - hash.put("Root", TNodeRootWS2::new); | |
68 | - | |
69 | - return hash; | |
70 | - } | |
71 | - | |
72 | - public static class Comments extends TNodeBase | |
73 | - { | |
74 | - | |
75 | - public ArrayList<TagString> strings; | |
76 | - | |
77 | - } | |
78 | - | |
79 | - public static class Identifier extends TNodeBase | |
80 | - { | |
81 | - | |
82 | - public TagString string; | |
83 | - | |
84 | - } | |
85 | - | |
86 | - public static class Sign extends TNodeBase | |
87 | - { | |
88 | - | |
89 | - public TagString string; | |
90 | - | |
91 | - } | |
92 | - | |
93 | - public static class IntegerUnsigned extends TNodeBase | |
94 | - { | |
95 | - | |
96 | - public TagString string; | |
97 | - | |
98 | - public Integer value; | |
99 | - | |
100 | - public int get() | |
101 | - { | |
102 | - if (value == null) value = Integer.parseInt(string.string, 10); | |
103 | - return value; | |
104 | - } | |
105 | - | |
106 | - } | |
107 | - | |
108 | - public static class IntegerSigned extends TNodeBase | |
109 | - { | |
110 | - | |
111 | - public @Nullable Sign sign; | |
112 | - public IntegerUnsigned integer; | |
113 | - | |
114 | - public Integer value; | |
115 | - | |
116 | - public int get() | |
117 | - { | |
118 | - if (value == null) value = sign != null && sign.string.string.equals("-") ? -integer.get() : integer.get(); | |
119 | - return value; | |
120 | - } | |
121 | - | |
122 | - } | |
123 | - | |
124 | - public static class Fraction extends TNodeBase | |
125 | - { | |
126 | - | |
127 | - public TagString string; | |
128 | - | |
129 | - } | |
130 | - | |
131 | - public static class Exponent extends TNodeBase | |
132 | - { | |
133 | - | |
134 | - public IntegerSigned integer; | |
135 | - | |
136 | - } | |
137 | - | |
138 | - public static class Real extends TNodeBase | |
139 | - { | |
140 | - | |
141 | - public IntegerSigned significand; | |
142 | - public @Nullable Fraction fraction; | |
143 | - public @Nullable Exponent exponent; | |
144 | - | |
145 | - public Double value; | |
146 | - | |
147 | - public double get() | |
148 | - { | |
149 | - if (value == null) value = Double.parseDouble(String.format("%s%s%s", | |
150 | - significand.get(), | |
151 | - fraction == null ? "" : "." + fraction.string.string, | |
152 | - exponent == null ? "" : "E" + exponent.integer.get())); | |
153 | - return value; | |
154 | - } | |
155 | - | |
156 | - } | |
157 | - | |
158 | - public static class Imaginary extends TNodeBase | |
159 | - { | |
160 | - | |
161 | - public Real real; | |
162 | - | |
163 | - } | |
164 | - | |
165 | - public static class TokenIdentifier extends TNodeBase | |
166 | - { | |
167 | - | |
168 | - public Identifier node; | |
169 | - | |
170 | - } | |
171 | - | |
172 | - public static class TokenDecimal extends TNodeBase implements IExpression | |
173 | - { | |
174 | - | |
175 | - public IntegerSigned node; | |
176 | - | |
177 | - @Override | |
178 | - public boolean validate(ArgumentsValidateWS2 argumentsValidate) | |
179 | - { | |
180 | - return true; | |
181 | - } | |
182 | - | |
183 | - @Override | |
184 | - public void calculate(ArgumentsInvokeWS2 argumentsInvoke, StructureComplex complex) | |
185 | - { | |
186 | - complex.re = node.get(); | |
187 | - complex.im = 0; | |
188 | - } | |
189 | - | |
190 | - } | |
191 | - | |
192 | - public static class TokenInteger extends TNodeBase implements IExpression | |
193 | - { | |
194 | - | |
195 | - public IntegerUnsigned radix; | |
196 | - public TagString string; | |
197 | - | |
198 | - public Integer value; | |
199 | - | |
200 | - public double get() | |
201 | - { | |
202 | - if (value == null) value = Integer.parseInt(string.string, radix.get() == 0 ? 16 : radix.get()); | |
203 | - return value; | |
204 | - } | |
205 | - | |
206 | - @Override | |
207 | - public boolean validate(ArgumentsValidateWS2 argumentsValidate) | |
208 | - { | |
209 | - if (radix.get() > 36) { | |
210 | - argumentsValidate.addMessage(radix.string, "基数は0~36でなければなりません: " + radix.get()); | |
211 | - return false; | |
212 | - } | |
213 | - | |
214 | - return true; | |
215 | - } | |
216 | - | |
217 | - @Override | |
218 | - public void calculate(ArgumentsInvokeWS2 argumentsInvoke, StructureComplex complex) | |
219 | - { | |
220 | - complex.re = get(); | |
221 | - complex.im = 0; | |
222 | - } | |
223 | - | |
224 | - } | |
225 | - | |
226 | - public static class TokenReal extends TNodeBase implements IExpression | |
227 | - { | |
228 | - | |
229 | - public Real node; | |
230 | - | |
231 | - @Override | |
232 | - public boolean validate(ArgumentsValidateWS2 argumentsValidate) | |
233 | - { | |
234 | - return true; | |
235 | - } | |
236 | - | |
237 | - @Override | |
238 | - public void calculate(ArgumentsInvokeWS2 argumentsInvoke, StructureComplex complex) | |
239 | - { | |
240 | - complex.re = node.get(); | |
241 | - complex.im = 0; | |
242 | - } | |
243 | - | |
244 | - } | |
245 | - | |
246 | - public static class TokenImaginary extends TNodeBase implements IExpression | |
247 | - { | |
248 | - | |
249 | - public Imaginary node; | |
250 | - | |
251 | - @Override | |
252 | - public boolean validate(ArgumentsValidateWS2 argumentsValidate) | |
253 | - { | |
254 | - return true; | |
255 | - } | |
256 | - | |
257 | - @Override | |
258 | - public void calculate(ArgumentsInvokeWS2 argumentsInvoke, StructureComplex complex) | |
259 | - { | |
260 | - complex.re = 0; | |
261 | - complex.im = node.real.get(); | |
262 | - } | |
263 | - | |
264 | - } | |
265 | - | |
266 | - public static class Variable extends TNodeBase implements IExpression | |
267 | - { | |
268 | - | |
269 | - public TokenIdentifier token; | |
270 | - | |
271 | - public int index; | |
272 | - | |
273 | - @Override | |
274 | - public boolean validate(ArgumentsValidateWS2 argumentsValidate) | |
275 | - { | |
276 | - String name = token.node.string.string; | |
277 | - | |
278 | - Integer index2 = argumentsValidate.stackFrameRoot.getStackFrame().getVariableIndex(name); | |
279 | - if (index2 == null) { | |
280 | - argumentsValidate.addMessage(token.node.string, "未宣言の変数です: " + name); | |
281 | - return false; | |
282 | - } else { | |
283 | - index = index2; | |
284 | - } | |
285 | - | |
286 | - return true; | |
287 | - } | |
288 | - | |
289 | - @Override | |
290 | - public void calculate(ArgumentsInvokeWS2 argumentsInvoke, StructureComplex complex) | |
291 | - { | |
292 | - complex.set(argumentsInvoke.virtualMachine.stack.variables[index]); | |
293 | - } | |
294 | - | |
295 | - } | |
296 | - | |
297 | - public static class LiteralNumeric extends TNodeBase implements IExpression | |
298 | - { | |
299 | - | |
300 | - public IExpression token; | |
301 | - | |
302 | - @Override | |
303 | - public boolean validate(ArgumentsValidateWS2 argumentsValidate) | |
304 | - { | |
305 | - return token.validate(argumentsValidate); | |
306 | - } | |
307 | - | |
308 | - @Override | |
309 | - public void calculate(ArgumentsInvokeWS2 argumentsInvoke, StructureComplex complex) | |
310 | - { | |
311 | - token.calculate(argumentsInvoke, complex); | |
312 | - } | |
313 | - | |
314 | - } | |
315 | - | |
316 | - public static class Bracket extends TNodeBase implements IExpression | |
317 | - { | |
318 | - | |
319 | - public IExpression expression; | |
320 | - | |
321 | - @Override | |
322 | - public boolean validate(ArgumentsValidateWS2 argumentsValidate) | |
323 | - { | |
324 | - return expression.validate(argumentsValidate); | |
325 | - } | |
326 | - | |
327 | - @Override | |
328 | - public void calculate(ArgumentsInvokeWS2 argumentsInvoke, StructureComplex complex) | |
329 | - { | |
330 | - expression.calculate(argumentsInvoke, complex); | |
331 | - } | |
332 | - | |
333 | - } | |
334 | - | |
335 | - public static class ExpressionSingle extends TNodeBase implements IExpression | |
336 | - { | |
337 | - | |
338 | - public ArrayList<Operator> operators; | |
339 | - public IExpression expression; | |
340 | - | |
341 | - @Override | |
342 | - public boolean validate(ArgumentsValidateWS2 argumentsValidate) | |
343 | - { | |
344 | - if (!expression.validate(argumentsValidate)) return false; | |
345 | - | |
346 | - for (int i = operators.size() - 1; i >= 0; i--) { | |
347 | - String operator = operators.get(i).string.string; | |
348 | - switch (operator) { | |
349 | - case "+": | |
350 | - break; | |
351 | - case "-": | |
352 | - break; | |
353 | - case "~": | |
354 | - break; | |
355 | - default: | |
356 | - argumentsValidate.addMessage(operators.get(i).string, "未知の演算子です: " + operator); | |
357 | - return false; | |
358 | - } | |
359 | - } | |
360 | - | |
361 | - return true; | |
362 | - } | |
363 | - | |
364 | - @Override | |
365 | - public void calculate(ArgumentsInvokeWS2 argumentsInvoke, StructureComplex complex) | |
366 | - { | |
367 | - expression.calculate(argumentsInvoke, complex); | |
368 | - | |
369 | - for (int i = operators.size() - 1; i >= 0; i--) { | |
370 | - String operator = operators.get(i).string.string; | |
371 | - switch (operator) { | |
372 | - case "+": | |
373 | - break; | |
374 | - case "-": | |
375 | - complex.neg(); | |
376 | - break; | |
377 | - case "~": | |
378 | - complex.con(); | |
379 | - break; | |
380 | - default: | |
381 | - throw new RuntimeException(); | |
382 | - } | |
383 | - } | |
384 | - } | |
385 | - | |
386 | - } | |
387 | - | |
388 | - public static class Operator extends TNodeBase | |
389 | - { | |
390 | - | |
391 | - public TagString string; | |
392 | - | |
393 | - } | |
394 | - | |
395 | - public static class Operations extends TNodeBase implements IExpression | |
396 | - { | |
397 | - | |
398 | - public Operation operations; | |
399 | - public boolean isRight; | |
400 | - public int indexRegister; | |
401 | - | |
402 | - public Operations() | |
403 | - { | |
404 | - this(false); | |
405 | - } | |
406 | - | |
407 | - public Operations(boolean isRight) | |
408 | - { | |
409 | - this.isRight = isRight; | |
410 | - } | |
411 | - | |
412 | - @Override | |
413 | - public boolean validate(ArgumentsValidateWS2 argumentsValidate) | |
414 | - { | |
415 | - if (isRight) { | |
416 | - if (!((IExpression) operations.operands.get(operations.operators.size())).validate(argumentsValidate)) { | |
417 | - return false; | |
418 | - } | |
419 | - | |
420 | - for (int i = operations.operators.size() - 1; i >= 0; i--) { | |
421 | - | |
422 | - IExpression operand = (IExpression) operations.operands.get(i); | |
423 | - if (!operand.validate(argumentsValidate)) { | |
424 | - return false; | |
425 | - } | |
426 | - | |
427 | - Operator operator = (Operator) operations.operators.get(i); | |
428 | - if (!validateOperator(argumentsValidate, operator)) { | |
429 | - return false; | |
430 | - } | |
431 | - } | |
432 | - | |
433 | - } else { | |
434 | - if (!((IExpression) operations.operands.get(0)).validate(argumentsValidate)) { | |
435 | - return false; | |
436 | - } | |
437 | - | |
438 | - for (int i = 0; i < operations.operators.size(); i++) { | |
439 | - | |
440 | - IExpression operand = (IExpression) operations.operands.get(i + 1); | |
441 | - if (!operand.validate(argumentsValidate)) { | |
442 | - return false; | |
443 | - } | |
444 | - | |
445 | - Operator operator = (Operator) operations.operators.get(i); | |
446 | - if (!validateOperator(argumentsValidate, operator)) { | |
447 | - return false; | |
448 | - } | |
449 | - } | |
450 | - | |
451 | - } | |
452 | - | |
453 | - // define register | |
454 | - indexRegister = argumentsValidate.registerFrameRoot.getRegisterFrame().defineRegister(); | |
455 | - | |
456 | - return true; | |
457 | - } | |
458 | - | |
459 | - @Override | |
460 | - public void calculate(ArgumentsInvokeWS2 argumentsInvoke, StructureComplex complex) | |
461 | - { | |
462 | - if (isRight) { | |
463 | - ((IExpression) operations.operands.get(operations.operators.size())).calculate(argumentsInvoke, complex); | |
464 | - | |
465 | - StructureComplex register = argumentsInvoke.virtualMachine.register.registers[indexRegister]; | |
466 | - for (int i = operations.operators.size() - 1; i >= 0; i--) { | |
467 | - | |
468 | - IExpression operand = (IExpression) operations.operands.get(i); | |
469 | - operand.calculate(argumentsInvoke, register); | |
470 | - | |
471 | - Operator operator = (Operator) operations.operators.get(i); | |
472 | - operate(operator, register, complex); | |
473 | - } | |
474 | - | |
475 | - } else { | |
476 | - ((IExpression) operations.operands.get(0)).calculate(argumentsInvoke, complex); | |
477 | - | |
478 | - StructureComplex register = argumentsInvoke.virtualMachine.register.registers[indexRegister]; | |
479 | - for (int i = 0; i < operations.operators.size(); i++) { | |
480 | - | |
481 | - IExpression operand = (IExpression) operations.operands.get(i + 1); | |
482 | - operand.calculate(argumentsInvoke, register); | |
483 | - | |
484 | - Operator operator = (Operator) operations.operators.get(i); | |
485 | - operate(operator, complex, register); | |
486 | - } | |
487 | - | |
488 | - } | |
489 | - } | |
490 | - | |
491 | - private boolean validateOperator(ArgumentsValidateWS2 argumentsValidate, Operator operator) | |
492 | - { | |
493 | - switch (operator.string.string) { | |
494 | - case "^": | |
495 | - break; | |
496 | - case "*": | |
497 | - break; | |
498 | - case "/": | |
499 | - break; | |
500 | - case "+": | |
501 | - break; | |
502 | - case "-": | |
503 | - break; | |
504 | - default: | |
505 | - argumentsValidate.addMessage(operator.string, "未知の演算子です: " + operator); | |
506 | - return false; | |
507 | - } | |
508 | - | |
509 | - return true; | |
510 | - } | |
511 | - | |
512 | - private void operate(Operator operator, StructureComplex left, StructureComplex right) | |
513 | - { | |
514 | - | |
515 | - switch (operator.string.string) { | |
516 | - case "^": | |
517 | - Exponential.exp(right, left); | |
518 | - break; | |
519 | - case "*": | |
520 | - left.mul(right); | |
521 | - break; | |
522 | - case "/": | |
523 | - left.div(right); | |
524 | - break; | |
525 | - case "+": | |
526 | - left.add(right); | |
527 | - break; | |
528 | - case "-": | |
529 | - left.sub(right); | |
530 | - break; | |
531 | - default: | |
532 | - throw new RuntimeException(); | |
533 | - } | |
534 | - } | |
535 | - | |
536 | - } | |
537 | - | |
538 | - public static class OperationsRight extends Operations | |
539 | - { | |
540 | - | |
541 | - public OperationsRight() | |
542 | - { | |
543 | - super(true); | |
544 | - } | |
545 | - | |
546 | - } | |
547 | - | |
548 | - public static interface IExpression | |
549 | - { | |
550 | - | |
551 | - public boolean validate(ArgumentsValidateWS2 argumentsValidate); | |
552 | - | |
553 | - public void calculate(ArgumentsInvokeWS2 argumentsInvoke, StructureComplex complex); | |
554 | - | |
555 | - } | |
556 | - | |
557 | - public static abstract class RoutineAssignmentBase extends TNodeBase implements IRoutine | |
558 | - { | |
559 | - | |
560 | - public int indexVariable; | |
561 | - public int indexRegister; | |
562 | - public IExpression expression; | |
563 | - | |
564 | - @Override | |
565 | - public boolean validate(ArgumentsValidateWS2 argumentsValidate) | |
566 | - { | |
567 | - String name = getNameVariable(); | |
568 | - | |
569 | - Integer indexVariable2 = argumentsValidate.stackFrameRoot.getStackFrame().getVariableIndex(name); | |
570 | - if (indexVariable2 == null) { | |
571 | - argumentsValidate.addMessage(getToken(), "未宣言の変数です: " + name); | |
572 | - return false; | |
573 | - } else { | |
574 | - indexVariable = indexVariable2; | |
575 | - } | |
576 | - | |
577 | - if (!expression.validate(argumentsValidate)) return false; | |
578 | - | |
579 | - // define register | |
580 | - indexRegister = argumentsValidate.registerFrameRoot.getRegisterFrame().defineRegister(); | |
581 | - | |
582 | - return true; | |
583 | - } | |
584 | - | |
585 | - @Override | |
586 | - public void invoke(ArgumentsInvokeWS2 argumentsInvoke) | |
587 | - { | |
588 | - StructureComplex register = argumentsInvoke.virtualMachine.register.registers[indexRegister]; | |
589 | - expression.calculate(argumentsInvoke, register); | |
590 | - argumentsInvoke.virtualMachine.stack.variables[indexVariable].set(register); | |
591 | - } | |
592 | - | |
593 | - protected abstract String getNameVariable(); | |
594 | - | |
595 | - protected abstract TagString getToken(); | |
596 | - | |
597 | - } | |
598 | - | |
599 | - public static class RoutineExpression extends RoutineAssignmentBase | |
600 | - { | |
601 | - | |
602 | - // TODO ";"にあっているのをなんとかする | |
603 | - public TagString token; | |
604 | - | |
605 | - @Override | |
606 | - protected String getNameVariable() | |
607 | - { | |
608 | - return "_"; | |
609 | - } | |
610 | - | |
611 | - @Override | |
612 | - protected TagString getToken() | |
613 | - { | |
614 | - return token; | |
615 | - } | |
616 | - | |
617 | - } | |
618 | - | |
619 | - public static class RoutineAssignment extends RoutineAssignmentBase | |
620 | - { | |
621 | - | |
622 | - public TokenIdentifier identifier; | |
623 | - | |
624 | - @Override | |
625 | - protected String getNameVariable() | |
626 | - { | |
627 | - return identifier.node.string.string; | |
628 | - } | |
629 | - | |
630 | - @Override | |
631 | - protected TagString getToken() | |
632 | - { | |
633 | - return identifier.node.string; | |
634 | - } | |
635 | - | |
636 | - } | |
637 | - | |
638 | - public static class RoutineDefinitionVariable extends TNodeBase implements IRoutine | |
639 | - { | |
640 | - | |
641 | - public TokenIdentifier identifier; | |
642 | - public int index; | |
643 | - | |
644 | - @Override | |
645 | - public boolean validate(ArgumentsValidateWS2 argumentsValidate) | |
646 | - { | |
647 | - String name = identifier.node.string.string; | |
648 | - | |
649 | - Integer index2 = argumentsValidate.stackFrameRoot.getStackFrame().getVariableIndex(name); | |
650 | - if (index2 != null) { | |
651 | - argumentsValidate.addMessage(identifier.node.string, "重複する変数名です: " + name); | |
652 | - return false; | |
653 | - } | |
654 | - | |
655 | - index = argumentsValidate.stackFrameRoot.getStackFrame().defineVariable(name); | |
656 | - | |
657 | - return true; | |
658 | - } | |
659 | - | |
660 | - @Override | |
661 | - public void invoke(ArgumentsInvokeWS2 argumentsInvoke) | |
662 | - { | |
663 | - // nothing to do | |
664 | - } | |
665 | - | |
666 | - } | |
667 | - | |
668 | - public static class RoutineDefinitionAndAssignmentVariable extends RoutineAssignmentBase | |
669 | - { | |
670 | - | |
671 | - public TokenIdentifier identifier; | |
672 | - | |
673 | - @Override | |
674 | - protected String getNameVariable() | |
675 | - { | |
676 | - return identifier.node.string.string; | |
677 | - } | |
678 | - | |
679 | - @Override | |
680 | - protected TagString getToken() | |
681 | - { | |
682 | - return identifier.node.string; | |
683 | - } | |
684 | - | |
685 | - @Override | |
686 | - public boolean validate(ArgumentsValidateWS2 argumentsValidate) | |
687 | - { | |
688 | - String name = getNameVariable(); | |
689 | - | |
690 | - Integer indexVariable2 = argumentsValidate.stackFrameRoot.getStackFrame().getVariableIndex(name); | |
691 | - if (indexVariable2 != null) { | |
692 | - argumentsValidate.addMessage(identifier.node.string, "重複する変数名です: " + name); | |
693 | - return false; | |
694 | - } | |
695 | - | |
696 | - indexVariable = argumentsValidate.stackFrameRoot.getStackFrame().defineVariable(name); | |
697 | - | |
698 | - if (!expression.validate(argumentsValidate)) return false; | |
699 | - | |
700 | - // define register | |
701 | - indexRegister = argumentsValidate.registerFrameRoot.getRegisterFrame().defineRegister(); | |
702 | - | |
703 | - return true; | |
704 | - } | |
705 | - | |
706 | - @Override | |
707 | - public void invoke(ArgumentsInvokeWS2 argumentsInvoke) | |
708 | - { | |
709 | - StructureComplex register = argumentsInvoke.virtualMachine.register.registers[indexRegister]; | |
710 | - expression.calculate(argumentsInvoke, register); | |
711 | - argumentsInvoke.virtualMachine.stack.variables[indexVariable].set(register); | |
712 | - } | |
713 | - | |
714 | - } | |
715 | - | |
716 | - public static class Routines extends TNodeBase implements IRoutine | |
717 | - { | |
718 | - | |
719 | - public ArrayList<IRoutine> routines; | |
720 | - | |
721 | - @Override | |
722 | - public boolean validate(ArgumentsValidateWS2 argumentsValidate) | |
723 | - { | |
724 | - for (IRoutine routine : routines) { | |
725 | - if (!routine.validate(argumentsValidate)) return false; | |
726 | - } | |
727 | - return true; | |
728 | - } | |
729 | - | |
730 | - @Override | |
731 | - public void invoke(ArgumentsInvokeWS2 argumentsInvoke) | |
732 | - { | |
733 | - for (IRoutine routine : routines) { | |
734 | - routine.invoke(argumentsInvoke); | |
735 | - } | |
736 | - } | |
737 | - | |
738 | - } | |
739 | - | |
740 | - public static class ExpressionRoutined extends TNodeBase | |
741 | - { | |
742 | - // TODO | |
743 | - } | |
744 | - | |
745 | -} |
@@ -93,10 +93,10 @@ | ||
93 | 93 | { |
94 | 94 | |
95 | 95 | // 構文解析 |
96 | - ResponseCompileWS2 resultCompile = WulfeniteScript2.compile(source); | |
96 | + ResponseCompile resultCompile = HWulfeniteScript2.compile(source); | |
97 | 97 | |
98 | 98 | // Validate |
99 | - ArgumentsValidateWS2 argumentsValidate = new ArgumentsValidateWS2(resultCompile); | |
99 | + ArgumentsValidate argumentsValidate = new ArgumentsValidate(resultCompile); | |
100 | 100 | argumentsValidate.stackFrameRoot.getStackFrame().defineVariable("_"); |
101 | 101 | assertFalse(resultCompile.response.node.validate(argumentsValidate)); |
102 | 102 |
@@ -106,15 +106,15 @@ | ||
106 | 106 | { |
107 | 107 | |
108 | 108 | // 構文解析 |
109 | - ResponseCompileWS2 resultCompile = WulfeniteScript2.compile(source); | |
109 | + ResponseCompile resultCompile = HWulfeniteScript2.compile(source); | |
110 | 110 | |
111 | 111 | // Validate |
112 | - ArgumentsValidateWS2 argumentsValidate = new ArgumentsValidateWS2(resultCompile); | |
112 | + ArgumentsValidate argumentsValidate = new ArgumentsValidate(resultCompile); | |
113 | 113 | int indexVariable = argumentsValidate.stackFrameRoot.getStackFrame().defineVariable("_"); |
114 | 114 | assertTrue(resultCompile.response.node.validate(argumentsValidate)); |
115 | 115 | |
116 | 116 | // Invoke |
117 | - ArgumentsInvokeWS2 argumentsInvoke = new ArgumentsInvokeWS2(argumentsValidate); | |
117 | + ArgumentsInvoke argumentsInvoke = new ArgumentsInvoke(argumentsValidate); | |
118 | 118 | argumentsInvoke.virtualMachine.stack.variables[indexVariable].set(re1, im1); |
119 | 119 | resultCompile.response.node.invoke(argumentsInvoke); |
120 | 120 |