Skip to content

Commit

Permalink
Pseudocode: Give library function calls a different color. (#1111)
Browse files Browse the repository at this point in the history
  • Loading branch information
ltfish authored Nov 2, 2023
1 parent 6007171 commit 7dfa4bd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions angrmanagement/config/color_schemes.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"feature_map_string_color": QColor(0x00, 0xF0, 0x80),
"pseudocode_comment_color": QColor(0x00, 0x80, 0x00, 0xFF),
"pseudocode_function_color": QColor(0x00, 0x00, 0xFF, 0xFF),
"pseudocode_library_function_color": QColor(0xFF, 0x00, 0xFF),
"pseudocode_quotation_color": QColor(0x00, 0x80, 0x00, 0xFF),
"pseudocode_keyword_color": QColor(0x00, 0x00, 0x80, 0xFF),
"pseudocode_types_color": QColor(0x10, 0x78, 0x96),
Expand Down Expand Up @@ -179,6 +180,7 @@
"feature_map_string_color": QColor(0x00, 0xF0, 0x80),
"pseudocode_comment_color": QColor(0x00, 0x80, 0x00, 0xFF),
"pseudocode_function_color": QColor(0x00, 0xAA, 0xFF),
"pseudocode_library_function_color": QColor(0xAA, 0x00, 0xFF),
"pseudocode_quotation_color": QColor(0x00, 0x80, 0x00, 0xFF),
"pseudocode_keyword_color": QColor(0xF1, 0xA7, 0xFA),
"pseudocode_types_color": QColor(0x00, 0xFF, 0xFF, 0xFF),
Expand Down Expand Up @@ -272,6 +274,7 @@
"pseudocode_comment_color": QColor(0x62, 0x72, 0xA4),
"pseudocode_comment_weight": QFont.Weight.Normal,
"pseudocode_function_color": QColor(0x50, 0xFA, 0x7B),
"pseudocode_library_function_color": QColor(0x8B, 0xE9, 0xFD),
"pseudocode_quotation_color": QColor(0xF1, 0xFA, 0x8C),
"pseudocode_keyword_color": QColor(0xFF, 0x79, 0xC6),
"pseudocode_types_color": QColor(0x8B, 0xE9, 0xFD),
Expand Down
1 change: 1 addition & 0 deletions angrmanagement/config/config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ def bool_serializer(config_option, value: bool) -> str:
CE("pseudocode_comment_weight", QFont.Weight, QFont.Weight.Bold),
CE("pseudocode_comment_style", QFont.Style, QFont.Style.StyleNormal),
CE("pseudocode_function_color", QColor, QColor(0x00, 0x00, 0xFF, 0xFF)),
CE("pseudocode_library_function_color", QColor, QColor(0xFF, 0x00, 0xFF)),
CE("pseudocode_function_weight", QFont.Weight, QFont.Weight.Bold),
CE("pseudocode_function_style", QFont.Style, QFont.Style.StyleNormal),
CE("pseudocode_quotation_color", QColor, QColor(0x00, 0x80, 0x00, 0xFF)),
Expand Down
11 changes: 10 additions & 1 deletion angrmanagement/ui/widgets/qccode_highlighter.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ def reset_formats():
Conf.pseudocode_function_color, Conf.pseudocode_function_weight, Conf.pseudocode_function_style
)

FORMATS["library_function"] = create_char_format(
Conf.pseudocode_library_function_color, Conf.pseudocode_function_weight, Conf.pseudocode_function_style
)

FORMATS["comment"] = create_char_format(
Conf.pseudocode_comment_color, Conf.pseudocode_comment_weight, Conf.pseudocode_comment_style
)
Expand All @@ -70,7 +74,12 @@ def _format_node(obj):
"""
if isinstance(obj, SimType):
return FORMATS["type"]
elif isinstance(obj, (CFunctionCall, CFunction)):
elif isinstance(obj, CFunctionCall):
if obj.callee_func is not None:
if obj.callee_func.is_simprocedure or obj.callee_func.is_plt or obj.callee_func.is_syscall:
return FORMATS["library_function"]
return FORMATS["function"]
elif isinstance(obj, CFunction):
return FORMATS["function"]
elif isinstance(obj, CLabel):
return FORMATS["label"]
Expand Down

0 comments on commit 7dfa4bd

Please sign in to comment.