-
Notifications
You must be signed in to change notification settings - Fork 40
Initial addition of CONSTANT SECTION #278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: gitside-gnucobol-3.x
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1869,6 +1869,7 @@ struct cb_program { | |
| struct cb_field *linkage_storage; /* LINKAGE */ | ||
| struct cb_field *screen_storage; /* SCREEN */ | ||
| struct cb_field *report_storage; /* REPORT */ | ||
| struct cb_field *constant_storage; /* CONSTANT */ | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that is the right thing to add - but you'd have to add the fields to that as well and then "read" the fields from there later on (have a look how that is done with working_storage)
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This I'm not exactly sure what should be added. I thought this is mainly for building the AST so I'm not particularly sure what is missing
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When producing AST we have a "current storage" where fields are added to (a linked list of 01/77 fields) - I think while the current_storage is setup correctly, the assignment to add fields to that list isn't. When you add the new storage to those two places, you'll likely see that they are "empty". |
||
| cb_tree local_file_list; /* Local files */ | ||
| cb_tree global_file_list; /* Global files */ | ||
| struct handler_struct global_handler[5]; /* Global handlers */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1752,6 +1752,9 @@ cb_build_generic_register (const char *name, const char *external_definition, | |
| } | ||
|
|
||
| if (current_program) { | ||
| if (field->storage == CB_STORAGE_CONSTANT) { | ||
| CB_FIELD_ADD(current_program->constant_storage, field); | ||
| } | ||
| if (field->storage == CB_STORAGE_LINKAGE) { | ||
| CB_FIELD_ADD (current_program->linkage_storage, field); | ||
| } else | ||
|
|
@@ -5076,6 +5079,10 @@ cb_validate_program_data (struct cb_program *prog) | |
| } | ||
| } | ||
| } | ||
|
|
||
| if (prog->constant_storage) { | ||
| CB_UNFINISHED ("CONSTANT SECTION code generation"); | ||
| } | ||
| } | ||
|
|
||
|
|
||
|
|
@@ -6157,7 +6164,7 @@ enum_explain_storage (const enum cb_storage storage) | |
| { | ||
| switch (storage) { | ||
| case CB_STORAGE_CONSTANT: | ||
| return "Constants"; | ||
| return "CONSTANT SECTION"; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Constants may should be lower-cased (not sure), but CONSTANT SECTION is wrong here as other constants have the same storage but are not "living" in that section |
||
| case CB_STORAGE_FILE: | ||
| return "FILE SECTION"; | ||
| case CB_STORAGE_WORKING: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2947,3 +2947,26 @@ AT_DATA([prog.cob], [ | |
|
|
||
| AT_CHECK([$COMPILE_ONLY -Wno-unfinished prog.cob], [0], [], []) | ||
| AT_CLEANUP | ||
|
|
||
|
|
||
| AT_SETUP([CONSTANT SECTION syntax]) | ||
| AT_KEYWORDS([extension constant VALUE]) | ||
|
|
||
| AT_DATA([prog.cob],[ | ||
| IDENTIFICATION DIVISION. | ||
| PROGRAM-ID. prog. | ||
| DATA DIVISION. | ||
| CONSTANT SECTION. | ||
| 01 NUM-CONST PIC 9(3). | ||
| 01 OTHER-CONST PIC 9(3) VALUE 123. | ||
| PROCEDURE DIVISION. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please add a third constant with a constant record |
||
| STOP RUN. | ||
|
|
||
| ]) | ||
|
|
||
| AT_CHECK([$COMPILE_ONLY prog.cob], [1], [], | ||
| [prog.cob:6: error: item in CONSTANT SECTION must have a VALUE clause | ||
| prog.cob:7: warning: handling of CONSTANT SECTION code generation is unfinished; implementation is likely to be changed | ||
| ]) | ||
| AT_CLEANUP | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -752,3 +752,46 @@ prog.cob:7: note: 'BIGFLT' defined here as USAGE FLOAT | |
|
|
||
| AT_CLEANUP | ||
|
|
||
|
|
||
| AT_SETUP([MOVE to CONSTANT SECTION item]) | ||
| AT_KEYWORDS([extension constant move]) | ||
|
|
||
| # To be implemented. | ||
| AT_XFAIL_IF([true]) | ||
|
|
||
| AT_DATA([prog.cob],[ | ||
| IDENTIFICATION DIVISION. | ||
| PROGRAM-ID. prog. | ||
| DATA DIVISION. | ||
| CONSTANT SECTION. | ||
| 01 NUM-CONST PIC 9(3) VALUE 123. | ||
| PROCEDURE DIVISION. | ||
| MOVE 456 TO NUM-CONST. | ||
| STOP RUN. | ||
| ]) | ||
|
|
||
| AT_CHECK([$COMPILE prog.cob], [1], [],[ignore]) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you may add -Wno-unfinished to the command line - please add the expected error into stderr instead of ignore (see tests above how to split the AT_CHECK into multiple lines for that |
||
| AT_CLEANUP | ||
|
|
||
|
|
||
| AT_SETUP([MOVE CONSTANT SECTION to field]) | ||
| AT_KEYWORDS([extension constant move]) | ||
|
|
||
| AT_XFAIL_IF([true]) | ||
|
|
||
| AT_DATA([prog.cob],[ | ||
| IDENTIFICATION DIVISION. | ||
| PROGRAM-ID. prog. | ||
| DATA DIVISION. | ||
| CONSTANT SECTION. | ||
| 01 MY-CONST PIC 9(3) VALUE 123. | ||
| WORKING-STORAGE SECTION. | ||
| 01 RESULT-FLD PIC 9(3). | ||
| PROCEDURE DIVISION. | ||
| MOVE MY-CONST TO RESULT-FLD. | ||
| DISPLAY RESULT-FLD. | ||
| STOP RUN. | ||
| ]) | ||
| # This is also not implemented yet but should help towards the bigger issue with CONSTANTs being replaced by literals | ||
| AT_CHECK([$COMPILE prog.cob], [0], [], []) | ||
| AT_CLEANUP | ||
|
Comment on lines
+777
to
+797
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this test should be moved to run_extensions (with -Wno-unfinished in the compilation) and should include testing the actual result (which I guess will be fine); |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please start with a newline (that helps with a bunch of diff algrothms for some reason)