|
@@ -493,8 +493,46 @@ class SemanticsVisitor(Visitor):
|
|
|
|
|
|
def visit_rvalue(self, tree):
|
|
|
if len(tree.get_tail()) > 1:
|
|
|
- # Complex
|
|
|
- raise Exception("TODO")
|
|
|
+ # Complex: dict_read operation needed
|
|
|
+ child = tree.get_tail()[0]
|
|
|
+ node = tree.get_child("rvalue")
|
|
|
+ expression = tree.get_child("expression")
|
|
|
+ operation = "dict_read"
|
|
|
+ call_tree = SemanticsVisitor.func_call(operation, [node, expression])
|
|
|
+ self.visit(call_tree)
|
|
|
+ tree.replace_child(child, call_tree)
|
|
|
+ self.set_type(tree, self.get_type(node))
|
|
|
+ """
|
|
|
+ child = tree.get_tail()[0]
|
|
|
+ if len(child.get_tail()) > 1:
|
|
|
+ l, op, r = child.get_tail()
|
|
|
+ l_type, r_type = self.get_type(l), self.get_type(r)
|
|
|
+ if type(l_type) != type(r_type):
|
|
|
+ print("Error: " + str(l_type) + " <-> " + str(r_type))
|
|
|
+ raise RuntimeError(
|
|
|
+ "{}:{}:{}: error: children were not casted".format(
|
|
|
+ self.inputfiles[0],
|
|
|
+ tree.startpos['line'],
|
|
|
+ tree.startpos['column']
|
|
|
+ ))
|
|
|
+ call_name = SemanticsVisitor.call_name_binary(l_type, op)
|
|
|
+ call_tree = SemanticsVisitor.func_call(call_name, [l, r])
|
|
|
+ try:
|
|
|
+ self.visit(call_tree)
|
|
|
+ except RuntimeError:
|
|
|
+ call_signature = "{0} function {1}({2}, {2})".format(
|
|
|
+ str(types_mv.Boolean()), call_name, l_type)
|
|
|
+ raise RuntimeError(
|
|
|
+ "{}:{}:{}: error: cannot perform {}: function '{}' is "
|
|
|
+ "not found".format(
|
|
|
+ self.inputfiles[0],
|
|
|
+ tree.startpos['line'],
|
|
|
+ tree.startpos['column'],
|
|
|
+ child.head,
|
|
|
+ call_signature))
|
|
|
+ tree.replace_child(child, call_tree)
|
|
|
+ self.set_type(tree, self.get_type(tree.get_tail()[i]))
|
|
|
+ """
|
|
|
else:
|
|
|
# Simple
|
|
|
self.visit_id(tree)
|