cg_name CgMakeTwoDups( // MAKE TWO DUPLICATES cg_name *orig, // - original and destination for first dup cg_name *second, // - destination for second dup cg_type cgtype ) // - original type { temp_handle handle; // - dup. handle cg_name dup; // - duplicated node dup = CgSaveAsTemp( &handle, *orig, cgtype ); dup = CgFetchType( dup, cgtype ); *orig = CgFetchTemp( handle, cgtype ); *second = CgFetchTemp( handle, cgtype ); // returned cg_name must be emitted before // any sequence points that use *orig or *second // (i.e., returned cg_name sets up the duplicate value) return dup; }
void CgSwitchEnd // GENERATE CODE FOR END OF SWITCH STMT ( void ) { SW_CTL *ctl; // - control for switch ctl = VstkTop( &stack_switches ); CgLabel( ctl->label ); CGSelect( ctl->id, CgFetchTemp( ctl->temp, ctl->type ) ); BEFiniLabel( ctl->label ); VstkPop( &stack_switches ); CgLabelsPop( &stack_labs_sw, ctl->cases ); }
cg_name CgMakeDup( // MAKE A DUPLICATE cg_name *orig, // - original cg_type cgtype ) // - and its type { temp_handle handle; // - dup. handle cg_name dup; // - duplicated node dup = CgSaveAsTemp( &handle, *orig, cgtype ); dup = CgFetchType( dup, cgtype ); *orig = CgFetchTemp( handle, cgtype ); // returned cg_name must be emitted before // any sequence points that use *orig // (i.e., returned cg_name sets up the duplicate value) return dup; }
cg_name CgSideEffect( // CONSTRUCT SIDE-EFFECT EXPRESSION cg_name lhs, // - expression on left cg_name rhs, // - expression on right cg_type type ) // - type of right expression { #if 0 return cgCommaSideEffect( lhs, rhs, type, O_SIDE_EFFECT ); #else cg_name expr; // - result if( NULL == lhs ) { expr = rhs; } else if( NULL == rhs ) { expr = lhs; } else { temp_handle handle; // - handle expr = CgSaveAsTemp( &handle, lhs, type ); expr = CgComma( expr, rhs, type ); expr = CgComma( expr, CgFetchTemp( handle, type ), type ); } return expr; #endif }