/ * codegen_class: Generate code for a single class. */
| 757 | * codegen_class: Generate code for a single class. |
| 758 | */ |
| 759 | void codegen_class(class_type c) |
| 760 | { |
| 761 | list_type p, m, cv; |
| 762 | long temppos, endpos, messagepos, propertypos; |
| 763 | int nummessages, i; |
| 764 | |
| 765 | /* Write out superclass class id */ |
| 766 | if (c->superclass == NULL) |
| 767 | OutputInt(outfile, NO_SUPERCLASS); |
| 768 | else OutputInt(outfile, c->superclass->class_id->idnum); |
| 769 | |
| 770 | /* Save current file position for backpatching */ |
| 771 | propertypos = FileCurPos(outfile); |
| 772 | OutputInt(outfile, 0); /* Set aside space for property table offset */ |
| 773 | temppos = FileCurPos(outfile); |
| 774 | OutputInt(outfile, 0); /* Set aside space for message dispatch table offset */ |
| 775 | |
| 776 | /****** Classvar table ******/ |
| 777 | // TOTAL # of classvars for this class |
| 778 | OutputInt(outfile, c->numclassvars); |
| 779 | // # of classvars for which we have default values |
| 780 | OutputInt(outfile, list_length(c->classvars)); |
| 781 | |
| 782 | /* Write out values of classvars with default values */ |
| 783 | for (cv = c->classvars; cv != NULL; cv = cv->next) |
| 784 | codegen_classvar( (classvar_type) cv->data); |
| 785 | |
| 786 | |
| 787 | /* Go back and fill in position of property table */ |
| 788 | endpos = FileCurPos(outfile); |
| 789 | FileGoto(outfile, propertypos); |
| 790 | OutputInt(outfile, endpos); |
| 791 | FileGotoEnd(outfile); |
| 792 | |
| 793 | /****** Property table ******/ |
| 794 | // TOTAL # of properties for this class |
| 795 | OutputInt(outfile, c->numproperties); |
| 796 | // # of properties for which we have default values |
| 797 | OutputInt(outfile, list_length(c->properties)); |
| 798 | |
| 799 | /* Write out values of properties with default values */ |
| 800 | for (p = c->properties; p != NULL; p = p->next) |
| 801 | codegen_property( (property_type) p->data); |
| 802 | |
| 803 | |
| 804 | /* Go back and fill in position of message dispatch table */ |
| 805 | endpos = FileCurPos(outfile); |
| 806 | FileGoto(outfile, temppos); |
| 807 | OutputInt(outfile, endpos); |
| 808 | FileGotoEnd(outfile); |
| 809 | |
| 810 | /* Write out # of message handlers */ |
| 811 | nummessages = list_length(c->messages); |
| 812 | OutputInt(outfile, nummessages); |
| 813 | |
| 814 | /* Save away position of message dispatch table */ |
| 815 | messagepos = FileCurPos(outfile); |
| 816 |
no test coverage detected