summary refs log tree commit diff stats
path: root/doc/uml/128002.diagram
blob: 3c359d4240e9db499293f2221b4b39ece9f06838 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
format 70

classcanvas 128002 class_ref 128002 // Displayable
  draw_all_relations default hide_attributes default hide_operations default hide_getset_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_relation_visibility default show_infonote default shadow default show_stereotype_properties default
  xyz 301.407 212.109 2000
end
classcanvas 128130 class_ref 128130 // UI
  draw_all_relations default hide_attributes default hide_operations default hide_getset_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_relation_visibility default show_infonote default shadow default show_stereotype_properties default
  xyz 240.852 390.327 2000
end
classcanvas 128258 class_ref 128258 // DefaultUI
  draw_all_relations default hide_attributes default hide_operations default hide_getset_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_relation_visibility default show_infonote default shadow default show_stereotype_properties default
  xyz 217.717 473.896 2000
end
classcanvas 128642 class_ref 128386 // DisplayableContainer
  draw_all_relations default hide_attributes default hide_operations default hide_getset_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_relation_visibility default show_infonote default shadow default show_stereotype_properties default
  xyz 224.704 309.894 2006
end
classcanvas 129410 class_ref 135042 // TitleBar
  draw_all_relations default hide_attributes default hide_operations default hide_getset_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_relation_visibility default show_infonote default shadow default show_stereotype_properties default
  xyz 629.233 351.65 2000
end
classcanvas 129666 class_ref 135170 // FileList
  draw_all_relations default hide_attributes default hide_operations default hide_getset_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_relation_visibility default show_infonote default shadow default show_stereotype_properties default
  xyz 539.259 352.907 2000
end
classcanvas 129922 class_ref 135298 // FileListContainer
  draw_all_relations default hide_attributes default hide_operations default hide_getset_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_relation_visibility default show_infonote default shadow default show_stereotype_properties default
  xyz 471.3 421.8 2000
end
classcanvas 131970 class_ref 135426 // Console
  draw_all_relations default hide_attributes default hide_operations default hide_getset_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_relation_visibility default show_infonote default shadow default show_stereotype_properties default
  xyz 722.435 351.987 2000
end
note 132738 "Only one instance, since it initializes curses!"
  xyzwh 68 390 2012 89 113
classcanvas 132994 class_ref 141954 // FileManagerAware
  draw_all_relations default hide_attributes default hide_operations default hide_getset_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_relation_visibility default show_infonote default shadow default show_stereotype_properties default
  xyz 138 98 2000
end
classcanvas 133122 class_ref 142082 // SettingsAware
  draw_all_relations default hide_attributes default hide_operations default hide_getset_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_relation_visibility default show_infonote default shadow default show_stereotype_properties default
  xyz 153 151 2000
end
classcanvas 133250 class_ref 142210 // EnvironmentAware
  draw_all_relations default hide_attributes default hide_operations default hide_getset_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_relation_visibility default show_infonote default shadow default show_stereotype_properties default
  xyz 134 50 2005
end
classcanvas 134530 class_ref 156034 // Widget
  draw_all_relations default hide_attributes default hide_operations default hide_getset_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default show_attribute_modifiers default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_relation_modifiers default show_relation_visibility default show_infonote default shadow default show_stereotype_properties default
  xyz 600 232 2000
end
note 136962 "Defines no methods, just for classification"
  xyzwh 608 99 2000 135 77
relationcanvas 128386 relation_ref 128002 // <generalisation>
  decenter_begin 529
  from ref 128258 z 2001 to ref 128130
  no_role_a no_role_b
  no_multiplicity_a no_multiplicity_b
end
relationcanvas 128898 relation_ref 128386 // <generalisation>
  decenter_begin 625
  decenter_end 339
  from ref 128642 z 2007 to ref 128002
  no_role_a no_role_b
  no_multiplicity_a no_multiplicity_b
end
relationcanvas 130178 relation_ref 135554 // <generalisation>
  decenter_end 715
  from ref 129922 z 2007 to point 349 395
  line 132610 z 2007 to ref 128642
  no_role_a no_role_b
  no_multiplicity_a no_multiplicity_b
end
relationcanvas 130562 relation_ref 135810 // <aggregation>
  decenter_begin 693
  from ref 129922 z 2001 to ref 129666
  no_role_a no_role_b
  no_multiplicity_a no_multiplicity_b
end
relationcanvas 130690 relation_ref 135938 // <aggregation>
  decenter_begin 720
  decenter_end 495
  from ref 128642 z 2007 to ref 128002
  no_role_a no_role_b
  no_multiplicity_a no_multiplicity_b
end
relationcanvas 132354 relation_ref 128258 // <generalisation>
  decenter_begin 487
  decenter_end 205
  from ref 128130 z 2007 to ref 128642
  no_role_a no_role_b
  no_multiplicity_a no_multiplicity_b
