1
1
use std:: default:: Default ;
2
2
3
3
use cwdemangle:: demangle;
4
- use egui:: { text:: LayoutJob , Color32 , FontFamily , FontId , Label , Sense , TextFormat } ;
4
+ use egui:: { text:: LayoutJob , Color32 , Label , Sense } ;
5
5
use egui_extras:: { Size , StripBuilder , TableBuilder } ;
6
6
use ppc750cl:: Argument ;
7
7
@@ -11,52 +11,50 @@ use crate::{
11
11
ObjInfo , ObjIns , ObjInsArg , ObjInsArgDiff , ObjInsDiff , ObjInsDiffKind , ObjReloc ,
12
12
ObjRelocKind , ObjSymbol ,
13
13
} ,
14
- views:: symbol_diff:: match_color_for_symbol,
14
+ views:: { symbol_diff:: match_color_for_symbol, write_text , COLOR_RED , FONT_SIZE } ,
15
15
} ;
16
16
17
- const FONT_SIZE : f32 = 14.0 ;
18
- const FONT_ID : FontId = FontId :: new ( FONT_SIZE , FontFamily :: Monospace ) ;
19
-
20
- const COLOR_RED : Color32 = Color32 :: from_rgb ( 200 , 40 , 41 ) ;
21
-
22
- fn write_text ( str : & str , color : Color32 , job : & mut LayoutJob ) {
23
- job. append ( str, 0.0 , TextFormat { font_id : FONT_ID , color, ..Default :: default ( ) } ) ;
17
+ fn write_reloc_name ( reloc : & ObjReloc , color : Color32 , job : & mut LayoutJob ) {
18
+ let name = reloc. target . demangled_name . as_ref ( ) . unwrap_or ( & reloc. target . name ) ;
19
+ write_text ( name, Color32 :: LIGHT_GRAY , job) ;
20
+ if reloc. target . addend != 0 {
21
+ write_text ( & format ! ( "+{:X}" , reloc. target. addend) , color, job) ;
22
+ }
24
23
}
25
24
26
- fn write_reloc ( reloc : & ObjReloc , job : & mut LayoutJob ) {
27
- let name = reloc. target . demangled_name . as_ref ( ) . unwrap_or ( & reloc. target . name ) ;
25
+ fn write_reloc ( reloc : & ObjReloc , color : Color32 , job : & mut LayoutJob ) {
28
26
match reloc. kind {
29
27
ObjRelocKind :: PpcAddr16Lo => {
30
- write_text ( name , Color32 :: LIGHT_GRAY , job) ;
31
- write_text ( "@l" , Color32 :: GRAY , job) ;
28
+ write_reloc_name ( reloc , color , job) ;
29
+ write_text ( "@l" , color , job) ;
32
30
}
33
31
ObjRelocKind :: PpcAddr16Hi => {
34
- write_text ( name , Color32 :: LIGHT_GRAY , job) ;
35
- write_text ( "@h" , Color32 :: GRAY , job) ;
32
+ write_reloc_name ( reloc , color , job) ;
33
+ write_text ( "@h" , color , job) ;
36
34
}
37
35
ObjRelocKind :: PpcAddr16Ha => {
38
- write_text ( name , Color32 :: LIGHT_GRAY , job) ;
39
- write_text ( "@ha" , Color32 :: GRAY , job) ;
36
+ write_reloc_name ( reloc , color , job) ;
37
+ write_text ( "@ha" , color , job) ;
40
38
}
41
39
ObjRelocKind :: PpcEmbSda21 => {
42
- write_text ( name , Color32 :: LIGHT_GRAY , job) ;
43
- write_text ( "@sda21" , Color32 :: GRAY , job) ;
40
+ write_reloc_name ( reloc , color , job) ;
41
+ write_text ( "@sda21" , color , job) ;
44
42
}
45
43
ObjRelocKind :: MipsHi16 => {
46
- write_text ( "%hi(" , Color32 :: GRAY , job) ;
47
- write_text ( name , Color32 :: LIGHT_GRAY , job) ;
48
- write_text ( ")" , Color32 :: GRAY , job) ;
44
+ write_text ( "%hi(" , color , job) ;
45
+ write_reloc_name ( reloc , color , job) ;
46
+ write_text ( ")" , color , job) ;
49
47
}
50
48
ObjRelocKind :: MipsLo16 => {
51
- write_text ( "%lo(" , Color32 :: GRAY , job) ;
52
- write_text ( name , Color32 :: LIGHT_GRAY , job) ;
53
- write_text ( ")" , Color32 :: GRAY , job) ;
49
+ write_text ( "%lo(" , color , job) ;
50
+ write_reloc_name ( reloc , color , job) ;
51
+ write_text ( ")" , color , job) ;
54
52
}
55
53
ObjRelocKind :: Absolute
56
54
| ObjRelocKind :: PpcRel24
57
55
| ObjRelocKind :: PpcRel14
58
56
| ObjRelocKind :: Mips26 => {
59
- write_text ( name , Color32 :: LIGHT_GRAY , job) ;
57
+ write_reloc_name ( reloc , color , job) ;
60
58
}
61
59
} ;
62
60
}
@@ -113,10 +111,10 @@ fn write_ins(
113
111
}
114
112
} ,
115
113
ObjInsArg :: Reloc => {
116
- write_reloc ( ins. reloc . as_ref ( ) . unwrap ( ) , job) ;
114
+ write_reloc ( ins. reloc . as_ref ( ) . unwrap ( ) , base_color , job) ;
117
115
}
118
116
ObjInsArg :: RelocWithBase => {
119
- write_reloc ( ins. reloc . as_ref ( ) . unwrap ( ) , job) ;
117
+ write_reloc ( ins. reloc . as_ref ( ) . unwrap ( ) , base_color , job) ;
120
118
write_text ( "(" , base_color, job) ;
121
119
writing_offset = true ;
122
120
continue ;
0 commit comments