Skip to content

Commit ba0d65f

Browse files
committed
Changing colors. Adding info icons
1 parent 66a520d commit ba0d65f

File tree

4 files changed

+42
-22
lines changed

4 files changed

+42
-22
lines changed

src/app/bytecode-viewer/bytecode-viewer.component.css

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,53 +36,63 @@ th, td {
3636
}
3737

3838
.row-selected > th, .row-selected > td {
39-
background-color: darkgreen;
39+
background-color: lightgreen;
4040
}
4141

4242
.row-selected > th > code, .row-selected > td > code {
43-
color: lightgreen;
43+
color: black;
4444
}
4545

4646
.red-colored {
4747
color: red;
4848
}
4949

50+
.blue-colored {
51+
color: blue;
52+
}
53+
5054
.row-entry-point > th, .row-entry-point > td {
51-
background-color: darkviolet;
55+
background-color: violet;
5256
}
5357

5458
.row-entry-point > th > code, .row-entry-point > td > code {
55-
color: thistle;
59+
color: black;
5660
}
5761

5862
.row-destination > th, .row-destination > td {
59-
background-color: darkblue;
63+
background-color: lightblue;
6064
}
6165

62-
.row-selected > td > .red-colored, .row-destination > td > .red-colored, .row-entry-point > td > .red-colored {
63-
color: lightpink;
66+
.row-destination > th > code, .row-destination > td > code {
67+
color: black;
6468
}
6569

66-
.row-destination > th > code, .row-destination > td > code {
70+
/*
71+
.row-selected > td > a, .row-destination > td > a, .row-entry-point > td > a {
6772
color: lightblue;
6873
}
74+
*/
75+
76+
.row-selected > td > .red-colored, .row-destination > td > .red-colored, .row-entry-point > td > .red-colored {
77+
color: red;
78+
}
79+
80+
.row-selected > td > .blue-colored, .row-destination > td > .blue-colored, .row-entry-point > td > .blue-colored {
81+
color: blue;
82+
}
83+
84+
.tab-pane {
85+
padding-top: 10px;
86+
}
6987

7088
.pulse {
7189
animation-name: pulse;
7290
animation-duration: 1s;
7391
animation-iteration-count: infinite;
7492
}
7593

76-
.row-selected > td > a, .row-destination > td > a, .row-entry-point > td > a {
77-
color: lightblue;
78-
}
79-
8094
@keyframes pulse {
8195
from { transform: scale(1); }
8296
50% { transform: scale(0.5); }
8397
to { transform: scale(1); }
84-
}
85-
86-
.tab-pane {
87-
padding-top: 10px;
8898
}

src/app/bytecode-viewer/bytecode-viewer.component.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,11 @@
160160
<code>{{disassembledInstruction.toString()}}</code>
161161
&nbsp;
162162
<fa-icon [icon]="exclamationIcon" class="pulse red-colored" tooltip="{{disassembledInstruction.warning}}"></fa-icon>
163-
</ng-template>
163+
</ng-template>
164+
<ng-container *ngIf="disassembledInstruction.info">
165+
&nbsp;
166+
<fa-icon [icon]="infoIcon" class="blue-colored" tooltip="{{disassembledInstruction.info}}"></fa-icon>
167+
</ng-container>
164168
</td>
165169
</tr>
166170
</tbody>

src/app/bytecode-viewer/bytecode-viewer.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import { Component, OnInit, Input } from '@angular/core';
2121
import { Disassembler } from '../shared/disassembler.shared';
2222
import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
23-
import { faExclamationCircle, faChartBar, faFile } from '@fortawesome/free-solid-svg-icons';
23+
import { faExclamationCircle, faInfoCircle, faChartBar, faFile } from '@fortawesome/free-solid-svg-icons';
2424

2525
@Component({
2626
selector: 'bytecode-viewer-component',
@@ -41,6 +41,7 @@ export class BytecodeViewerComponent implements OnInit {
4141
loading: boolean = false;
4242

4343
exclamationIcon: IconDefinition = faExclamationCircle;
44+
infoIcon: IconDefinition = faInfoCircle;
4445
fileIcon: IconDefinition = faFile;
4546
barChartIcon: IconDefinition = faChartBar;
4647

src/app/shared/disassembler.shared.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,19 @@ class DisassembledInstruction {
3030

3131
public referencedAddress: number;
3232
public warning: string;
33+
public info: string;
3334

3435
public bytes: Uint8Array;
3536

36-
constructor(address: number, instruction: Instruction, operands: string, referencedAddress: number, warning: string, bytes: Uint8Array) {
37+
constructor(address: number, instruction: Instruction, operands: string, referencedAddress: number, warning: string, info: string, bytes: Uint8Array) {
3738
this.address = address;
3839

3940
this.instruction = instruction;
4041
this.operands = operands;
4142

4243
this.referencedAddress = referencedAddress;
4344
this.warning = warning;
45+
this.info = info;
4446

4547
this.bytes = bytes;
4648
}
@@ -69,6 +71,7 @@ export class Disassembler {
6971

7072
private jumpDestination: number;
7173
private warning: string;
74+
private info: string;
7275

7376
public static readonly MIN_OBJ_SIZE: number = 1 + 1 + 3 * 4 + 1;
7477

@@ -150,7 +153,7 @@ export class Disassembler {
150153
public static readonly DUP_X1: Instruction = {mnemonic: "dup_x1", opcode: 59};
151154
public static readonly DUP_X2: Instruction = {mnemonic: "dup_x2", opcode: 60};
152155

153-
public static readonly INVALID_INSTR: Instruction = {mnemonic: "", opcode: 61};
156+
public static readonly INVALID_INSTR: Instruction = {mnemonic: "???", opcode: 61};
154157

155158
public static readonly INSTRUCTIONS: Instruction[] = [
156159
Disassembler.LOAD, Disassembler.LOAD_0, Disassembler.LOAD_1, Disassembler.LOAD_2,
@@ -201,7 +204,7 @@ export class Disassembler {
201204
if (this.jumpDestination && (this.jumpDestination < 0 || this.jumpDestination >= this.uint8Array.length - this.headerSize)) {
202205
this.warning = 'This instruction is problematic! Destination address does not exist.';
203206
}
204-
this.disassembledInstructions.push(new DisassembledInstruction(this.address, instruction, operands, isJumpInstruction ? this.jumpDestination : null, this.warning, bytes));
207+
this.disassembledInstructions.push(new DisassembledInstruction(this.address, instruction, operands, isJumpInstruction ? this.jumpDestination : null, this.warning, this.info, bytes));
205208
this.address = this.current - this.headerSize;
206209
}
207210

@@ -224,6 +227,7 @@ export class Disassembler {
224227

225228
while (this.current < this.uint8Array.length) {
226229
this.warning = null;
230+
this.info = null;
227231
this.jumpDestination = null;
228232
this.startAddresses.push(this.address);
229233
switch(this.opcode = this.get()) {
@@ -327,7 +331,8 @@ export class Disassembler {
327331
this.operand1 = this.get4();
328332
let asciiChar = String.fromCharCode(this.operand1);
329333
let isPrintable = /^[ -~]$/.test(asciiChar);
330-
this.put(Disassembler.CONST, new Uint8Array([this.opcode, (this.operand1 >> 24) & 0x0ff, (this.operand1 >> 16) & 0x0ff, (this.operand1 >> 8) & 0x0ff, this.operand1 & 0x0ff]), this.operand1.toString() + (isPrintable ? " (ASCII char: '" + asciiChar + "')" : ""));
334+
this.info = isPrintable ? "If it is interpreted as an ASCII char, this value is '" + asciiChar + "'" : "";
335+
this.put(Disassembler.CONST, new Uint8Array([this.opcode, (this.operand1 >> 24) & 0x0ff, (this.operand1 >> 16) & 0x0ff, (this.operand1 >> 8) & 0x0ff, this.operand1 & 0x0ff]), this.operand1.toString());
331336
break;
332337
}
333338
case Disassembler.ADD.opcode: {

0 commit comments

Comments
 (0)