end
relationcanvas 133378 relation_ref 142850 // <generalisation>
  decenter_begin 505
  from ref 128002 z 2006 to point 348 66
  line 133762 z 2006 to ref 133250
  no_role_a no_role_b
  no_multiplicity_a no_multiplicity_b
end
relationcanvas 133506 relation_ref 142978 // <generalisation>
  decenter_begin 313
  from ref 128002 z 2001 to point 329 115
  line 133890 z 2001 to ref 132994
  no_role_a no_role_b
  no_multiplicity_a no_multiplicity_b
end
relationcanvas 134274 relation_ref 149634 // <generalisation>
  decenter_begin 116
  from ref 128002 z 2001 to point 307 168
  line 134402 z 2001 to ref 133122
  no_role_a no_role_b
  no_multiplicity_a no_multiplicity_b
end
relationcanvas 134658 relation_ref 170754 // <generalisation>
  decenter_end 708
  from ref 134530 z 2001 to ref 128002
  no_role_a no_role_b
  no_multiplicity_a no_multiplicity_b
end
relationcanvas 134786 relation_ref 170882 // <generalisation>
  from ref 131970 z 2001 to ref 134530
  no_role_a no_role_b
  no_multiplicity_a no_multiplicity_b
end
relationcanvas 134914 relation_ref 171010 // <generalisation>
  from ref 129410 z 2001 to ref 134530
  no_role_a no_role_b
  no_multiplicity_a no_multiplicity_b
end
relationcanvas 135042 relation_ref 171138 // <generalisation>
  from ref 129666 z 2001 to ref 134530
  no_role_a no_role_b
  no_multiplicity_a no_multiplicity_b
end
relationcanvas 135938 relation_ref 171266 // <generalisation>
  decenter_begin 333
  from ref 129922 z 2001 to point 517 316
  line 136066 z 2001 to ref 134530
  no_role_a no_role_b
  no_multiplicity_a no_multiplicity_b
end
relationcanvas 136194 relation_ref 178178 // <aggregation>
  from ref 128258 z 2001 to point 366 492
  line 136706 z 2001 to point 456 291
  line 136834 z 2001 to ref 134530
  no_role_a no_role_b
  no_multiplicity_a no_multiplicity_b
end
line 132866 -_-_
  from ref 132738 z 2013 to ref 128130
line 137090 -_-_
  from ref 136962 z 2001 to ref 134530
end
"k">return; } if (s.at(0) == '-') raise << "'" << s << "' starts with '-', which can be confused with a negative number; use a different name\n" << end(); if (s.substr(0, 2) == "0x") { raise << "'" << s << "' looks like a hex number; use a different name\n" << end(); return; } if (isdigit(s.at(0))) raise << "'" << s << "' starts with a digit, and so can be confused with a negative number; use a different name.\n" << end(); if (SIZE(s) == 2) raise << "'" << s << "' is two characters long which can look like raw hex bytes at a glance; use a different name\n" << end(); } //: Now that that's done, let's start using names as labels. :(scenario map_label) == 0x1 loop: 05 0x0d0c0b0a/imm32 +transform: label 'loop' is at address 1 :(before "End Level-2 Transforms") Transform.push_back(rewrite_labels); :(code) void rewrite_labels(program& p) { trace(99, "transform") << "-- rewrite labels" << end(); if (p.segments.empty()) return; segment& code = p.segments.at(0); map<string, int32_t> byte_index; // values are unsigned, but we're going to do subtractions on them so they need to fit in 31 bits compute_byte_indices_for_labels(code, byte_index); if (trace_contains_errors()) return; drop_labels(code); if (trace_contains_errors()) return; replace_labels_with_displacements(code, byte_index); } void compute_byte_indices_for_labels(const segment& code, map<string, int32_t>& byte_index) { int current_byte = 0; for (int i = 0; i < SIZE(code.lines); ++i) { const line& inst = code.lines.at(i); for (int j = 0; j < SIZE(inst.words); ++j) { const word& curr = inst.words.at(j); // hack: if we have any operand metadata left after previous transforms, // deduce its size // Maybe we should just move this transform to before instruction // packing, and deduce the size of *all* operands. But then we'll also // have to deal with bitfields. if (has_operand_metadata(curr, "disp32") || has_operand_metadata(curr, "imm32")) { if (*curr.data.rbegin() == ':') raise << "'" << to_string(inst) << "': don't use ':' when jumping to labels\n" << end(); current_byte += 4; } else if (has_operand_metadata(curr, "disp16")) { if (*curr.data.rbegin() == ':') raise << "'" << to_string(inst) << "': don't use ':' when jumping to labels\n" << end(); current_byte += 2; } // automatically handle /disp8 and /imm8 here else if (*curr.data.rbegin() != ':') { ++current_byte; } else { string label = drop_last(curr.data); // ensure labels look sufficiently different from raw hex check_valid_name(label); if (trace_contains_errors()) return; if (contains_any_operand_metadata(curr)) raise << "'" << to_string(inst) << "': label definition (':') not allowed in operand\n" << end(); if (j > 0) raise << "'" << to_string(inst) << "': labels can only be the first word in a line.\n" << end(); if (Map_file.is_open()) Map_file << "0x" << HEXWORD << (code.start + current_byte) << ' ' << label << '\n'; put(byte_index, label, current_byte); trace(99, "transform") << "label '" << label << "' is at address " << (current_byte+code.start) << end(); // no modifying current_byte; label definitions won't be in the final binary } } } } :(before "End Globals") bool Dump_map = false; // currently used only by 'subx translate' ofstream Map_file; :(before "End Commandline Options") else if (is_equal(*arg, "--map")) { Dump_map = true; // End --map Settings } //: wait to open "map" for writing until we're sure we aren't trying to read it :(after "Begin subx translate") if (Dump_map) Map_file.open("map"); :(before "End subx translate") if (Dump_map) Map_file.close(); :(code) void drop_labels(segment& code) { for (int i = 0; i < SIZE(code.lines); ++i) { line& inst = code.lines.at(i); vector<word>::iterator new_end = remove_if(inst.words.begin(), inst.words.end(), is_label); inst.words.erase(new_end, inst.words.end()); } } bool is_label(const word& w) { return *w.data.rbegin() == ':'; } void replace_labels_with_displacements(segment& code, const map<string, int32_t>& byte_index) { int32_t byte_index_next_instruction_starts_at = 0; for (int i = 0; i < SIZE(code.lines); ++i) { line& inst = code.lines.at(i); byte_index_next_instruction_starts_at += num_bytes(inst); line new_inst; for (int j = 0; j < SIZE(inst.words); ++j) { const word& curr = inst.words.at(j); if (contains_key(byte_index, curr.data)) { int32_t displacement = static_cast<int32_t>(get(byte_index, curr.data)) - byte_index_next_instruction_starts_at; if (has_operand_metadata(curr, "disp8")) { if (displacement > 0xff || displacement < -0x7f) raise << "'" << to_string(inst) << "': label too far away for displacement " << std::hex << displacement << " to fit in 8 bits\n" << end(); else emit_hex_bytes(new_inst, displacement, 1); } else if (has_operand_metadata(curr, "disp16")) { if (displacement > 0xffff || displacement < -0x7fff) raise << "'" << to_string(inst) << "': label too far away for displacement " << std::hex << displacement << " to fit in 16 bits\n" << end(); else emit_hex_bytes(new_inst, displacement, 2); } else if (has_operand_metadata(curr, "disp32")) { emit_hex_bytes(new_inst, displacement, 4); } } else { new_inst.words.push_back(curr); } } inst.words.swap(new_inst.words); trace(99, "transform") << "instruction after transform: '" << data_to_string(inst) << "'" << end(); } } string data_to_string(const line& inst) { ostringstream out; for (int i = 0; i < SIZE(inst.words); ++i) { if (i > 0) out << ' '; out << inst.words.at(i).data; } return out.str(); } string drop_last(const string& s) { return string(s.begin(), --s.end()); } //: Label definitions must be the first word on a line. No jumping inside //: instructions. //: They should also be the only word on a line. //: However, you can absolutely have multiple labels map to the same address, //: as long as they're on separate lines. :(scenario multiple_labels_at) == 0x1 # address 1 loop: $loop2: # address 1 (labels take up no space) 05 0x0d0c0b0a/imm32 # address 6 eb $loop2/disp8 # address 8 eb $loop3/disp8 # address 0xa $loop3: +transform: label 'loop' is at address 1 +transform: label '$loop2' is at address 1 +transform: label '$loop3' is at address a # first jump is to -7 +transform: instruction after transform: 'eb f9' # second jump is to 0 (fall through) +transform: instruction after transform: 'eb 00' :(scenario label_too_short) % Hide_errors = true; == 0x1 xz: 05 0x0d0c0b0a/imm32 +error: 'xz' is two characters long which can look like raw hex bytes at a glance; use a different name :(scenario label_hex) % Hide_errors = true; == 0x1 0xab: 05 0x0d0c0b0a/imm32 +error: '0xab' looks like a hex number; use a different name :(scenario label_negative_hex) % Hide_errors = true; == 0x1 -a: # indent to avoid looking like a trace_should_not_contain command for this scenario 05 0x0d0c0b0a/imm32 +error: '-a' starts with '-', which can be confused with a negative number; use a different name //: now that we have labels, we need to adjust segment size computation to //: ignore them. :(scenario segment_size_ignores_labels) == code # 0x09000074 05/add 0x0d0c0b0a/imm32 # 5 bytes foo: # 0 bytes == data # 0x0a000079 bar: 00 +transform: segment 1 begins at address 0x0a000079 :(before "End size_of(word w) Special-cases") else if (is_label(w)) return 0;