| summaryrefslogtreecommitdiff |
diff options
| author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2022-01-30 16:21:41 +0100 |
|---|---|---|
| committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2022-01-30 16:21:41 +0100 |
| commit | 3db983ddc34ff516740d6e5e2c359c8779ee999c (patch) | |
| tree | ea1426992ca9ec1d24e71122ab7bad175372ad69 /src/json-export | |
| parent | b748936e7ec1e39b664b6933c66912e77d570f99 (diff) | |
Adds text constant optimization, fixes spacing.
Diffstat (limited to 'src/json-export')
3 files changed, 30 insertions, 41 deletions
diff --git a/src/json-export/src/tonkadur/jsonexport/ComputationCompiler.java b/src/json-export/src/tonkadur/jsonexport/ComputationCompiler.java index e9146d7..598bc2e 100644 --- a/src/json-export/src/tonkadur/jsonexport/ComputationCompiler.java +++ b/src/json-export/src/tonkadur/jsonexport/ComputationCompiler.java @@ -62,8 +62,16 @@ public class ComputationCompiler implements ComputationVisitor result = new JSONObject(); result.put("category", "cast"); - result.put("from", n.get_parent().get_type().get_name()); - result.put("to", n.get_type().get_name()); + result.put + ( + "from", + Translator.get_compiled_type_name(n.get_parent().get_type()) + ); + result.put + ( + "to", + Translator.get_compiled_type_name(n.get_type()) + ); result.put("value", cc.get_result()); } @@ -73,7 +81,7 @@ public class ComputationCompiler implements ComputationVisitor result = new JSONObject(); result.put("category", "constant"); - result.put("type", n.get_type().get_name()); + result.put("type", Translator.get_compiled_type_name(n.get_type())); result.put("value", n.get_as_string()); } @@ -93,7 +101,7 @@ public class ComputationCompiler implements ComputationVisitor result = new JSONObject(); result.put("category", "if_else"); - result.put("type", n.get_type().get_name()); + result.put("type", Translator.get_compiled_type_name(n.get_type())); result.put("condition", cond_cc.get_result()); result.put("if_true", if_true_cc.get_result()); result.put("if_false", if_false_cc.get_result()); @@ -105,7 +113,11 @@ public class ComputationCompiler implements ComputationVisitor result = new JSONObject(); result.put("category", "get_allocable_address"); - result.put("type", n.get_target_type().get_name()); + result.put + ( + "type", + Translator.get_compiled_type_name(n.get_target_type()) + ); } public void visit_newline (final Newline n) @@ -137,7 +149,7 @@ public class ComputationCompiler implements ComputationVisitor result.put("category", "operation"); result.put("operator", n.get_operator()); - result.put("type", n.get_type().get_name()); + result.put("type", Translator.get_compiled_type_name(n.get_type())); result.put("x", cc.get_result()); if (n.get_second_parameter() != null) @@ -162,7 +174,7 @@ public class ComputationCompiler implements ComputationVisitor result = new JSONObject(); result.put("category", "address"); - result.put("type", n.get_type().get_name()); + result.put("type", Translator.get_compiled_type_name(n.get_type())); result.put("value_or_target", cc.get_result()); } @@ -180,7 +192,7 @@ public class ComputationCompiler implements ComputationVisitor result = new JSONObject(); result.put("category", "relative_address"); - result.put("type", n.get_type().get_name()); + result.put("type", Translator.get_compiled_type_name(n.get_type())); result.put("target", cc.get_result()); result.put("extra", param_cc.get_result()); } @@ -221,7 +233,7 @@ public class ComputationCompiler implements ComputationVisitor result = new JSONObject(); result.put("category", "size"); - result.put("value", cc.get_result()); + result.put("target", cc.get_result()); } public void visit_extra_computation (final ExtraComputation n) @@ -261,7 +273,7 @@ public class ComputationCompiler implements ComputationVisitor result = new JSONObject(); result.put("category", "value_of"); - result.put("type", n.get_type().get_name()); + result.put("type", Translator.get_compiled_type_name(n.get_type())); result.put("target", cc.get_result()); } diff --git a/src/json-export/src/tonkadur/jsonexport/InstructionCompiler.java b/src/json-export/src/tonkadur/jsonexport/InstructionCompiler.java index 39a07af..95f9332 100644 --- a/src/json-export/src/tonkadur/jsonexport/InstructionCompiler.java +++ b/src/json-export/src/tonkadur/jsonexport/InstructionCompiler.java @@ -208,7 +208,7 @@ public class InstructionCompiler implements InstructionVisitor result.put("category", "initialize"); result.put("target", ref_cc.get_result()); - result.put("type", Translator.compile_type(n.get_type())); + result.put("type", Translator.get_compiled_type_name(n.get_type())); } public void visit_prompt_command (final PromptCommand n) diff --git a/src/json-export/src/tonkadur/jsonexport/Translator.java b/src/json-export/src/tonkadur/jsonexport/Translator.java index 6d7f60e..69c503f 100644 --- a/src/json-export/src/tonkadur/jsonexport/Translator.java +++ b/src/json-export/src/tonkadur/jsonexport/Translator.java @@ -55,7 +55,7 @@ public class Translator obj = new JSONObject(); obj.put("name", e.get_name()); - obj.put("type", compile_type(e.get_type())); + obj.put("type",get_compiled_type_name(e.get_type())); result.add(obj); } @@ -129,7 +129,7 @@ public class Translator f = new JSONObject(); f.put("name", field.getKey()); - f.put("type", compile_type(field.getValue())); + f.put("type",get_compiled_type_name(field.getValue())); fields.add(f); } @@ -166,40 +166,17 @@ public class Translator return result; } - public static JSONObject compile_type (final Type t) + public static String get_compiled_type_name (final Type t) { - final JSONObject result; - - result = new JSONObject(); - - if (t instanceof DictType) + if (t instanceof PointerType) { - result.put("category", "structure"); - result.put("name", t.get_name()); - } - else if (t instanceof PointerType) - { - result.put("category", "pointer"); - result.put - ( - "target", - compile_type(((PointerType) t).get_target_type()) - ); + return "ptr"; } else if (t instanceof MapType) { - result.put("category", "list"); - result.put - ( - "member_type", - compile_type(((MapType) t).get_member_type()) - ); - } - else - { - result.put("category", t.get_name()); + return "list"; } - return result; + return t.get_name(); } } |


