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
Class libraries for software components #22
Comments
Hi, Feel free to propose an incremental patch series that do so. Regards, On Mon, Sep 15, 2014 at 1:24 PM, Markus Elfring notifications@github.com
Nicolas Palix |
Would you like to help in the identification of software components for which it will be more useful to develop class libraries than other source code places? |
Start with the parts you want to reuse. On Mon, Sep 15, 2014 at 1:34 PM, Markus Elfring notifications@github.com
Nicolas Palix |
Note also that making a class is only useful when you want multiple julia On Mon, 15 Sep 2014, Nicolas Palix wrote:
|
Classes are also useful to model specific interfaces where their usage frequency is lower. I am curious how your acceptance will evolve for object-oriented software development together with the programming language "OCaml". |
This allows the SmPL and C ASTs to better match up, which enables more transformations. The patch is very large, so I have left the different messages as they were proposed in the original patch series. This is the 1st commit message: parsing_cocci: Add Function Prototype token To add the types ParenType and FunctionType to the SmPL AST, a reduce/reduce conflict with the funproto rule of the SmPL parser must be resolved. This requires explicitly identifying a function prototype by use of a token (TFunProto). While the correct method of identifying a function prototype would be to check if an identifier is preceded by a return type, it is challenging to implement. This is because implementing an OCaml function, to correctly determine a C type in SmPL, without the aid of Yacc, would have to handle a number of cases (disjunctions, typeof expressions, etc.). Thus, a slightly hacky approach is taken to determine a function prototype with not the best certainty but what works for most cases in SmPL. If the identifier is preceded by any token that does not seem to be part of a type, then it is not identified as a function prototype. Else, it is. This is the commit message coccinelle#2: parsing_cocci: AST: Add ParenType and FunctionType to SmPL ASTs ParenType and FunctionType are types present in the C AST that are not present in the SmPL AST. In the pursuit of aligning both the C and SmPL ASTs, add these types to the SmPL ASTs. For a function pointer as follows: int (*x)(params) The SmPL AST would be as follows: ParenType -> Pointer -> FunctionType params -> BaseType int For an array of function pointers as follows: int (*x[2])(params) The SmPL AST would be as follows: ParenType -> Array 2 -> Pointer -> FunctionType params -> BaseType int This is the commit message coccinelle#3: parsing_cocci: visitor_ast0: Add cases for ParenType/FunctionType The order of the terms in ParenType require implementing a special case for ParenType. This case handles only the following: <type> ( * id [ .* ] ) ( params ) i.e., a function pointer or an array of function pointers, and will fail for any other cases. This is similar to the function used to print ParenType in Pretty_print_c. This is the commit message coccinelle#4: parsing_cocci: visitor_ast: Add cases for ParenType/FunctionType The order of the terms in ParenType require implementing a special case for ParenType. This case handles only the following: <type> ( * id [ .* ] ) ( params ) i.e., a function pointer or an array of function pointers, and will fail for any other cases. This is similar to the function used to print ParenType in Pretty_print_c. This is the commit message coccinelle#5: parsing_cocci: arity: Add cases for ParenType/FunctionType ParenType and FunctionType are added to the SmPL ASTs. Add cases for these types in arity.ml. This is the commit message coccinelle#6: parsing_cocci: parser: Add direct_declarator/direct_abstract_d rules The direct_declarator rule and the direct_abstract_d rule are present in the C parser. Add similar rules to the SmPL parser so that declarators are parsed as they are in the C parser. For the type ParenType, direct_declarator and direct_abstract_d only allow the following productions: ( * id [ .* ] ) ( params ) i.e. a function pointer or an array of function pointers. The compromise is flexibility in the range of productions, mainly because collateral evolutions needed by having a flexible rule are very large and distasteful. Examples of productions that are not supported are as follows: - int (*x[][])(params) An array of arrays of function pointers - int (**x[])(params) An array of pointers to function pointers - int ((*x))(params) The first two can be supported by implementing a loop of some kind to check for array of array of ... and pointer to pointer to ... Replace usage of the older d_ident rule in the SmPL parser with the above mentioned rules. All usages of d_ident, however, have not been removed due to reduce/reduce conflicts. Remove rules/productions that parse function pointers with usage of direct_declarator and direct_abstract_d. This is the commit message coccinelle#7: parsing_cocci: index: Add cases for ParenType/FunctionType ParenType and FunctionType are now added to the SmPL ASTs. Add cases for these types in index.ml. This is the commit message coccinelle#8: parsing_cocci: context_neg: Add cases for ParenType/FunctionType ParenType and FunctionType are now added to the SmPL ASTs. Add cases for these types in context_neg.ml. This is the commit message coccinelle#9: parsing_cocci: unparse_ast0: Add cases for ParenType/FunctionType ParenType/FunctionType are now types in the SmPL ASTs. Add cases for these types in unparse_ast0.ml. This is the commit message coccinelle#10: parsing_cocci: single_statement: Add cases for ParenType/FunctionType ParenType/FunctionType are now types in the SmPL ASTs. Add cases for these types in single_statement.ml. This is the commit message coccinelle#11: parsing_cocci: function_prototypes: Add cases for ParenType/FunctionType ParenType and FunctionType are now added to the SmPL ASTs. Add cases for these types in function_prototypes.ml. This is the commit message coccinelle#12: parsing_cocci: check_meta: Add cases for ParenType/FunctionType ParenType and FunctionType are now added to the SmPL ASTs. Add cases for these types in check_meta.ml. This is the commit message coccinelle#13: parsing_cocci: iso_pattern: Add cases for ParenType/FunctionType ParenType and FunctionType are now added to the SmPL ASTs. Add cases for these types in iso_pattern.ml. This is the commit message coccinelle#14: parsing_cocci: adjust_pragmas: Add cases for ParenType/FunctionType ParenType and FunctionType are now added to the SmPL ASTs. Add cases for these types in adjust_pragmas.ml. This is the commit message coccinelle#15: parsing_cocci: compute_lines: Add cases for ParenType/FunctionType ParenType and FunctionType are now added to the SmPL ASTs. Add cases for these types in compute_lines.ml. This is the commit message coccinelle#16: parsing_cocci: ast0toast: Add cases for ParenType/FunctionType ParenType and FunctionType are now added to the SmPL ASTs. Add cases for these types in ast0toast.ml. This is the commit message coccinelle#17: parsing_cocci: type_cocci: Add ParenType/FunctionType to types ParenType and FunctionType are now added to the SmPL ASTs. Add cases for these types in type_cocci.ml. This is the commit message coccinelle#18: parsing_cocci: unify_ast: Add cases for ParenType/FunctionType ParenType and FunctionType are now added to the SmPL ASTs. Add cases for these types in unify_ast.ml. This is the commit message coccinelle#19: parsing_cocci: disjdistr: Add cases for ParenType/FunctionType ParenType and FunctionType are now added to the SmPL ASTs. Add cases for these types in disjdistr.ml. This is the commit message coccinelle#20: parsing_cocci: ast_cocci: Add cases for ParenType/FunctionType ParenType and FunctionType are now added to the SmPL ASTs. Add cases for these types in ast_cocci.ml. This is the commit message coccinelle#21: parsing_cocci: pretty_print_cocci: Print ParenType/FunctionType The order of the terms in ParenType require implementing a special case for ParenType. This case handles only the following: <type> ( * id [ .* ] ) ( params ) i.e., a function pointer or an array of function pointers, and will fail for any other cases. This is similar to the function used to print ParenType in Pretty_print_c. This is the commit message coccinelle#22: parsing_c: unparse_cocci: Print ParenType/FunctionType The order of the terms in ParenType require implementing a special case for ParenType. This case handles only the following: <type> ( * id [ .* ] ) ( params ) i.e., a function pointer or an array of function pointers, and will fail for any other cases. This is similar to the function used to print ParenType in Pretty_print_c. This is the commit message coccinelle#23: engine: Match A.ParenType and A.FunctionType ParenType and FunctionType are added to the SmPL AST as types. Match these types correctly. This is the commit message coccinelle#24: tools: spgen: Add cases for ParenType/FunctionType ParenType and FunctionType are now added to the SmPL ASTs. Add cases for these types in position_generator.ml. This is the commit message coccinelle#25: cocci: Remove Ast_cocci.FunctionPointer ParenType and FunctionType are now in the SmPL AST, and these types have replaced all productions related to the FunctionPointer type in the SmPL parser. Remove FunctionPointer from the SmPL ASTs, its cases and any functions or constructs related to it from the codebase. This is the commit message coccinelle#26: tests: Add test case for array of function pointers Add a test case to match against an array of function pointers. This would previously not work due to differences in the C and SmPL ASTs. Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com> Reviewed-by: Julia Lawall <Julia.Lawall@inria.fr>
This allows the SmPL and C ASTs to better match up, which enables more transformations. The patch is very large, so I have left the different messages as they were proposed in the original patch series. This is the 1st commit message: parsing_cocci: Add Function Prototype token To add the types ParenType and FunctionType to the SmPL AST, a reduce/reduce conflict with the funproto rule of the SmPL parser must be resolved. This requires explicitly identifying a function prototype by use of a token (TFunProto). While the correct method of identifying a function prototype would be to check if an identifier is preceded by a return type, it is challenging to implement. This is because implementing an OCaml function, to correctly determine a C type in SmPL, without the aid of Yacc, would have to handle a number of cases (disjunctions, typeof expressions, etc.). Thus, a slightly hacky approach is taken to determine a function prototype with not the best certainty but what works for most cases in SmPL. If the identifier is preceded by any token that does not seem to be part of a type, then it is not identified as a function prototype. Else, it is. This is the commit message #2: parsing_cocci: AST: Add ParenType and FunctionType to SmPL ASTs ParenType and FunctionType are types present in the C AST that are not present in the SmPL AST. In the pursuit of aligning both the C and SmPL ASTs, add these types to the SmPL ASTs. For a function pointer as follows: int (*x)(params) The SmPL AST would be as follows: ParenType -> Pointer -> FunctionType params -> BaseType int For an array of function pointers as follows: int (*x[2])(params) The SmPL AST would be as follows: ParenType -> Array 2 -> Pointer -> FunctionType params -> BaseType int This is the commit message #3: parsing_cocci: visitor_ast0: Add cases for ParenType/FunctionType The order of the terms in ParenType require implementing a special case for ParenType. This case handles only the following: <type> ( * id [ .* ] ) ( params ) i.e., a function pointer or an array of function pointers, and will fail for any other cases. This is similar to the function used to print ParenType in Pretty_print_c. This is the commit message #4: parsing_cocci: visitor_ast: Add cases for ParenType/FunctionType The order of the terms in ParenType require implementing a special case for ParenType. This case handles only the following: <type> ( * id [ .* ] ) ( params ) i.e., a function pointer or an array of function pointers, and will fail for any other cases. This is similar to the function used to print ParenType in Pretty_print_c. This is the commit message #5: parsing_cocci: arity: Add cases for ParenType/FunctionType ParenType and FunctionType are added to the SmPL ASTs. Add cases for these types in arity.ml. This is the commit message #6: parsing_cocci: parser: Add direct_declarator/direct_abstract_d rules The direct_declarator rule and the direct_abstract_d rule are present in the C parser. Add similar rules to the SmPL parser so that declarators are parsed as they are in the C parser. For the type ParenType, direct_declarator and direct_abstract_d only allow the following productions: ( * id [ .* ] ) ( params ) i.e. a function pointer or an array of function pointers. The compromise is flexibility in the range of productions, mainly because collateral evolutions needed by having a flexible rule are very large and distasteful. Examples of productions that are not supported are as follows: - int (*x[][])(params) An array of arrays of function pointers - int (**x[])(params) An array of pointers to function pointers - int ((*x))(params) The first two can be supported by implementing a loop of some kind to check for array of array of ... and pointer to pointer to ... Replace usage of the older d_ident rule in the SmPL parser with the above mentioned rules. All usages of d_ident, however, have not been removed due to reduce/reduce conflicts. Remove rules/productions that parse function pointers with usage of direct_declarator and direct_abstract_d. This is the commit message #7: parsing_cocci: index: Add cases for ParenType/FunctionType ParenType and FunctionType are now added to the SmPL ASTs. Add cases for these types in index.ml. This is the commit message #8: parsing_cocci: context_neg: Add cases for ParenType/FunctionType ParenType and FunctionType are now added to the SmPL ASTs. Add cases for these types in context_neg.ml. This is the commit message #9: parsing_cocci: unparse_ast0: Add cases for ParenType/FunctionType ParenType/FunctionType are now types in the SmPL ASTs. Add cases for these types in unparse_ast0.ml. This is the commit message #10: parsing_cocci: single_statement: Add cases for ParenType/FunctionType ParenType/FunctionType are now types in the SmPL ASTs. Add cases for these types in single_statement.ml. This is the commit message #11: parsing_cocci: function_prototypes: Add cases for ParenType/FunctionType ParenType and FunctionType are now added to the SmPL ASTs. Add cases for these types in function_prototypes.ml. This is the commit message #12: parsing_cocci: check_meta: Add cases for ParenType/FunctionType ParenType and FunctionType are now added to the SmPL ASTs. Add cases for these types in check_meta.ml. This is the commit message #13: parsing_cocci: iso_pattern: Add cases for ParenType/FunctionType ParenType and FunctionType are now added to the SmPL ASTs. Add cases for these types in iso_pattern.ml. This is the commit message #14: parsing_cocci: adjust_pragmas: Add cases for ParenType/FunctionType ParenType and FunctionType are now added to the SmPL ASTs. Add cases for these types in adjust_pragmas.ml. This is the commit message #15: parsing_cocci: compute_lines: Add cases for ParenType/FunctionType ParenType and FunctionType are now added to the SmPL ASTs. Add cases for these types in compute_lines.ml. This is the commit message #16: parsing_cocci: ast0toast: Add cases for ParenType/FunctionType ParenType and FunctionType are now added to the SmPL ASTs. Add cases for these types in ast0toast.ml. This is the commit message #17: parsing_cocci: type_cocci: Add ParenType/FunctionType to types ParenType and FunctionType are now added to the SmPL ASTs. Add cases for these types in type_cocci.ml. This is the commit message #18: parsing_cocci: unify_ast: Add cases for ParenType/FunctionType ParenType and FunctionType are now added to the SmPL ASTs. Add cases for these types in unify_ast.ml. This is the commit message #19: parsing_cocci: disjdistr: Add cases for ParenType/FunctionType ParenType and FunctionType are now added to the SmPL ASTs. Add cases for these types in disjdistr.ml. This is the commit message #20: parsing_cocci: ast_cocci: Add cases for ParenType/FunctionType ParenType and FunctionType are now added to the SmPL ASTs. Add cases for these types in ast_cocci.ml. This is the commit message #21: parsing_cocci: pretty_print_cocci: Print ParenType/FunctionType The order of the terms in ParenType require implementing a special case for ParenType. This case handles only the following: <type> ( * id [ .* ] ) ( params ) i.e., a function pointer or an array of function pointers, and will fail for any other cases. This is similar to the function used to print ParenType in Pretty_print_c. This is the commit message #22: parsing_c: unparse_cocci: Print ParenType/FunctionType The order of the terms in ParenType require implementing a special case for ParenType. This case handles only the following: <type> ( * id [ .* ] ) ( params ) i.e., a function pointer or an array of function pointers, and will fail for any other cases. This is similar to the function used to print ParenType in Pretty_print_c. This is the commit message #23: engine: Match A.ParenType and A.FunctionType ParenType and FunctionType are added to the SmPL AST as types. Match these types correctly. This is the commit message #24: tools: spgen: Add cases for ParenType/FunctionType ParenType and FunctionType are now added to the SmPL ASTs. Add cases for these types in position_generator.ml. This is the commit message #25: cocci: Remove Ast_cocci.FunctionPointer ParenType and FunctionType are now in the SmPL AST, and these types have replaced all productions related to the FunctionPointer type in the SmPL parser. Remove FunctionPointer from the SmPL ASTs, its cases and any functions or constructs related to it from the codebase. This is the commit message #26: tests: Add test case for array of function pointers Add a test case to match against an array of function pointers. This would previously not work due to differences in the C and SmPL ASTs. Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com> Reviewed-by: Julia Lawall <Julia.Lawall@inria.fr>
This is a combination of 28 commits. This is the 1st commit message: cocci: Add parameter attributes to C AST With extended support of attributes, parameter attributes are needed in the C AST so that the nocast test case does not break. Add the p_attr field to parameter in the C AST. Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com> This is the commit message #2: parsing_c: parser: Place parameter attributes in C AST Parameter attributes are needed so as to not break the nocast test case when attributes are fully supported. Add parameter attributes to the C AST. Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com> This is the commit message #3: parsing_c: visitor_c: Visit parameter attributes As attributes are added to the parameter type, have the C AST visitor visit these attributes as well. Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com> This is the commit message #4: parsing_c: unparse_hrule: Add parameter attributes in record Parameter attributes are added to the C AST. Initialize the parameter attributes field as empty in a case in unparse_hrule.ml. Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com> This is the commit message #5: parsing_c: type_c: Add parameter attributes to record Paramter attributes are added to the C AST. Reflect this change in a case in type_c.ml. Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com> This is the commit message #6: engine: cocci_vs_c: "Match" parameter attributes Parameter attributes are added to the C AST, but not to the SmPL AST. Once parameter attributes are added to SmPL as well, they can actually be matched, but for now a call to attribute_list is required to correctly remove attributes. Attributes from a parameter are removed when the whole parameter is removed, replaced or otherwise. Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com> This is the commit message #7: parsing_cocci: ast0_cocci: Add parameter attributes Add parameter attributes to AST0 of SmPL. This is a list of attributes in the VoidParam and Param types of AST0. Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com> This is the commit message #8: parsing_cocci: parser: Parse Parameter attributes Parameter attributes are added to the SmPL AST. Parse these attributes correctly in the SmPL parser. The added production only supports attributes after the type or the type and identifier. Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com> This is the commit message #9: parsing_cocci: visitor_ast0: Visit Parameter attributes Parameter attributes are added to AST0 of SmPL. Visit these attributes in the AST0 visitor. Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com> This is the commit message #10: parsing_cocci: arity: Reflect Parameter attributes Parameter attributes are added to the SmPL AST. Reflect these changes in arity.ml. Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com> This is the commit message #11: parsing_cocci: check_meta: Reflect Parameter attributes Parameter attributes are added to the SmPL AST. Reflect these changes in check_meta.ml. Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com> This is the commit message #12: parsing_cocci: compute_lines: Reflect Parameter attributes Parameter attributes are added to the SmPL AST. Reflect these changes in compute_lines.ml. Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com> This is the commit message #13: parsing_cocci: context_neg: Reflect Parameter attributes Parameter attributes are added to the SmPL AST. Reflect these changes in context_neg.ml. Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com> This is the commit message #14: parsing_cocci: function_prototypes: Reflect Parameter attributes Parameter attributes are added to the SmPL AST. Reflect these changes in function_prototypes.ml. Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com> This is the commit message #15: parsing_cocci: index: Reflect Parameter attributes Parameter attributes are added to the SmPL AST. Reflect these changes in index.ml. Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com> This is the commit message #16: parsing_cocci: iso_pattern: Reflect Parameter attributes Parameter attributes are added to the SmPL AST. Reflect these changes in iso_pattern.ml. Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com> This is the commit message #17: parsing_cocci: type_infer: Reflect Parameter attributes Parameter attributes are added to the SmPL AST. Reflect these changes in type_infer.ml. Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com> This is the commit message #18: parsing_cocci: unparse_ast0: Reflect Parameter attributes Parameter attributes are added to the SmPL AST. Reflect these changes in unparse_ast0.ml. Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com> This is the commit message #19: parsing_c: unparse_cocci: Reflect Parameter attributes Parameter attributes are added to the SmPL AST. Print these attributes correctly in unparse_cocci.ml. Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com> This is the commit message #20: parsing_cocci: ast_cocci: Add Parameter attributes Add parameter attributes to the SmPL AST. This is a list of attributes in the VoidParam and Param types of the SmPL AST. Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com> This is the commit message #21: parsing_cocci: visitor_ast: Visit Parameter attributes Parameter attributes are added to the SmPL AST. Visit these attributes in the AST visitor. Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com> This is the commit message #22: parsing_cocci: ast0toast: Reflect Parameter attributes Parameter attributes are added to the SmPL AST. Reflect these changes in ast0toast.ml. Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com> This is the commit message #23: parsing_cocci: disjdistr: Reflect Parameter attributes Parameter attributes are added to the SmPL AST. Reflect these changes in disjdistr.ml. Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com> This is the commit message #24: parsing_cocci: pretty_print_cocci: Reflect Parameter attributes Parameter attributes are added to the SmPL AST. Print these attributes correctly in pretty_print_cocci.ml. Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com> This is the commit message #25: parsing_cocci: unify_ast: Reflect Parameter attributes Parameter attributes are added to the SmPL AST. Reflect these changes in unify_ast.ml. Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com> This is the commit message #26: engine: cocci_vs_c: Match Parameter attributes Parameter attributes are added to the C and SmPL AST. Match the attributes correctly in cocci_vs_c.ml. Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com> This is the commit message #27: ocaml: coccilib: Reflect Parameter attributes Parameter attributes are added to the SmPL AST. Reflect these changes in coccilib.mli. Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com> This is the commit message #28: engine: c_vs_c: Match parameter attributes Parameter attributes are added to the C AST. Add an expression to check if attributes are equal on both sides to the parameter case in c_vs_c. Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
How do you see the chances to transform parts from your software into reusable class libraries?
The text was updated successfully, but these errors were encountered: