Commit edd12069 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Avoid segfault when processing component types

parent 89db664e
...@@ -220,11 +220,11 @@ package body Buildsupport_Utils is ...@@ -220,11 +220,11 @@ package body Buildsupport_Utils is
function Get_Instance_Of (Device : Node_Id) return Name_Id is function Get_Instance_Of (Device : Node_Id) return Name_Id is
Instance_Of : Name_id := No_Name; Instance_Of : Name_id := No_Name;
begin begin
if Is_Defined_Property (Device, "taste_iv_properties::instance_of") if Is_Defined_Property (Device, "taste_iv_properties::is_instance_of")
then then
Instance_Of := Get_String_Property Instance_Of := Get_String_Property
(Device, Get_String_Name (Device, Get_String_Name
("taste_iv_properties::instance_of")); ("taste_iv_properties::is_instance_of"));
end if; end if;
return Instance_Of; return Instance_Of;
end Get_Instance_Of; end Get_Instance_Of;
......
...@@ -258,7 +258,16 @@ void GW_SDL_Interface(Interface * i) ...@@ -258,7 +258,16 @@ void GW_SDL_Interface(Interface * i)
void GW_SDL_Backend(FV * fv) void GW_SDL_Backend(FV * fv)
{ {
if (fv->system_ast->context->onlycv) return; if (fv->system_ast->context->onlycv) return;
if ((sdl == fv->language || opengeode == fv->language) && (false == fv->is_component_type)) { if ((sdl == fv->language || opengeode == fv->language)) {
printf("FV %s is in SDL\n", fv->name);
if (NULL == fv->instance_of) {
printf("Its instance_of is NULL\n");
}
else {
printf("It IS AN INSTANCE OF %s\n", fv->instance_of);
}
}
if ((sdl == fv->language || opengeode == fv->language) && (NULL == fv->instance_of)) {
Create_New_SDL_Structure(fv); Create_New_SDL_Structure(fv);
FOREACH(i, Interface, fv->interfaces, { FOREACH(i, Interface, fv->interfaces, {
GW_SDL_Interface(i); GW_SDL_Interface(i);
......
...@@ -319,15 +319,15 @@ void Function_Semantic_Check(FV * fv) ...@@ -319,15 +319,15 @@ void Function_Semantic_Check(FV * fv)
Interface_Semantic_Check(i); Interface_Semantic_Check(i);
} }
); );
/* /*
* SDL specific checks: is_component_type can only be true for SDL functions. * SDL specific checks: is_component_type can only be true for SDL functions.
* instance_of can only point to functions with is_component_type set to true. * instance_of can only point to functions with is_component_type set to true.
*/ */
if (fv->is_component_type) { if (fv->is_component_type) {
if (sdl != fv->language) { if (sdl != fv->language) {
ERROR ERROR
("** Error: Is_Component_Type is True for \"%s\". This is allowed only for SDL functions.\n", ("[ERROR] Is_Component_Type is True for \"%s\". This is allowed only for SDL functions.\n",
fv->name); fv->name);
add_error(); add_error();
} }
...@@ -337,50 +337,52 @@ void Function_Semantic_Check(FV * fv) ...@@ -337,50 +337,52 @@ void Function_Semantic_Check(FV * fv)
FV *definition = FindFV (fv->instance_of); FV *definition = FindFV (fv->instance_of);
if (definition == NULL) { if (definition == NULL) {
ERROR ERROR
("** Error: Defining function \"%s\" for \"%s\" not found.\n", ("[ERROR] Component type \"%s\" (for instance \"%s\") not found.\n",
fv->instance_of, fv->name); fv->instance_of, fv->name);
add_error(); add_error();
return;
} }
if (false == definition->is_component_type) { else {
ERROR if (false == definition->is_component_type) {
("** Error: Is_Component_Type is False for \"%s\". It should be True,\n", ERROR
definition->name); ("[ERROR] Is_Component_Type is False for \"%s\". It should be True,\n",
ERROR definition->name);
(" because function \"%s\" claims that it is an instance of \"%s\".\n", ERROR
fv->name, definition->name); (" because function \"%s\" claims that it is an instance of \"%s\".\n",
add_error(); fv->name, definition->name);
} add_error();
int fv_intf_cnt = 0; }
int definition_intf_cnt = 0; int fv_intf_cnt = 0;
FOREACH(i, Interface, fv->interfaces, { int definition_intf_cnt = 0;
Interface *def_i = FindInterface (definition, i->name); FOREACH(i, Interface, fv->interfaces, {
if (def_i == NULL) { Interface *def_i = FindInterface (definition, i->name);
ERROR if (def_i == NULL) {
("** Error: Interface \"%s\" of instance \"%s\" not found from definition \"%s\".\n",
i->name, fv->name, definition->name);
add_error();
} else {
if (!MultiInstance_SDL_Interface_Check (i, def_i)) {
ERROR ERROR
("** Error: Interface \"%s\" of instance \"%s\" not matching with definition \"%s\".\n", ("** Error: Interface \"%s\" of instance \"%s\" not found from definition \"%s\".\n",
i->name, fv->name, definition->name); i->name, fv->name, definition->name);
add_error(); add_error();
} else {
if (!MultiInstance_SDL_Interface_Check (i, def_i)) {
ERROR
("** Error: Interface \"%s\" of instance \"%s\" not matching with definition \"%s\".\n",
i->name, fv->name, definition->name);
add_error();
}
} }
}
fv_intf_cnt++; fv_intf_cnt++;
}); });
FOREACH(i, Interface, definition->interfaces, { FOREACH(i, Interface, definition->interfaces, {
UNUSED (i); UNUSED (i);
definition_intf_cnt++; definition_intf_cnt++;
}); });
if (fv_intf_cnt != definition_intf_cnt) { if (fv_intf_cnt != definition_intf_cnt) {
ERROR ERROR
("** Error: Interface count mismatch between definition \"%s\" and instance \"%s\".\n", ("** Error: Interface count mismatch between definition \"%s\" and instance \"%s\".\n",
definition->name, fv->name); definition->name, fv->name);
add_error(); add_error();
}
} }
} }
} }
......
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