예제 #1
0
    def string_length(self):
        self.arguments.append(cil.CILArgNode(self.self_vinfo))

        ret_vinfo = self.define_internal_local()

        self.register_instruction(cil.CILLengthNode, ret_vinfo, self.self_vinfo)
        self.register_instruction(cil.CILReturnNode, ret_vinfo)
예제 #2
0
    def string_concat(self):
        self.arguments.append(cil.CILArgNode(self.self_vinfo))
        other_arg = VariableInfo("other_arg")
        self.register_argument(other_arg)

        ret_vinfo = self.define_internal_local()

        self.register_instruction(cil.CILConcatNode, ret_vinfo, self.self_vinfo, other_arg)
        self.register_instruction(cil.CILReturnNode, ret_vinfo)
예제 #3
0
    def string_substr(self):
        self.arguments.append(cil.CILArgNode(self.self_vinfo))
        idx_arg = VariableInfo("idx_arg")
        self.register_argument(idx_arg)
        length_arg = VariableInfo("length_arg")
        self.register_argument(length_arg)

        ret_vinfo = self.define_internal_local()

        self.register_instruction(cil.CILSubstringNode, ret_vinfo, self.self_vinfo, idx_arg, length_arg)
        self.register_instruction(cil.CILReturnNode, ret_vinfo)
예제 #4
0
    def visit(self, node, ret_vinfo = None):
        self.internal_count = 0
        self.localvars = []
        self.local_pointer = 0
        self.arguments = []
        self.instructions = []

        function_minfo = self.environment.get_method_info(node.method_name, self.current_class.class_name)
        function_minfo.method_name = self.build_internal_mname(function_minfo.method_name)
        self.current_function = function_minfo

        self.arguments.append(cil.CILArgNode(self.self_vinfo))
        for arg in node.signature_vinfos:
            self.register_argument(arg)

        ret_vinfo = self.define_internal_local()
        self.visit(node.body_expr, ret_vinfo)

        self.register_instruction(cil.CILReturnNode, ret_vinfo)
        self.dotcode.append(cil.CILFunctionNode(function_minfo, self.arguments, self.localvars, self.instructions))

        return function_minfo
예제 #5
0
 def io_inint(self):
     self.arguments.append(cil.CILArgNode(self.self_vinfo))
     ret_vinfo = self.define_internal_local()
     self.register_instruction(cil.CILReadIntNode, ret_vinfo)
     self.register_instruction(cil.CILReturnNode, ret_vinfo)
예제 #6
0
 def io_outint(self):
     self.arguments.append(cil.CILArgNode(self.self_vinfo))
     int_arg = VariableInfo("int")
     self.register_argument(int_arg)
     self.register_instruction(cil.CILPrintIntNode, int_arg)
     self.register_instruction(cil.CILReturnNode, self.self_vinfo)
예제 #7
0
 def io_outstring(self):
     self.arguments.append(cil.CILArgNode(self.self_vinfo))
     str_arg = VariableInfo("str")
     self.register_argument(str_arg)
     self.register_instruction(cil.CILPrintStringNode, str_arg)
     self.register_instruction(cil.CILReturnNode, self.self_vinfo)
예제 #8
0
 def object_type_name(self):
     self.arguments.append(cil.CILArgNode(self.self_vinfo))
     ret_vinfo = self.define_internal_local()
     self.register_instruction(cil.CILTypeNameNode, ret_vinfo, self.self_vinfo)
     self.register_instruction(cil.CILReturnNode, ret_vinfo)
예제 #9
0
 def register_argument(self, vinfo):
     vinfo.var_name = self.build_internal_vname(vinfo.var_name)
     arg_node = cil.CILArgNode(vinfo)
     self.arguments.append(arg_node)
     return vinfo