-
Notifications
You must be signed in to change notification settings - Fork 38
Improve CobolFieldAttribute variable names #775
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: develop
Are you sure you want to change the base?
Improve CobolFieldAttribute variable names #775
Conversation
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.
Pull request overview
This pull request enhances code generation by adding descriptive suffixes to attribute variable names in generated Java code. The suffixes encode type information, digits, scale, and flags, making the generated code more readable and self-documenting (e.g., a_1_NumericDisplay_Digits9_Scale2_HaveSign).
Key changes:
- Added suffix generation infrastructure with
build_attr_suffix()andlookup_attr_suffix()functions that create descriptive suffixes based on attribute properties - Updated attribute struct to store the generated suffix
- Modified all attribute variable references throughout code generation to append the suffix
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@h-himo @n-isaka COBOLコード 01 NUM-1 PIC 9(02).
01 NUM-2 PIC S9(02) SIGN IS TRAILING SEPARATE.
01 NUM-3 PIC S9(02)V9(3) COMP-3.
01 NUM-4 PIC S9(02)VP(3) COMP-3.
01 STR-1 PIC X(5).
01 STR-2 PIC X(5) JUSTIFIED RIGHT.従来のコード。 a_1 = new CobolFieldAttribute (16, 2, 0, 7, null);
a_2 = new CobolFieldAttribute (18, 5, 3, 1, null);
a_3 = new CobolFieldAttribute (18, 5, -3, 1, null);
a_4 = new CobolFieldAttribute (16, 2, 0, 0, null);
a_5 = new CobolFieldAttribute (33, 0, 0, 0, null);
a_6 = new CobolFieldAttribute (33, 0, 0, 16, null);改修後の生成コード。 // 文の順番はコンパイラの都合による順番で、COBOLソース上の宣言順ではない
// NUM-2
a_1_NumericDisplay_Digits2_Scale0_HaveSign_SignSeparate_SignLeading = new CobolFieldAttribute(
CobolFieldAttribute.COB_TYPE_NUMERIC_DISPLAY,
/* digits= */ 2,
/* scale= */ 0,
CobolFieldAttribute.COB_FLAG_HAVE_SIGN
| CobolFieldAttribute.COB_FLAG_SIGN_SEPARATE
| CobolFieldAttribute.COB_FLAG_SIGN_LEADING,
/* pic= */ null);
// NUM-3
a_2_NumericPacked_Digits5_Scale3_HaveSign = new CobolFieldAttribute(
CobolFieldAttribute.COB_TYPE_NUMERIC_PACKED,
/* digits= */ 5,
/* scale= */ 3,
CobolFieldAttribute.COB_FLAG_HAVE_SIGN,
/* pic= */ null);
// NUM-4
a_3_NumericPacked_Digits5_ScaleNeg3_HaveSign = new CobolFieldAttribute(
CobolFieldAttribute.COB_TYPE_NUMERIC_PACKED,
/* digits= */ 5,
/* scale= */ -3,
CobolFieldAttribute.COB_FLAG_HAVE_SIGN,
/* pic= */ null);
// NUM-1
a_4_NumericDisplay_Digits2_Scale0 = new CobolFieldAttribute(
CobolFieldAttribute.COB_TYPE_NUMERIC_DISPLAY,
/* digits= */ 2,
/* scale= */ 0,
CobolFieldAttribute.COB_FLAG_NOT_SPECIFIED,
/* pic= */ null);
// STR-1
a_5_Alphanumeric = new CobolFieldAttribute(
CobolFieldAttribute.COB_TYPE_ALPHANUMERIC,
/* digits= */ 0,
/* scale= */ 0,
CobolFieldAttribute.COB_FLAG_NOT_SPECIFIED,
/* pic= */ null);
// STR-2
a_6_Alphanumeric_Justified = new CobolFieldAttribute(
CobolFieldAttribute.COB_TYPE_ALPHANUMERIC,
/* digits= */ 0,
/* scale= */ 0,
CobolFieldAttribute.COB_FLAG_JUSTIFIED,
/* pic= */ null);変数の命名規則は以下の通りです PIC 9等の数値系のもの
PIC X等の文字列系のもの
|
This pull request enhances the code generation process by introducing descriptive suffixes to attribute variable names based on their type and properties. This makes generated code more readable and helps distinguish between different attribute configurations. This PR will resolve #758 completely.
Key changes include:
Attribute Suffix Generation and Usage:
suffixfield to theattr_liststruct and logic to generate a descriptive suffix for each attribute based on its type, digits, scale, and flags. This is handled by the newbuild_attr_suffixandget_type_short_namefunctions. [1] [2]Supporting Infrastructure:
These changes improve code clarity and maintainability by making attribute variables self-descriptive and reducing the risk of naming collisions.