stage3/narrow_candidate_datatypes.cc
changeset 487 1619b2fe03e1
parent 484 f78750994a82
child 489 2c874cccbb44
equal deleted inserted replaced
486:e22150ad75fd 487:1619b2fe03e1
   927 void *narrow_candidate_datatypes_c::visit(  LT_operator_c *symbol)  {return narrow_binary_operator(widen_CMP_table, symbol);}
   927 void *narrow_candidate_datatypes_c::visit(  LT_operator_c *symbol)  {return narrow_binary_operator(widen_CMP_table, symbol);}
   928 void *narrow_candidate_datatypes_c::visit(  LE_operator_c *symbol)  {return narrow_binary_operator(widen_CMP_table, symbol);}
   928 void *narrow_candidate_datatypes_c::visit(  LE_operator_c *symbol)  {return narrow_binary_operator(widen_CMP_table, symbol);}
   929 void *narrow_candidate_datatypes_c::visit(  NE_operator_c *symbol)  {return narrow_binary_operator(widen_CMP_table, symbol);}
   929 void *narrow_candidate_datatypes_c::visit(  NE_operator_c *symbol)  {return narrow_binary_operator(widen_CMP_table, symbol);}
   930 
   930 
   931 
   931 
   932 // SYM_REF0(CAL_operator_c)
       
   933 /* called from il_fb_call_c (symbol->il_call_operator->accpet(*this) ) */
       
   934 void *narrow_candidate_datatypes_c::visit(CAL_operator_c *symbol) {
       
   935 	/* set the desired datatype of the previous il instruction */
       
   936 	/* This FB call does not change the value in the current/default IL variable, so we pass the required datatype to the previous IL instruction */
       
   937 	set_datatype_in_prev_il_instructions(symbol->datatype, fake_prev_il_instruction);
       
   938 	return NULL;
       
   939 }
       
   940 
   932 
   941 
   933 
   942 void *narrow_candidate_datatypes_c::narrow_conditional_flow_control_IL_instruction(symbol_c *symbol) {
   934 void *narrow_candidate_datatypes_c::narrow_conditional_flow_control_IL_instruction(symbol_c *symbol) {
   943 	/* if the next IL instructions needs us to provide a datatype other than a bool, 
   935 	/* if the next IL instructions needs us to provide a datatype other than a bool, 
   944 	 * then we have an internal compiler error - most likely in fill_candidate_datatypes_c 
   936 	 * then we have an internal compiler error - most likely in fill_candidate_datatypes_c 
   958 	set_datatype_in_prev_il_instructions(symbol->datatype, fake_prev_il_instruction);
   950 	set_datatype_in_prev_il_instructions(symbol->datatype, fake_prev_il_instruction);
   959 	return NULL;
   951 	return NULL;
   960 }
   952 }
   961 
   953 
   962 
   954 
       
   955 // SYM_REF0(CAL_operator_c)
   963 // SYM_REF0(CALC_operator_c)
   956 // SYM_REF0(CALC_operator_c)
   964 // SYM_REF0(CALCN_operator_c)
   957 // SYM_REF0(CALCN_operator_c)
   965 /* called from visit(il_fb_call_c *) {symbol->il_call_operator->accpet(*this)} */
   958 /* called from visit(il_fb_call_c *) {symbol->il_call_operator->accpet(*this)} */
       
   959 /* NOTE: The CAL, JMP and RET instructions simply set the desired datatype of the previous il instruction since they do not change the value in the current/default IL variable */
       
   960 /* called from il_fb_call_c (symbol->il_call_operator->accpet(*this) ) */
       
   961 void *narrow_candidate_datatypes_c::visit(  CAL_operator_c *symbol) {set_datatype_in_prev_il_instructions(symbol->datatype, fake_prev_il_instruction); return NULL;}
       
   962 void *narrow_candidate_datatypes_c::visit(  RET_operator_c *symbol) {set_datatype_in_prev_il_instructions(symbol->datatype, fake_prev_il_instruction); return NULL;}
       
   963 void *narrow_candidate_datatypes_c::visit(  JMP_operator_c *symbol) {set_datatype_in_prev_il_instructions(symbol->datatype, fake_prev_il_instruction); return NULL;}
   966 void *narrow_candidate_datatypes_c::visit( CALC_operator_c *symbol) {return narrow_conditional_flow_control_IL_instruction(symbol);}
   964 void *narrow_candidate_datatypes_c::visit( CALC_operator_c *symbol) {return narrow_conditional_flow_control_IL_instruction(symbol);}
   967 void *narrow_candidate_datatypes_c::visit(CALCN_operator_c *symbol) {return narrow_conditional_flow_control_IL_instruction(symbol);}
   965 void *narrow_candidate_datatypes_c::visit(CALCN_operator_c *symbol) {return narrow_conditional_flow_control_IL_instruction(symbol);}
   968 
       
   969 
       
   970 void *narrow_candidate_datatypes_c::visit(RET_operator_c *symbol) {
       
   971 	/* set the desired datatype of the previous il instruction */
       
   972 	/* This RET instruction does not change the value in the current/default IL variable, so we pass the required datatype to the previous IL instruction.
       
   973 	 * Actually this should always be NULL, otherwise we have a bug in the flow_control_analysis_c
       
   974 	 * However, since that class has not yet been completely finished, we do not yet check this assertion!
       
   975 	 */
       
   976 // 	if (NULL != symbol->datatype) ERROR;
       
   977 	set_datatype_in_prev_il_instructions(symbol->datatype, fake_prev_il_instruction);
       
   978 	return NULL;
       
   979 }
       
   980 
       
   981 void *narrow_candidate_datatypes_c::visit( RETC_operator_c *symbol) {return narrow_conditional_flow_control_IL_instruction(symbol);}
   966 void *narrow_candidate_datatypes_c::visit( RETC_operator_c *symbol) {return narrow_conditional_flow_control_IL_instruction(symbol);}
   982 void *narrow_candidate_datatypes_c::visit(RETCN_operator_c *symbol) {return narrow_conditional_flow_control_IL_instruction(symbol);}
   967 void *narrow_candidate_datatypes_c::visit(RETCN_operator_c *symbol) {return narrow_conditional_flow_control_IL_instruction(symbol);}
   983 
       
   984 void *narrow_candidate_datatypes_c::visit(JMP_operator_c *symbol) {
       
   985 	/* set the desired datatype of the previous il instruction */
       
   986 	/* This JMP instruction does not change the value in the current/default IL variable, so we pass the required datatype to the previous IL instruction.
       
   987 	 * Actually this should always be NULL, otherwise we have a bug in the flow_control_analysis_c
       
   988 	 * However, since that class has not yet been completely finished, we do not yet check this assertion!
       
   989 	 */
       
   990 // 	if (NULL != symbol->datatype) ERROR;
       
   991 	set_datatype_in_prev_il_instructions(symbol->datatype, fake_prev_il_instruction);
       
   992 	return NULL;
       
   993 }
       
   994 
       
   995 void *narrow_candidate_datatypes_c::visit( JMPC_operator_c *symbol) {return narrow_conditional_flow_control_IL_instruction(symbol);}
   968 void *narrow_candidate_datatypes_c::visit( JMPC_operator_c *symbol) {return narrow_conditional_flow_control_IL_instruction(symbol);}
   996 void *narrow_candidate_datatypes_c::visit(JMPCN_operator_c *symbol) {return narrow_conditional_flow_control_IL_instruction(symbol);}
   969 void *narrow_candidate_datatypes_c::visit(JMPCN_operator_c *symbol) {return narrow_conditional_flow_control_IL_instruction(symbol);}
   997 
   970 
   998 /* Symbol class handled together with function call checks */
   971 /* Symbol class handled together with function call checks */
   999 // void *visit(il_assign_operator_c *symbol, variable_name);
   972 // void *visit(il_assign_operator_c *symbol, variable_name);