stage3/fill_candidate_datatypes.cc
changeset 489 2c874cccbb44
parent 488 c833f83aac8c
child 490 29f6ab0bf954
equal deleted inserted replaced
488:c833f83aac8c 489:2c874cccbb44
   278 
   278 
   279 /* handle implicit FB call in IL.
   279 /* handle implicit FB call in IL.
   280  * e.g.  CLK ton_var
   280  * e.g.  CLK ton_var
   281  *        CU counter_var
   281  *        CU counter_var
   282  */
   282  */
   283 void fill_candidate_datatypes_c::handle_implicit_il_fb_call(symbol_c *il_instruction, const char *param_name, symbol_c *&called_fb_declaration) {
   283 void *fill_candidate_datatypes_c::handle_implicit_il_fb_call(symbol_c *il_instruction, const char *param_name, symbol_c *&called_fb_declaration) {
   284 	symbol_c *fb_type_id = search_varfb_instance_type->get_basetype_id(il_operand);
   284 	symbol_c *fb_type_id = search_varfb_instance_type->get_basetype_id(il_operand);
   285   	/* Although a call to a non-declared FB is a semantic error, this is currently caught by stage 2! */
   285   	/* Although a call to a non-declared FB is a semantic error, this is currently caught by stage 2! */
   286 	if (NULL == fb_type_id) ERROR;
   286 	if (NULL == fb_type_id) ERROR;
   287 
   287 
   288 	function_block_declaration_c *fb_decl = function_block_type_symtable.find_value(fb_type_id);
   288 	function_block_declaration_c *fb_decl = function_block_type_symtable.find_value(fb_type_id);
   312 	 */
   312 	 */
   313 	if (NULL != prev_il_instruction)
   313 	if (NULL != prev_il_instruction)
   314 		il_instruction->candidate_datatypes = prev_il_instruction->candidate_datatypes; 
   314 		il_instruction->candidate_datatypes = prev_il_instruction->candidate_datatypes; 
   315 
   315 
   316 	if (debug) std::cout << "handle_implicit_il_fb_call() [" << prev_il_instruction->candidate_datatypes.size() << "] ==> " << il_instruction->candidate_datatypes.size() << " result.\n";
   316 	if (debug) std::cout << "handle_implicit_il_fb_call() [" << prev_il_instruction->candidate_datatypes.size() << "] ==> " << il_instruction->candidate_datatypes.size() << " result.\n";
       
   317 	return NULL;
   317 }
   318 }
   318 
   319 
   319 
   320 
   320 
   321 
   321 
   322 
  1071 	if (debug) std::cout << "R [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1072 	if (debug) std::cout << "R [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> "  << symbol->candidate_datatypes.size() << " result.\n";
  1072 	return NULL;
  1073 	return NULL;
  1073 }
  1074 }
  1074 
  1075 
  1075 
  1076 
  1076 void *fill_candidate_datatypes_c::visit(S1_operator_c  *symbol) {handle_implicit_il_fb_call(symbol,  "S1", symbol->called_fb_declaration); return NULL;}
  1077 void *fill_candidate_datatypes_c::visit( S1_operator_c  *symbol) {return handle_implicit_il_fb_call(symbol,  "S1", symbol->called_fb_declaration);}
  1077 void *fill_candidate_datatypes_c::visit(R1_operator_c  *symbol) {handle_implicit_il_fb_call(symbol,  "R1", symbol->called_fb_declaration); return NULL;}
  1078 void *fill_candidate_datatypes_c::visit( R1_operator_c  *symbol) {return handle_implicit_il_fb_call(symbol,  "R1", symbol->called_fb_declaration);}
  1078 void *fill_candidate_datatypes_c::visit(CLK_operator_c *symbol) {handle_implicit_il_fb_call(symbol, "CLK", symbol->called_fb_declaration); return NULL;}
  1079 void *fill_candidate_datatypes_c::visit( CLK_operator_c *symbol) {return handle_implicit_il_fb_call(symbol, "CLK", symbol->called_fb_declaration);}
  1079 void *fill_candidate_datatypes_c::visit(CU_operator_c  *symbol) {handle_implicit_il_fb_call(symbol,  "CU", symbol->called_fb_declaration); return NULL;}
  1080 void *fill_candidate_datatypes_c::visit( CU_operator_c  *symbol) {return handle_implicit_il_fb_call(symbol,  "CU", symbol->called_fb_declaration);}
  1080 void *fill_candidate_datatypes_c::visit(CD_operator_c  *symbol) {handle_implicit_il_fb_call(symbol,  "CD", symbol->called_fb_declaration); return NULL;}
  1081 void *fill_candidate_datatypes_c::visit( CD_operator_c  *symbol) {return handle_implicit_il_fb_call(symbol,  "CD", symbol->called_fb_declaration);}
  1081 void *fill_candidate_datatypes_c::visit(PV_operator_c  *symbol) {handle_implicit_il_fb_call(symbol,  "PV", symbol->called_fb_declaration); return NULL;}
  1082 void *fill_candidate_datatypes_c::visit( PV_operator_c  *symbol) {return handle_implicit_il_fb_call(symbol,  "PV", symbol->called_fb_declaration);}
  1082 void *fill_candidate_datatypes_c::visit(IN_operator_c  *symbol) {handle_implicit_il_fb_call(symbol,  "IN", symbol->called_fb_declaration); return NULL;}
  1083 void *fill_candidate_datatypes_c::visit( IN_operator_c  *symbol) {return handle_implicit_il_fb_call(symbol,  "IN", symbol->called_fb_declaration);}
  1083 void *fill_candidate_datatypes_c::visit(PT_operator_c  *symbol) {handle_implicit_il_fb_call(symbol,  "PT", symbol->called_fb_declaration); return NULL;}
  1084 void *fill_candidate_datatypes_c::visit( PT_operator_c  *symbol) {return handle_implicit_il_fb_call(symbol,  "PT", symbol->called_fb_declaration);}
  1084 
  1085 
  1085 void *fill_candidate_datatypes_c::visit( AND_operator_c *symbol) {return handle_binary_operator(widen_AND_table, symbol, prev_il_instruction, il_operand);}
  1086 void *fill_candidate_datatypes_c::visit( AND_operator_c *symbol) {return handle_binary_operator(widen_AND_table, symbol, prev_il_instruction, il_operand);}
  1086 void *fill_candidate_datatypes_c::visit( OR_operator_c  *symbol) {return handle_binary_operator( widen_OR_table, symbol, prev_il_instruction, il_operand);}
  1087 void *fill_candidate_datatypes_c::visit(  OR_operator_c *symbol) {return handle_binary_operator( widen_OR_table, symbol, prev_il_instruction, il_operand);}
  1087 void *fill_candidate_datatypes_c::visit( XOR_operator_c *symbol) {return handle_binary_operator(widen_XOR_table, symbol, prev_il_instruction, il_operand);}
  1088 void *fill_candidate_datatypes_c::visit( XOR_operator_c *symbol) {return handle_binary_operator(widen_XOR_table, symbol, prev_il_instruction, il_operand);}
  1088 void *fill_candidate_datatypes_c::visit(ANDN_operator_c *symbol) {return handle_binary_operator(widen_AND_table, symbol, prev_il_instruction, il_operand);}
  1089 void *fill_candidate_datatypes_c::visit(ANDN_operator_c *symbol) {return handle_binary_operator(widen_AND_table, symbol, prev_il_instruction, il_operand);}
  1089 void *fill_candidate_datatypes_c::visit( ORN_operator_c *symbol) {return handle_binary_operator( widen_OR_table, symbol, prev_il_instruction, il_operand);}
  1090 void *fill_candidate_datatypes_c::visit( ORN_operator_c *symbol) {return handle_binary_operator( widen_OR_table, symbol, prev_il_instruction, il_operand);}
  1090 void *fill_candidate_datatypes_c::visit(XORN_operator_c *symbol) {return handle_binary_operator(widen_XOR_table, symbol, prev_il_instruction, il_operand);}
  1091 void *fill_candidate_datatypes_c::visit(XORN_operator_c *symbol) {return handle_binary_operator(widen_XOR_table, symbol, prev_il_instruction, il_operand);}
  1091 
  1092 
  1092 void *fill_candidate_datatypes_c::visit(ADD_operator_c *symbol) {return handle_binary_operator(widen_ADD_table, symbol, prev_il_instruction, il_operand);}
  1093 void *fill_candidate_datatypes_c::visit( ADD_operator_c *symbol) {return handle_binary_operator(widen_ADD_table, symbol, prev_il_instruction, il_operand);}
  1093 void *fill_candidate_datatypes_c::visit(SUB_operator_c *symbol) {return handle_binary_operator(widen_SUB_table, symbol, prev_il_instruction, il_operand);}
  1094 void *fill_candidate_datatypes_c::visit( SUB_operator_c *symbol) {return handle_binary_operator(widen_SUB_table, symbol, prev_il_instruction, il_operand);}
  1094 void *fill_candidate_datatypes_c::visit(MUL_operator_c *symbol) {return handle_binary_operator(widen_MUL_table, symbol, prev_il_instruction, il_operand);}
  1095 void *fill_candidate_datatypes_c::visit( MUL_operator_c *symbol) {return handle_binary_operator(widen_MUL_table, symbol, prev_il_instruction, il_operand);}
  1095 void *fill_candidate_datatypes_c::visit(DIV_operator_c *symbol) {return handle_binary_operator(widen_DIV_table, symbol, prev_il_instruction, il_operand);}
  1096 void *fill_candidate_datatypes_c::visit( DIV_operator_c *symbol) {return handle_binary_operator(widen_DIV_table, symbol, prev_il_instruction, il_operand);}
  1096 void *fill_candidate_datatypes_c::visit(MOD_operator_c *symbol) {return handle_binary_operator(widen_MOD_table, symbol, prev_il_instruction, il_operand);}
  1097 void *fill_candidate_datatypes_c::visit( MOD_operator_c *symbol) {return handle_binary_operator(widen_MOD_table, symbol, prev_il_instruction, il_operand);}
  1097 
  1098 
  1098 void *fill_candidate_datatypes_c::visit( GT_operator_c *symbol) {return handle_binary_operator(widen_CMP_table, symbol, prev_il_instruction, il_operand);}
  1099 void *fill_candidate_datatypes_c::visit(  GT_operator_c *symbol) {return handle_binary_operator(widen_CMP_table, symbol, prev_il_instruction, il_operand);}
  1099 void *fill_candidate_datatypes_c::visit( GE_operator_c *symbol) {return handle_binary_operator(widen_CMP_table, symbol, prev_il_instruction, il_operand);}
  1100 void *fill_candidate_datatypes_c::visit(  GE_operator_c *symbol) {return handle_binary_operator(widen_CMP_table, symbol, prev_il_instruction, il_operand);}
  1100 void *fill_candidate_datatypes_c::visit( EQ_operator_c *symbol) {return handle_binary_operator(widen_CMP_table, symbol, prev_il_instruction, il_operand);}
  1101 void *fill_candidate_datatypes_c::visit(  EQ_operator_c *symbol) {return handle_binary_operator(widen_CMP_table, symbol, prev_il_instruction, il_operand);}
  1101 void *fill_candidate_datatypes_c::visit( LT_operator_c *symbol) {return handle_binary_operator(widen_CMP_table, symbol, prev_il_instruction, il_operand);}
  1102 void *fill_candidate_datatypes_c::visit(  LT_operator_c *symbol) {return handle_binary_operator(widen_CMP_table, symbol, prev_il_instruction, il_operand);}
  1102 void *fill_candidate_datatypes_c::visit( LE_operator_c *symbol) {return handle_binary_operator(widen_CMP_table, symbol, prev_il_instruction, il_operand);}
  1103 void *fill_candidate_datatypes_c::visit(  LE_operator_c *symbol) {return handle_binary_operator(widen_CMP_table, symbol, prev_il_instruction, il_operand);}
  1103 void *fill_candidate_datatypes_c::visit( NE_operator_c *symbol) {return handle_binary_operator(widen_CMP_table, symbol, prev_il_instruction, il_operand);}
  1104 void *fill_candidate_datatypes_c::visit(  NE_operator_c *symbol) {return handle_binary_operator(widen_CMP_table, symbol, prev_il_instruction, il_operand);}
  1104 
  1105 
  1105 
  1106 
  1106 
  1107 
  1107 void *fill_candidate_datatypes_c::handle_conditional_il_flow_control_operator(symbol_c *symbol) {
  1108 void *fill_candidate_datatypes_c::handle_conditional_il_flow_control_operator(symbol_c *symbol) {
  1108 	if (NULL == prev_il_instruction) return NULL;
  1109 	if (NULL == prev_il_instruction) return NULL;
  1111 			add_datatype_to_candidate_list(symbol, prev_il_instruction->candidate_datatypes[i]);
  1112 			add_datatype_to_candidate_list(symbol, prev_il_instruction->candidate_datatypes[i]);
  1112 	}
  1113 	}
  1113 	return NULL;
  1114 	return NULL;
  1114 }
  1115 }
  1115 
  1116 
  1116 void *fill_candidate_datatypes_c::visit(  CAL_operator_c *symbol) {if (NULL == prev_il_instruction) return NULL; symbol->candidate_datatypes = prev_il_instruction->candidate_datatypes; return NULL;}
  1117 void *fill_candidate_datatypes_c::visit(  CAL_operator_c *symbol) {if (NULL != prev_il_instruction) symbol->candidate_datatypes = prev_il_instruction->candidate_datatypes; return NULL;}
  1117 void *fill_candidate_datatypes_c::visit(  RET_operator_c *symbol) {if (NULL == prev_il_instruction) return NULL; symbol->candidate_datatypes = prev_il_instruction->candidate_datatypes; return NULL;}
  1118 void *fill_candidate_datatypes_c::visit(  RET_operator_c *symbol) {if (NULL != prev_il_instruction) symbol->candidate_datatypes = prev_il_instruction->candidate_datatypes; return NULL;}
  1118 void *fill_candidate_datatypes_c::visit(  JMP_operator_c *symbol) {if (NULL == prev_il_instruction) return NULL; symbol->candidate_datatypes = prev_il_instruction->candidate_datatypes; return NULL;}
  1119 void *fill_candidate_datatypes_c::visit(  JMP_operator_c *symbol) {if (NULL != prev_il_instruction) symbol->candidate_datatypes = prev_il_instruction->candidate_datatypes; return NULL;}
  1119 void *fill_candidate_datatypes_c::visit( CALC_operator_c *symbol) {return handle_conditional_il_flow_control_operator(symbol);}
  1120 void *fill_candidate_datatypes_c::visit( CALC_operator_c *symbol) {return handle_conditional_il_flow_control_operator(symbol);}
  1120 void *fill_candidate_datatypes_c::visit(CALCN_operator_c *symbol) {return handle_conditional_il_flow_control_operator(symbol);}
  1121 void *fill_candidate_datatypes_c::visit(CALCN_operator_c *symbol) {return handle_conditional_il_flow_control_operator(symbol);}
  1121 void *fill_candidate_datatypes_c::visit( RETC_operator_c *symbol) {return handle_conditional_il_flow_control_operator(symbol);}
  1122 void *fill_candidate_datatypes_c::visit( RETC_operator_c *symbol) {return handle_conditional_il_flow_control_operator(symbol);}
  1122 void *fill_candidate_datatypes_c::visit(RETCN_operator_c *symbol) {return handle_conditional_il_flow_control_operator(symbol);}
  1123 void *fill_candidate_datatypes_c::visit(RETCN_operator_c *symbol) {return handle_conditional_il_flow_control_operator(symbol);}
  1123 void *fill_candidate_datatypes_c::visit( JMPC_operator_c *symbol) {return handle_conditional_il_flow_control_operator(symbol);}
  1124 void *fill_candidate_datatypes_c::visit( JMPC_operator_c *symbol) {return handle_conditional_il_flow_control_operator(symbol);}