changeset 793 | 268bf4ca5fa1 |
parent 762 | a3d917474ae4 |
parent 706 | 31553c22f318 |
child 834 | 783ef40344dd |
785:b08167f156a1 | 793:268bf4ca5fa1 |
---|---|
364 |
364 |
365 |
365 |
366 void *print_getter(symbol_c *symbol) { |
366 void *print_getter(symbol_c *symbol) { |
367 unsigned int vartype = search_var_instance_decl->get_vartype(symbol); |
367 unsigned int vartype = search_var_instance_decl->get_vartype(symbol); |
368 if (wanted_variablegeneration == fparam_output_vg) { |
368 if (wanted_variablegeneration == fparam_output_vg) { |
369 if (vartype == search_var_instance_decl_c::external_vt) |
369 if (vartype == search_var_instance_decl_c::external_vt) { |
370 s4o.print(GET_EXTERNAL_BY_REF); |
370 if (search_var_instance_decl->type_is_fb(symbol)) |
371 s4o.print(GET_EXTERNAL_FB_BY_REF); |
|
372 else |
|
373 s4o.print(GET_EXTERNAL_BY_REF); |
|
374 } |
|
371 else if (vartype == search_var_instance_decl_c::located_vt) |
375 else if (vartype == search_var_instance_decl_c::located_vt) |
372 s4o.print(GET_LOCATED_BY_REF); |
376 s4o.print(GET_LOCATED_BY_REF); |
373 else |
377 else |
374 s4o.print(GET_VAR_BY_REF); |
378 s4o.print(GET_VAR_BY_REF); |
375 } |
379 } |
376 else { |
380 else { |
377 if (vartype == search_var_instance_decl_c::external_vt) |
381 if (vartype == search_var_instance_decl_c::external_vt) { |
378 s4o.print(GET_EXTERNAL); |
382 if (search_var_instance_decl->type_is_fb(symbol)) |
379 else if (vartype == search_var_instance_decl_c::located_vt) |
383 s4o.print(GET_EXTERNAL_FB); |
380 s4o.print(GET_LOCATED); |
384 else |
381 else |
385 s4o.print(GET_EXTERNAL); |
382 s4o.print(GET_VAR); |
386 } |
387 else if (vartype == search_var_instance_decl_c::located_vt) |
|
388 s4o.print(GET_LOCATED); |
|
389 else |
|
390 s4o.print(GET_VAR); |
|
383 } |
391 } |
384 s4o.print("("); |
392 s4o.print("("); |
385 |
393 |
386 variablegeneration_t old_wanted_variablegeneration = wanted_variablegeneration; |
394 variablegeneration_t old_wanted_variablegeneration = wanted_variablegeneration; |
387 wanted_variablegeneration = complextype_base_vg; |
395 wanted_variablegeneration = complextype_base_vg; |
394 wanted_variablegeneration = old_wanted_variablegeneration; |
402 wanted_variablegeneration = old_wanted_variablegeneration; |
395 return NULL; |
403 return NULL; |
396 } |
404 } |
397 |
405 |
398 void *print_setter(symbol_c* symbol, |
406 void *print_setter(symbol_c* symbol, |
399 symbol_c* type, |
407 symbol_c* type, |
400 symbol_c* value, |
408 symbol_c* value, |
401 symbol_c* fb_symbol = NULL, |
409 symbol_c* fb_symbol = NULL, |
402 symbol_c* fb_value = NULL, |
410 symbol_c* fb_value = NULL, |
403 bool negative = false) { |
411 bool negative = false) { |
404 |
412 |
405 bool type_is_complex = false; |
413 bool type_is_complex = search_var_instance_decl->type_is_complex(symbol); |
406 if (fb_symbol == NULL) { |
414 if (fb_symbol == NULL) { |
407 unsigned int vartype = search_var_instance_decl->get_vartype(symbol); |
415 unsigned int vartype = search_var_instance_decl->get_vartype(symbol); |
408 type_is_complex = search_var_instance_decl->type_is_complex(symbol); |
416 if (vartype == search_var_instance_decl_c::external_vt) { |
409 if (vartype == search_var_instance_decl_c::external_vt) |
417 if (search_var_instance_decl->type_is_fb(symbol)) |
410 s4o.print(SET_EXTERNAL); |
418 s4o.print(SET_EXTERNAL_FB); |
419 else |
|
420 s4o.print(SET_EXTERNAL); |
|
421 } |
|
411 else if (vartype == search_var_instance_decl_c::located_vt) |
422 else if (vartype == search_var_instance_decl_c::located_vt) |
412 s4o.print(SET_LOCATED); |
423 s4o.print(SET_LOCATED); |
413 else |
424 else |
414 s4o.print(SET_VAR); |
425 s4o.print(SET_VAR); |
415 } |
426 } |
416 else |
427 else { |
417 s4o.print(SET_VAR); |
428 unsigned int vartype = search_var_instance_decl->get_vartype(fb_symbol); |
429 if (vartype == search_var_instance_decl_c::external_vt) |
|
430 s4o.print(SET_EXTERNAL_FB); |
|
431 else |
|
432 s4o.print(SET_VAR); |
|
433 } |
|
418 s4o.print("("); |
434 s4o.print("("); |
419 |
435 |
420 if (fb_symbol != NULL) { |
436 if (fb_symbol != NULL) { |
421 print_variable_prefix(); |
437 print_variable_prefix(); |
422 fb_symbol->accept(*this); |
438 fb_symbol->accept(*this); |
429 |
445 |
430 symbol->accept(*this); |
446 symbol->accept(*this); |
431 s4o.print(","); |
447 s4o.print(","); |
432 if (negative) { |
448 if (negative) { |
433 if (get_datatype_info_c::is_BOOL_compatible(this->current_operand->datatype)) |
449 if (get_datatype_info_c::is_BOOL_compatible(this->current_operand->datatype)) |
434 s4o.print("!"); |
450 s4o.print("!"); |
435 else |
451 else |
436 s4o.print("~"); |
452 s4o.print("~"); |
437 } |
453 } |
438 wanted_variablegeneration = expression_vg; |
454 wanted_variablegeneration = expression_vg; |
439 print_check_function(type, value, fb_value); |
455 print_check_function(type, value, fb_value); |
440 if (type_is_complex) { |
456 if (type_is_complex) { |
441 s4o.print(","); |
457 s4o.print(","); |
493 break; |
509 break; |
494 case complextype_base_vg: |
510 case complextype_base_vg: |
495 generate_c_base_c::visit(symbol); |
511 generate_c_base_c::visit(symbol); |
496 break; |
512 break; |
497 case complextype_suffix_vg: |
513 case complextype_suffix_vg: |
498 break; |
514 break; |
499 default: |
515 default: |
500 if (this->is_variable_prefix_null()) { |
516 if (this->is_variable_prefix_null()) { |
501 vartype = search_var_instance_decl->get_vartype(symbol); |
517 vartype = search_var_instance_decl->get_vartype(symbol); |
502 if (wanted_variablegeneration == fparam_output_vg) { |
518 if (wanted_variablegeneration == fparam_output_vg) { |
503 s4o.print("&("); |
519 s4o.print("&("); |
504 generate_c_base_c::visit(symbol); |
520 generate_c_base_c::visit(symbol); |
505 s4o.print(")"); |
521 s4o.print(")"); |
506 } |
522 } |
523 TRACE("direct_variable_c"); |
539 TRACE("direct_variable_c"); |
524 /* Do not use print_token() as it will change everything into uppercase */ |
540 /* Do not use print_token() as it will change everything into uppercase */ |
525 if (strlen(symbol->value) == 0) ERROR; |
541 if (strlen(symbol->value) == 0) ERROR; |
526 if (this->is_variable_prefix_null()) { |
542 if (this->is_variable_prefix_null()) { |
527 if (wanted_variablegeneration != fparam_output_vg) |
543 if (wanted_variablegeneration != fparam_output_vg) |
528 s4o.print("*("); |
544 s4o.print("*("); |
529 } |
545 } |
530 else { |
546 else { |
531 switch (wanted_variablegeneration) { |
547 switch (wanted_variablegeneration) { |
532 case expression_vg: |
548 case expression_vg: |
533 s4o.print(GET_LOCATED); |
549 s4o.print(GET_LOCATED); |
534 s4o.print("("); |
550 s4o.print("("); |
535 break; |
551 break; |
536 case fparam_output_vg: |
552 case fparam_output_vg: |
537 s4o.print(GET_LOCATED_BY_REF); |
553 s4o.print(GET_LOCATED_BY_REF); |
538 s4o.print("("); |
554 s4o.print("("); |
539 break; |
555 break; |
540 default: |
556 default: |
542 } |
558 } |
543 } |
559 } |
544 this->print_variable_prefix(); |
560 this->print_variable_prefix(); |
545 s4o.printlocation(symbol->value + 1); |
561 s4o.printlocation(symbol->value + 1); |
546 if ((this->is_variable_prefix_null() && wanted_variablegeneration != fparam_output_vg) || |
562 if ((this->is_variable_prefix_null() && wanted_variablegeneration != fparam_output_vg) || |
547 wanted_variablegeneration != assignment_vg) |
563 wanted_variablegeneration != assignment_vg) |
548 s4o.print(")"); |
564 s4o.print(")"); |
549 return NULL; |
565 return NULL; |
550 } |
566 } |
551 |
567 |
552 /*************************************/ |
568 /*************************************/ |
565 s4o.print("."); |
581 s4o.print("."); |
566 symbol->field_selector->accept(*this); |
582 symbol->field_selector->accept(*this); |
567 } |
583 } |
568 break; |
584 break; |
569 case complextype_suffix_vg: |
585 case complextype_suffix_vg: |
570 symbol->record_variable->accept(*this); |
586 symbol->record_variable->accept(*this); |
571 if (type_is_complex) { |
587 if (type_is_complex) { |
572 s4o.print("."); |
588 s4o.print("."); |
573 symbol->field_selector->accept(*this); |
589 symbol->field_selector->accept(*this); |
574 } |
590 } |
575 break; |
591 break; |
576 case assignment_vg: |
592 case assignment_vg: |
577 symbol->record_variable->accept(*this); |
593 symbol->record_variable->accept(*this); |
578 s4o.print("."); |
594 s4o.print("."); |
579 symbol->field_selector->accept(*this); |
595 symbol->field_selector->accept(*this); |
580 break; |
596 break; |
581 default: |
597 default: |
582 if (this->is_variable_prefix_null()) { |
598 if (this->is_variable_prefix_null()) { |
583 symbol->record_variable->accept(*this); |
599 symbol->record_variable->accept(*this); |
584 s4o.print("."); |
600 s4o.print("."); |
585 symbol->field_selector->accept(*this); |
601 symbol->field_selector->accept(*this); |
586 } |
602 } |
587 else |
603 else |
588 print_getter(symbol); |
604 print_getter(symbol); |
589 break; |
605 break; |
590 } |
606 } |
591 return NULL; |
607 return NULL; |
592 } |
608 } |
593 |
609 |
621 symbol->subscript_list->accept(*this); |
637 symbol->subscript_list->accept(*this); |
622 |
638 |
623 current_array_type = NULL; |
639 current_array_type = NULL; |
624 } |
640 } |
625 else |
641 else |
626 print_getter(symbol); |
642 print_getter(symbol); |
627 break; |
643 break; |
628 } |
644 } |
629 return NULL; |
645 return NULL; |
630 } |
646 } |
631 |
647 |
632 /* subscript_list ',' subscript */ |
648 /* subscript_list ',' subscript */ |
633 void *visit(subscript_list_c *symbol) { |
649 void *visit(subscript_list_c *symbol) { |
634 array_dimension_iterator_c* array_dimension_iterator = new array_dimension_iterator_c(current_array_type); |
650 array_dimension_iterator_c* array_dimension_iterator = new array_dimension_iterator_c(current_array_type); |
635 for (int i = 0; i < symbol->n; i++) { |
651 for (int i = 0; i < symbol->n; i++) { |
636 symbol_c* dimension = array_dimension_iterator->next(); |
652 symbol_c* dimension = array_dimension_iterator->next(); |
637 if (dimension == NULL) ERROR; |
653 if (dimension == NULL) ERROR; |
638 |
654 |
639 s4o.print("[("); |
655 s4o.print("[("); |
640 symbol->elements[i]->accept(*this); |
656 symbol->elements[i]->accept(*this); |
641 s4o.print(") - ("); |
657 s4o.print(") - ("); |
642 dimension->accept(*this); |
658 dimension->accept(*this); |
643 s4o.print(")]"); |
659 s4o.print(")]"); |
644 } |
660 } |
858 s4o.print("("); |
874 s4o.print("("); |
859 default_literal_type(function_type_prefix)->accept(*this); |
875 default_literal_type(function_type_prefix)->accept(*this); |
860 s4o.print(")"); |
876 s4o.print(")"); |
861 } |
877 } |
862 if (function_type_suffix != NULL) { |
878 if (function_type_suffix != NULL) { |
863 function_type_suffix = default_literal_type(function_type_suffix); |
879 function_type_suffix = default_literal_type(function_type_suffix); |
864 } |
880 } |
865 if (has_output_params) { |
881 if (has_output_params) { |
866 fcall_number++; |
882 fcall_number++; |
867 s4o.print("__"); |
883 s4o.print("__"); |
868 fbname->accept(*this); |
884 fbname->accept(*this); |
883 /* function being called is overloaded! */ |
899 /* function being called is overloaded! */ |
884 s4o.print("__"); |
900 s4o.print("__"); |
885 print_function_parameter_data_types_c overloaded_func_suf(&s4o); |
901 print_function_parameter_data_types_c overloaded_func_suf(&s4o); |
886 f_decl->accept(overloaded_func_suf); |
902 f_decl->accept(overloaded_func_suf); |
887 } |
903 } |
888 } |
904 } |
889 if (function_type_suffix != NULL) |
905 if (function_type_suffix != NULL) |
890 function_type_suffix->accept(*this); |
906 function_type_suffix->accept(*this); |
891 } |
907 } |
892 s4o.print("("); |
908 s4o.print("("); |
893 s4o.indent_right(); |
909 s4o.indent_right(); |
1049 |
1065 |
1050 /* now output the value assignment */ |
1066 /* now output the value assignment */ |
1051 if (param_value != NULL) |
1067 if (param_value != NULL) |
1052 if ((param_direction == function_param_iterator_c::direction_in) || |
1068 if ((param_direction == function_param_iterator_c::direction_in) || |
1053 (param_direction == function_param_iterator_c::direction_inout)) { |
1069 (param_direction == function_param_iterator_c::direction_inout)) { |
1054 if (this->is_variable_prefix_null()) { |
1070 if (this->is_variable_prefix_null()) { |
1055 symbol->fb_name->accept(*this); |
1071 symbol->fb_name->accept(*this); |
1056 s4o.print("."); |
1072 s4o.print("."); |
1057 param_name->accept(*this); |
1073 param_name->accept(*this); |
1058 s4o.print(" = "); |
1074 s4o.print(" = "); |
1059 print_check_function(param_type, param_value); |
1075 print_check_function(param_type, param_value); |
1060 } |
1076 } |
1061 else { |
1077 else { |
1062 print_setter(param_name, param_type, param_value, symbol->fb_name); |
1078 print_setter(param_name, param_type, param_value, symbol->fb_name); |
1063 } |
1079 } |
1064 s4o.print(";\n" + s4o.indent_spaces); |
1080 s4o.print(";\n" + s4o.indent_spaces); |
1065 } |
1081 } |
1066 } /* for(...) */ |
1082 } /* for(...) */ |
1067 |
1083 |
1068 /* now call the function... */ |
1084 /* now call the function... */ |
1069 function_block_type_name->accept(*this); |
1085 function_block_type_name->accept(*this); |
1070 s4o.print(FB_FUNCTION_SUFFIX); |
1086 s4o.print(FB_FUNCTION_SUFFIX); |
1071 s4o.print("(&"); |
1087 s4o.print("("); |
1088 if (search_var_instance_decl->get_vartype(symbol->fb_name) != search_var_instance_decl_c::external_vt) |
|
1089 s4o.print("&"); |
|
1072 print_variable_prefix(); |
1090 print_variable_prefix(); |
1073 symbol->fb_name->accept(*this); |
1091 symbol->fb_name->accept(*this); |
1074 s4o.print(")"); |
1092 s4o.print(")"); |
1075 |
1093 |
1076 /* loop through each function parameter, find the variable to which |
1094 /* loop through each function parameter, find the variable to which |
1097 (param_direction == function_param_iterator_c::direction_inout)) { |
1115 (param_direction == function_param_iterator_c::direction_inout)) { |
1098 symbol_c *param_type = search_varfb_instance_type->get_type_id(param_value); |
1116 symbol_c *param_type = search_varfb_instance_type->get_type_id(param_value); |
1099 s4o.print(";\n" + s4o.indent_spaces); |
1117 s4o.print(";\n" + s4o.indent_spaces); |
1100 if (this->is_variable_prefix_null()) { |
1118 if (this->is_variable_prefix_null()) { |
1101 param_value->accept(*this); |
1119 param_value->accept(*this); |
1102 s4o.print(" = "); |
1120 s4o.print(" = "); |
1103 print_check_function(param_type, param_name, symbol->fb_name); |
1121 print_check_function(param_type, param_name, symbol->fb_name); |
1104 } |
1122 } |
1105 else { |
1123 else { |
1106 print_setter(param_value, param_type, param_name, NULL, symbol->fb_name); |
1124 print_setter(param_value, param_type, param_name, NULL, symbol->fb_name); |
1107 } |
1125 } |
1108 } |
1126 } |
1109 } /* for(...) */ |
1127 } /* for(...) */ |
1110 |
1128 |
1111 s4o.print(";\n"); |
1129 s4o.print(";\n"); |
1112 s4o.indent_left(); |
1130 s4o.indent_left(); |
1248 s4o.print("("); |
1266 s4o.print("("); |
1249 default_literal_type(function_type_prefix)->accept(*this); |
1267 default_literal_type(function_type_prefix)->accept(*this); |
1250 s4o.print(")"); |
1268 s4o.print(")"); |
1251 } |
1269 } |
1252 if (function_type_suffix != NULL) { |
1270 if (function_type_suffix != NULL) { |
1253 function_type_suffix = default_literal_type(function_type_suffix); |
1271 function_type_suffix = default_literal_type(function_type_suffix); |
1254 } |
1272 } |
1255 if (has_output_params) { |
1273 if (has_output_params) { |
1256 fcall_number++; |
1274 fcall_number++; |
1257 s4o.print("__"); |
1275 s4o.print("__"); |
1258 fbname->accept(*this); |
1276 fbname->accept(*this); |
1418 return NULL; |
1436 return NULL; |
1419 } |
1437 } |
1420 |
1438 |
1421 |
1439 |
1422 // SYM_REF1(il_simple_instruction_c, il_simple_instruction, symbol_c *prev_il_instruction;) |
1440 // SYM_REF1(il_simple_instruction_c, il_simple_instruction, symbol_c *prev_il_instruction;) |
1423 void *visit(il_simple_instruction_c *symbol) { |
1441 void *visit(il_simple_instruction_c *symbol) { |
1424 /* all previous IL instructions should have the same datatype (checked in stage3), so we get the datatype from the first previous IL instruction we find */ |
1442 /* all previous IL instructions should have the same datatype (checked in stage3), so we get the datatype from the first previous IL instruction we find */ |
1425 implicit_variable_current.datatype = (symbol->prev_il_instruction.empty())? NULL : symbol->prev_il_instruction[0]->datatype; |
1443 implicit_variable_current.datatype = (symbol->prev_il_instruction.empty())? NULL : symbol->prev_il_instruction[0]->datatype; |
1426 implicit_variable_result .datatype = symbol->datatype; |
1444 implicit_variable_result .datatype = symbol->datatype; |
1427 |
1445 |
1428 symbol->il_simple_instruction->accept(*this); |
1446 symbol->il_simple_instruction->accept(*this); |
1509 XXX_operator(&(this->implicit_variable_result), get_datatype_info_c::is_BOOL_compatible(symbol->datatype)?" = !":" = ~", &(this->implicit_variable_current)); |
1527 XXX_operator(&(this->implicit_variable_result), get_datatype_info_c::is_BOOL_compatible(symbol->datatype)?" = !":" = ~", &(this->implicit_variable_current)); |
1510 return NULL; |
1528 return NULL; |
1511 } |
1529 } |
1512 |
1530 |
1513 |
1531 |
1514 void *visit(S_operator_c *symbol) { |
1532 void *visit(S_operator_c *symbol) { |
1515 if (wanted_variablegeneration != expression_vg) { |
1533 if (wanted_variablegeneration != expression_vg) { |
1516 s4o.print("LD"); |
1534 s4o.print("LD"); |
1517 return NULL; |
1535 return NULL; |
1518 } |
1536 } |
1519 |
1537 |
1531 ERROR; |
1549 ERROR; |
1532 return NULL; |
1550 return NULL; |
1533 } |
1551 } |
1534 |
1552 |
1535 |
1553 |
1536 void *visit(R_operator_c *symbol) { |
1554 void *visit(R_operator_c *symbol) { |
1537 if (wanted_variablegeneration != expression_vg) { |
1555 if (wanted_variablegeneration != expression_vg) { |
1538 s4o.print("LD"); |
1556 s4o.print("LD"); |
1539 return NULL; |
1557 return NULL; |
1540 } |
1558 } |
1541 |
1559 |
1563 void *visit( CD_operator_c *symbol) {return XXX_CAL_operator( "CD", this->current_operand);} |
1581 void *visit( CD_operator_c *symbol) {return XXX_CAL_operator( "CD", this->current_operand);} |
1564 void *visit( PV_operator_c *symbol) {return XXX_CAL_operator( "PV", this->current_operand);} |
1582 void *visit( PV_operator_c *symbol) {return XXX_CAL_operator( "PV", this->current_operand);} |
1565 void *visit( IN_operator_c *symbol) {return XXX_CAL_operator( "IN", this->current_operand);} |
1583 void *visit( IN_operator_c *symbol) {return XXX_CAL_operator( "IN", this->current_operand);} |
1566 void *visit( PT_operator_c *symbol) {return XXX_CAL_operator( "PT", this->current_operand);} |
1584 void *visit( PT_operator_c *symbol) {return XXX_CAL_operator( "PT", this->current_operand);} |
1567 |
1585 |
1568 void *visit(AND_operator_c *symbol) { |
1586 void *visit(AND_operator_c *symbol) { |
1569 if (!get_datatype_info_c::is_ANY_BIT_compatible(symbol->datatype)) ERROR; |
1587 if (!get_datatype_info_c::is_ANY_BIT_compatible(symbol->datatype)) ERROR; |
1570 XXX_operator(&(this->implicit_variable_result), " &= ", this->current_operand); |
1588 XXX_operator(&(this->implicit_variable_result), " &= ", this->current_operand); |
1571 return NULL; |
1589 return NULL; |
1572 } |
1590 } |
1573 |
1591 |
1574 void *visit(OR_operator_c *symbol) { |
1592 void *visit(OR_operator_c *symbol) { |
1575 if (!get_datatype_info_c::is_ANY_BIT_compatible(symbol->datatype)) ERROR; |
1593 if (!get_datatype_info_c::is_ANY_BIT_compatible(symbol->datatype)) ERROR; |
1576 XXX_operator(&(this->implicit_variable_result), " |= ", this->current_operand); |
1594 XXX_operator(&(this->implicit_variable_result), " |= ", this->current_operand); |
1577 return NULL; |
1595 return NULL; |
1578 } |
1596 } |
1579 |
1597 |
1580 void *visit(XOR_operator_c *symbol) { |
1598 void *visit(XOR_operator_c *symbol) { |
1581 if (!get_datatype_info_c::is_ANY_BIT_compatible(symbol->datatype)) ERROR; |
1599 if (!get_datatype_info_c::is_ANY_BIT_compatible(symbol->datatype)) ERROR; |
1582 // '^' is a bit by bit exclusive OR !! Also seems to work with boolean types! |
1600 // '^' is a bit by bit exclusive OR !! Also seems to work with boolean types! |
1583 XXX_operator(&(this->implicit_variable_result), " ^= ", this->current_operand); |
1601 XXX_operator(&(this->implicit_variable_result), " ^= ", this->current_operand); |
1584 return NULL; |
1602 return NULL; |
1585 } |
1603 } |
1586 |
1604 |
1587 void *visit(ANDN_operator_c *symbol) { |
1605 void *visit(ANDN_operator_c *symbol) { |
1588 if (!get_datatype_info_c::is_ANY_BIT_compatible(symbol->datatype)) ERROR; |
1606 if (!get_datatype_info_c::is_ANY_BIT_compatible(symbol->datatype)) ERROR; |
1589 XXX_operator(&(this->implicit_variable_result), get_datatype_info_c::is_BOOL_compatible(this->current_operand->datatype)?" &= !":" &= ~", this->current_operand); |
1607 XXX_operator(&(this->implicit_variable_result), get_datatype_info_c::is_BOOL_compatible(this->current_operand->datatype)?" &= !":" &= ~", this->current_operand); |
1590 return NULL; |
1608 return NULL; |
1591 } |
1609 } |
1592 |
1610 |
1593 void *visit(ORN_operator_c *symbol) { |
1611 void *visit(ORN_operator_c *symbol) { |
1594 if (!get_datatype_info_c::is_ANY_BIT_compatible(symbol->datatype)) ERROR; |
1612 if (!get_datatype_info_c::is_ANY_BIT_compatible(symbol->datatype)) ERROR; |
1595 XXX_operator(&(this->implicit_variable_result), get_datatype_info_c::is_BOOL_compatible(this->current_operand->datatype)?" |= !":" |= ~", this->current_operand); |
1613 XXX_operator(&(this->implicit_variable_result), get_datatype_info_c::is_BOOL_compatible(this->current_operand->datatype)?" |= !":" |= ~", this->current_operand); |
1596 return NULL; |
1614 return NULL; |
1597 } |
1615 } |
1598 |
1616 |
1599 void *visit(XORN_operator_c *symbol) { |
1617 void *visit(XORN_operator_c *symbol) { |
1600 if (!get_datatype_info_c::is_ANY_BIT_compatible(symbol->datatype)) ERROR; |
1618 if (!get_datatype_info_c::is_ANY_BIT_compatible(symbol->datatype)) ERROR; |
1601 // bit by bit exclusive OR !! Also seems to work with boolean types! |
1619 // bit by bit exclusive OR !! Also seems to work with boolean types! |
1602 XXX_operator(&(this->implicit_variable_result), get_datatype_info_c::is_BOOL_compatible(this->current_operand->datatype)?" ^= !":" ^= ~", this->current_operand); |
1620 XXX_operator(&(this->implicit_variable_result), get_datatype_info_c::is_BOOL_compatible(this->current_operand->datatype)?" ^= !":" ^= ~", this->current_operand); |
1603 return NULL; |
1621 return NULL; |
1604 } |
1622 } |
1605 |
1623 |
1606 void *visit(ADD_operator_c *symbol) { |
1624 void *visit(ADD_operator_c *symbol) { |
1607 if (get_datatype_info_c::is_TIME_compatible(symbol->datatype) || get_datatype_info_c::is_ANY_DATE_compatible (symbol->datatype)) |
1625 if (get_datatype_info_c::is_TIME_compatible(symbol->datatype) || get_datatype_info_c::is_ANY_DATE_compatible (symbol->datatype)) |
1608 XXX_function(&(this->implicit_variable_result), "__time_add", &(this->implicit_variable_current), this->current_operand); |
1626 XXX_function(&(this->implicit_variable_result), "__time_add", &(this->implicit_variable_current), this->current_operand); |
1609 else XXX_operator(&(this->implicit_variable_result), " += ", this->current_operand); |
1627 else XXX_operator(&(this->implicit_variable_result), " += ", this->current_operand); |
1610 return NULL; |
1628 return NULL; |
1611 } |
1629 } |
1612 |
1630 |
1613 void *visit(SUB_operator_c *symbol) { |
1631 void *visit(SUB_operator_c *symbol) { |
1614 if (get_datatype_info_c::is_TIME_compatible(symbol->datatype) || get_datatype_info_c::is_ANY_DATE_compatible (symbol->datatype)) |
1632 if (get_datatype_info_c::is_TIME_compatible(symbol->datatype) || get_datatype_info_c::is_ANY_DATE_compatible (symbol->datatype)) |
1615 XXX_function(&(this->implicit_variable_result), "__time_sub", &(this->implicit_variable_current), this->current_operand); |
1633 XXX_function(&(this->implicit_variable_result), "__time_sub", &(this->implicit_variable_current), this->current_operand); |
1616 else XXX_operator(&(this->implicit_variable_result), " -= ", this->current_operand); |
1634 else XXX_operator(&(this->implicit_variable_result), " -= ", this->current_operand); |
1617 return NULL; |
1635 return NULL; |
1618 } |
1636 } |
1619 |
1637 |
1620 void *visit(MUL_operator_c *symbol) { |
1638 void *visit(MUL_operator_c *symbol) { |
1621 if (get_datatype_info_c::is_TIME_compatible(symbol->datatype)) |
1639 if (get_datatype_info_c::is_TIME_compatible(symbol->datatype)) |
1622 XXX_function(&(this->implicit_variable_result), "__time_mul", &(this->implicit_variable_current), this->current_operand); |
1640 XXX_function(&(this->implicit_variable_result), "__time_mul", &(this->implicit_variable_current), this->current_operand); |
1623 else XXX_operator(&(this->implicit_variable_result), " *= ", this->current_operand); |
1641 else XXX_operator(&(this->implicit_variable_result), " *= ", this->current_operand); |
1624 return NULL; |
1642 return NULL; |
1625 } |
1643 } |
1626 |
1644 |
1627 void *visit(DIV_operator_c *symbol) { |
1645 void *visit(DIV_operator_c *symbol) { |
1628 if (get_datatype_info_c::is_TIME_compatible(symbol->datatype)) |
1646 if (get_datatype_info_c::is_TIME_compatible(symbol->datatype)) |
1629 XXX_function(&(this->implicit_variable_result), "__time_div", &(this->implicit_variable_current), this->current_operand); |
1647 XXX_function(&(this->implicit_variable_result), "__time_div", &(this->implicit_variable_current), this->current_operand); |
1630 else XXX_operator(&(this->implicit_variable_result), " /= ", this->current_operand); |
1648 else XXX_operator(&(this->implicit_variable_result), " /= ", this->current_operand); |
1631 return NULL; |
1649 return NULL; |
1632 } |
1650 } |
1683 s4o.print("goto ");s4o.print(END_LABEL); |
1701 s4o.print("goto ");s4o.print(END_LABEL); |
1684 return NULL; |
1702 return NULL; |
1685 } |
1703 } |
1686 |
1704 |
1687 //SYM_REF0(JMP_operator_c) |
1705 //SYM_REF0(JMP_operator_c) |
1688 void *visit(JMP_operator_c *symbol) { |
1706 void *visit(JMP_operator_c *symbol) { |
1689 if (NULL == this->jump_label) ERROR; |
1707 if (NULL == this->jump_label) ERROR; |
1690 s4o.print("goto "); |
1708 s4o.print("goto "); |
1691 this->jump_label->accept(*this); |
1709 this->jump_label->accept(*this); |
1692 return NULL; |
1710 return NULL; |
1693 } |
1711 } |
1694 |
1712 |
1695 // SYM_REF0(JMPC_operator_c) |
1713 // SYM_REF0(JMPC_operator_c) |
1696 void *visit(JMPC_operator_c *symbol) { |
1714 void *visit(JMPC_operator_c *symbol) { |
1697 if (NULL == this->jump_label) ERROR; |
1715 if (NULL == this->jump_label) ERROR; |
1698 C_modifier(); |
1716 C_modifier(); |
1699 s4o.print("goto "); |
1717 s4o.print("goto "); |
1700 this->jump_label->accept(*this); |
1718 this->jump_label->accept(*this); |
1701 return NULL; |
1719 return NULL; |
1702 } |
1720 } |
1703 |
1721 |
1704 // SYM_REF0(JMPCN_operator_c) |
1722 // SYM_REF0(JMPCN_operator_c) |
1705 void *visit(JMPCN_operator_c *symbol) { |
1723 void *visit(JMPCN_operator_c *symbol) { |
1706 if (NULL == this->jump_label) ERROR; |
1724 if (NULL == this->jump_label) ERROR; |
1707 CN_modifier(); |
1725 CN_modifier(); |
1708 s4o.print("goto "); |
1726 s4o.print("goto "); |
1709 this->jump_label->accept(*this); |
1727 this->jump_label->accept(*this); |
1710 return NULL; |
1728 return NULL; |