Commit dc327d30 authored by johnvg@science.ru.nl's avatar johnvg@science.ru.nl

use function is_using_desc_relative_to_array in module...

use function is_using_desc_relative_to_array in module graph_to_string_and_descriptors, add the address of __ARRAY__ to descriptors if it yields 1 (to fix the descriptors for position independent code)
parent e3d33c31
......@@ -25,6 +25,19 @@ desc_arity_offset = code inline {
get_desc_arity_offset
}
get_array_D :: !{#Int} -> Int;
get_array_D a = code {
pushD_a 0
pop_a 1
}
// The c function is_using_desc_relative_to_array is defined in copy_graph_to_string.c
// the function returns 1 if positions are relative to _ARRAY_ and 0 when not.
is_using_desc_relative_to_array :: Int;
is_using_desc_relative_to_array = code {
ccall is_using_desc_relative_to_array ":I"
}
get_D_from_string s i :== IF_INT_64_OR_32 (get_D_from_string_64 s i) (get_D_from_string_32 s i);
get_D_from_string_32 :: !{#Char} !Int -> Int;
......@@ -210,8 +223,8 @@ get_module_name :: !Int -> {#Char};
get_module_name m
= {get_module_name_char m i\\i<-[0..get_module_name_size m-1]};
get_n_non_pointers_and_array_elem_desc :: !Int !a !Int -> (!Int,!Int);
get_n_non_pointers_and_array_elem_desc d v offset
get_n_non_pointers_and_array_elem_desc :: !Int !a !Int !Int -> (!Int,!Int);
get_n_non_pointers_and_array_elem_desc d v offset array_desc
# arity = get_D_node_arity d;
| arity==0
| is_Int_D d || is_Char_D d || is_Bool_D d
......@@ -222,6 +235,7 @@ get_n_non_pointers_and_array_elem_desc d v offset
# ed=get_array_elem_D v offset;
| ed==0
= (2,ed);
# ed=ed+array_desc;
| is_Int_D ed
= (2+get_array_size v offset,ed);
| is_Real_D ed
......@@ -313,22 +327,23 @@ count_unboxed_records_in_record desc
= count_unboxed_records_in_record desc (i+1) (n_unboxed_records+1);
}
replace_descs_by_desc_numbers_and_build_desc_tree :: !Int !*{#Char} !Int !DescOrModTree -> (!*{#Char},!Int,!DescOrModTree);
replace_descs_by_desc_numbers_and_build_desc_tree i s n_descs desc_tree
replace_descs_by_desc_numbers_and_build_desc_tree :: !Int !*{#Char} !Int !Int !DescOrModTree -> (!*{#Char},!Int,!DescOrModTree);
replace_descs_by_desc_numbers_and_build_desc_tree i s n_descs array_desc desc_tree
| i>=size s
= (s,n_descs,desc_tree);
#! desc=get_D_from_string s i;
#! desc=desc+array_desc;
| desc bitand 1<>0
= replace_descs_by_desc_numbers_and_build_desc_tree (i+IF_INT_64_OR_32 8 4) s n_descs desc_tree;
= replace_descs_by_desc_numbers_and_build_desc_tree (i+IF_INT_64_OR_32 8 4) s n_descs array_desc desc_tree;
| desc bitand 2==0
= abort ("unevaluated node in replace_descs_by_desc_numbers_and_build_desc_tree "+++toString desc);
#! a=cast_string_to_a s;
# (d,array_elem_desc) = get_n_non_pointers_and_array_elem_desc desc a (i+IF_INT_64_OR_32 16 8);
# (d,array_elem_desc) = get_n_non_pointers_and_array_elem_desc desc a (i+IF_INT_64_OR_32 16 8) array_desc;
# (s,n_descs,desc_tree) = store_desc_n_and_add_desc desc i s n_descs desc_tree;
| array_elem_desc==0
= replace_descs_by_desc_numbers_and_build_desc_tree (i+IF_INT_64_OR_32 8 4+(d<<(IF_INT_64_OR_32 3 2))) s n_descs desc_tree;
= replace_descs_by_desc_numbers_and_build_desc_tree (i+IF_INT_64_OR_32 8 4+(d<<(IF_INT_64_OR_32 3 2))) s n_descs array_desc desc_tree;
# (s,n_descs,desc_tree) = store_desc_n_and_add_desc array_elem_desc (i+IF_INT_64_OR_32 16 8) s n_descs desc_tree;
= replace_descs_by_desc_numbers_and_build_desc_tree (i+IF_INT_64_OR_32 8 4+(d<<(IF_INT_64_OR_32 3 2))) s n_descs desc_tree;
= replace_descs_by_desc_numbers_and_build_desc_tree (i+IF_INT_64_OR_32 8 4+(d<<(IF_INT_64_OR_32 3 2))) s n_descs array_desc desc_tree;
{}{
store_desc_n_and_add_desc :: Int Int !*{#Char} !Int !DescOrModTree -> (!*{#Char},!Int,!DescOrModTree);
store_desc_n_and_add_desc desc i s n_descs desc_tree
......@@ -508,7 +523,8 @@ graph_to_string_with_descriptor_and_module_table :: !a -> (!{#Char},!{#{#Char}},
graph_to_string_with_descriptor_and_module_table g
# g = eval_all_nodes g;
# s = copy_to_string g;
# (s,n_descs,desc_tree) = replace_descs_by_desc_numbers_and_build_desc_tree 0 s 0 EmptyDescOrModTree;
# array_desc = if (is_using_desc_relative_to_array==1) (get_array_D {} - 2) 0;
# (s,n_descs,desc_tree) = replace_descs_by_desc_numbers_and_build_desc_tree 0 s 0 array_desc EmptyDescOrModTree;
# desc_a = make_desc_array n_descs desc_tree;
# (desc_a,n_mods,mod_tree) = make_module_tree desc_a;
# mod_a = make_mod_array n_mods mod_tree;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment