Revision | ba535a962764a34bf6ae85fef94f349166155a07 (tree) |
---|---|
Time | 2015-10-22 18:27:28 |
Author | MirrgieRiana |
Commiter | MirrgieRiana |
ArgumentsGetComplex: add: setVariable
@@ -1,6 +1,7 @@ | ||
1 | 1 | package mirrg.compile.lithiumbromide; |
2 | 2 | |
3 | 3 | import java.util.ArrayList; |
4 | +import java.util.Hashtable; | |
4 | 5 | |
5 | 6 | import mirrg.complex.hydrogen.StructureComplex; |
6 | 7 | import mirrg.complex.hydrogen.functions.Trigonometry; |
@@ -8,14 +9,28 @@ | ||
8 | 9 | public class ArgumentsGetComplex |
9 | 10 | { |
10 | 11 | |
12 | + public Hashtable<String, StructureComplex> variables = new Hashtable<>(); | |
13 | + | |
14 | + { | |
15 | + variables.put("pi", new StructureComplex(Math.PI, 0)); | |
16 | + } | |
17 | + | |
18 | + /** | |
19 | + * @param complex | |
20 | + * 破壊される可能性はない | |
21 | + */ | |
22 | + public void setVariable(String name, StructureComplex complex) | |
23 | + { | |
24 | + variables.put(name, complex.copy()); | |
25 | + } | |
26 | + | |
27 | + /** | |
28 | + * @return 破壊可能 | |
29 | + */ | |
11 | 30 | public StructureComplex getVariable(String name) |
12 | 31 | { |
13 | - switch (name) { | |
14 | - case "pi": | |
15 | - return new StructureComplex(Math.PI, 0); | |
16 | - default: | |
17 | - return null; | |
18 | - } | |
32 | + StructureComplex complex = variables.get(name); | |
33 | + return complex == null ? null : complex.copy(); | |
19 | 34 | } |
20 | 35 | |
21 | 36 | public StructureComplex callFunction(String name, ArrayList<INodeExpressionBase> arguments) |