Example #1
0
def get_return_type_index_from_func_node_label(label):
    return_node_index = None
    if label == AST_PUBLIC_FUNCTION:
        return_node_index = 1
    elif label == AST_PRIVATE_FUNCTION:
        return_node_index = 1
    #### DEBUG
    else:
        emit_utils.emit_assert("Unknown label getting return type for.")
    #### END DEBUG

    return return_node_index
Example #2
0
def get_arg_index_from_func_node_label(label):
    arg_node_index = None
    if label == AST_PUBLIC_FUNCTION:
        arg_node_index = 2
    elif label == AST_PRIVATE_FUNCTION:
        arg_node_index = 2
    elif label == AST_ONCREATE_FUNCTION:
        arg_node_index = 1
    elif label == AST_MESSAGE_SEND_SEQUENCE_FUNCTION:
        arg_node_index = 2
    #### DEBUG
    else:
        emit_utils.emit_assert("Unrecognized label passed to " + "get_arg_index_from_func_node_label.")
    #### END DEBUG
    return arg_node_index
Example #3
0
def get_endpoint_section_node(endpoint_name, ast_root):
    end1_sec_node = ast_root.children[4]
    end2_sec_node = ast_root.children[5]

    end1_name_node = end1_sec_node.children[0]
    end1_name = end1_name_node.value

    if end1_name == endpoint_name:
        return end1_sec_node

    #### DEBUG
    end2_name_node = end2_sec_node.children[0]
    end2_name = end2_name_node.value
    if end2_name != endpoint_name:
        emit_utils.emit_assert("Cannot find endpoint named " + endpoint_name)
    #### END DEBUG

    return end2_sec_node
Example #4
0
def convert_args_helper (func_decl_arglist_node,sequence_local,is_endpoint_call):
    '''
    @see convert_args_to_waldo
    '''
    converted_args_string = ''
    
    for func_decl_arg_node in func_decl_arglist_node.children:
        arg_name_node = func_decl_arg_node.children[1]
        var_type_dict = func_decl_arg_node.children[0].type
        # the name of the argument as it appears in the Waldo source
        # text
        arg_name = arg_name_node.value
        # the unique, name of the argument, annotated by the slice-ing
        # code.
        arg_unique_name = arg_name_node.sliceAnnotationName

        
        if not sequence_local:
            force_copy = 'True'
            
            if TypeCheck.templateUtil.is_external(func_decl_arg_node.type):
                force_copy = 'False'
            
            if ((not is_endpoint_call) and
                emit_utils.is_reference_type(func_decl_arg_node)):
                # we force copy maps, lists, and user structs only if
                # it's an endpoint call and they're not external.  
                force_copy = 'False'

            if TypeCheck.templateUtil.is_basic_function_type(func_decl_arg_node.type):
                # functions copied in must have their external args
                # arrays set.  these should be passed into the context
                # method that transforms a function into a waldo variable.
                ext_args_array_txt = emit_statement.emit_external_args_list_from_func_obj_type_dict(
                    func_decl_arg_node.type)

                converted_args_string += (
                    arg_name + ' = ' +
                    '_context.func_turn_into_waldo_var(' + arg_name +
                    ',%s,_active_event,self._host_uuid,False,%s)\n' % (force_copy,ext_args_array_txt))
            else:
                converted_args_string += (
                    arg_name + ' = ' +
                    '_context.turn_into_waldo_var_if_was_var(' + arg_name +
                    ',%s,_active_event,self._host_uuid,False)\n' % force_copy)

        else:

            if arg_unique_name == None:
                emit_utils.emit_assert(
                    'When converting sequence local args, arg name has no ' +
                    'unique name.')

            # FIXME: assume that there's a mechanism preventing
            # copying functions in user structs.  Longer-term answer
            # may be to remove function fields from user structs???
            # Rely on endpoint calls for foreign functions???
                
            # returns a peered version of passed in data
            convert_call_txt = (
                '_context.convert_for_seq_local(' + arg_name + ',' +
                '_active_event,self._host_uuid)\n' )

            # actually adds the created peered variable above to the
            # variable store.
            converted_args_string +='''
_context.sequence_local_store.add_var(
    "%s", %s)
''' % ( arg_unique_name , convert_call_txt)

    return converted_args_string