pub struct Instruction(_);

Implementations§

Examples found in repository?
src/opcodes.rs (line 393)
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
    pub fn mode(&self) -> OpMode {
        match self.get_op() {
            OpCode::Move => OpMode::IAB,
            OpCode::LoadK => OpMode::IABx,
            OpCode::LoadKx => OpMode::IA,
            OpCode::LoadBool => OpMode::IABC,
            OpCode::LoadNil => OpMode::IAB,
            OpCode::GetUpVal => OpMode::IAB,
            OpCode::GetTabUp => OpMode::IABC,
            OpCode::GetTable => OpMode::IABC,
            OpCode::SetTabUp => OpMode::IABC,
            OpCode::SetUpVal => OpMode::IAB,
            OpCode::SetTable => OpMode::IABC,
            OpCode::NewTable => OpMode::IABC,
            OpCode::Self_ => OpMode::IABC,
            OpCode::Add => OpMode::IABC,
            OpCode::Sub => OpMode::IABC,
            OpCode::Mul => OpMode::IABC,
            OpCode::Mod => OpMode::IABC,
            OpCode::Pow => OpMode::IABC,
            OpCode::Div => OpMode::IABC,
            OpCode::IDiv => OpMode::IABC,
            OpCode::BAdd => OpMode::IABC,
            OpCode::BOr => OpMode::IABC,
            OpCode::BXor => OpMode::IABC,
            OpCode::Shl => OpMode::IABC,
            OpCode::Shr => OpMode::IABC,
            OpCode::Unm => OpMode::IAB,
            OpCode::BNot => OpMode::IAB,
            OpCode::Not => OpMode::IAB,
            OpCode::Len => OpMode::IAB,
            OpCode::Concat => OpMode::IABC,
            OpCode::Jmp => OpMode::IAsBx,
            OpCode::Eq => OpMode::IABC,
            OpCode::Lt => OpMode::IABC,
            OpCode::Le => OpMode::IABC,
            OpCode::Test => OpMode::IAC,
            OpCode::TestSet => OpMode::IABC,
            OpCode::Call => OpMode::IABC,
            OpCode::TailCall => OpMode::IABC,
            OpCode::Return => OpMode::IAB,
            OpCode::ForLoop => OpMode::IAsBx,
            OpCode::ForPrep => OpMode::IAsBx,
            OpCode::TForCall => OpMode::IAC,
            OpCode::TForLoop => OpMode::IAsBx,
            OpCode::SetList => OpMode::IAsBx,
            OpCode::Closure => OpMode::IABx,
            OpCode::Vararg => OpMode::IAB,
            OpCode::ExtraArg => OpMode::IAx,
        }
    }
}

use std::fmt;
impl fmt::Debug for Instruction {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self.mode() {
            OpMode::IA => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                " ",
                " "
            ),
            OpMode::IAB => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_B(),
                " "
            ),
            OpMode::IABC => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_B(),
                self.get_arg_C()
            ),
            OpMode::IAC => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                " ",
                self.get_arg_C()
            ),
            OpMode::IABx => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_Bx(),
                " "
            ),
            OpMode::IAsBx => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_sBx(),
                " "
            ),
            OpMode::IAx => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_Ax(),
                " ",
                " "
            ),
        }
    }
Examples found in repository?
src/compiler.rs (line 108)
104
105
106
107
108
109
    pub fn inverse_cond(&self, context: &mut ProtoContext) {
        let proto = &mut context.proto;
        let cond = self.pc - 1;
        let instruction = proto.get_instruction(cond);
        instruction.set_arg_A(1 - instruction.get_arg_A());
    }
More examples
Hide additional examples
src/proto.rs (line 142)
140
141
142
143
144
145
146
147
148
    pub fn fix_cond_jump_pos(&mut self, true_pos: usize, false_pos: usize, pc: usize) {
        let instruction = self.get_instruction(pc);
        let pos = if instruction.get_arg_A() == 0 {
            true_pos
        } else {
            false_pos
        };
        instruction.set_arg_sBx(pos as i32 - pc as i32 - 1);
    }
src/opcodes.rs (line 453)
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self.mode() {
            OpMode::IA => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                " ",
                " "
            ),
            OpMode::IAB => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_B(),
                " "
            ),
            OpMode::IABC => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_B(),
                self.get_arg_C()
            ),
            OpMode::IAC => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                " ",
                self.get_arg_C()
            ),
            OpMode::IABx => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_Bx(),
                " "
            ),
            OpMode::IAsBx => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_sBx(),
                " "
            ),
            OpMode::IAx => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_Ax(),
                " ",
                " "
            ),
        }
    }
Examples found in repository?
src/compiler.rs (line 108)
104
105
106
107
108
109
    pub fn inverse_cond(&self, context: &mut ProtoContext) {
        let proto = &mut context.proto;
        let cond = self.pc - 1;
        let instruction = proto.get_instruction(cond);
        instruction.set_arg_A(1 - instruction.get_arg_A());
    }
Examples found in repository?
src/opcodes.rs (line 462)
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self.mode() {
            OpMode::IA => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                " ",
                " "
            ),
            OpMode::IAB => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_B(),
                " "
            ),
            OpMode::IABC => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_B(),
                self.get_arg_C()
            ),
            OpMode::IAC => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                " ",
                self.get_arg_C()
            ),
            OpMode::IABx => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_Bx(),
                " "
            ),
            OpMode::IAsBx => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_sBx(),
                " "
            ),
            OpMode::IAx => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_Ax(),
                " ",
                " "
            ),
        }
    }
Examples found in repository?
src/opcodes.rs (line 471)
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self.mode() {
            OpMode::IA => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                " ",
                " "
            ),
            OpMode::IAB => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_B(),
                " "
            ),
            OpMode::IABC => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_B(),
                self.get_arg_C()
            ),
            OpMode::IAC => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                " ",
                self.get_arg_C()
            ),
            OpMode::IABx => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_Bx(),
                " "
            ),
            OpMode::IAsBx => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_sBx(),
                " "
            ),
            OpMode::IAx => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_Ax(),
                " ",
                " "
            ),
        }
    }
Examples found in repository?
src/opcodes.rs (line 501)
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self.mode() {
            OpMode::IA => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                " ",
                " "
            ),
            OpMode::IAB => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_B(),
                " "
            ),
            OpMode::IABC => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_B(),
                self.get_arg_C()
            ),
            OpMode::IAC => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                " ",
                self.get_arg_C()
            ),
            OpMode::IABx => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_Bx(),
                " "
            ),
            OpMode::IAsBx => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_sBx(),
                " "
            ),
            OpMode::IAx => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_Ax(),
                " ",
                " "
            ),
        }
    }
Examples found in repository?
src/opcodes.rs (line 486)
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self.mode() {
            OpMode::IA => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                " ",
                " "
            ),
            OpMode::IAB => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_B(),
                " "
            ),
            OpMode::IABC => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_B(),
                self.get_arg_C()
            ),
            OpMode::IAC => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                " ",
                self.get_arg_C()
            ),
            OpMode::IABx => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_Bx(),
                " "
            ),
            OpMode::IAsBx => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_sBx(),
                " "
            ),
            OpMode::IAx => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_Ax(),
                " ",
                " "
            ),
        }
    }
Examples found in repository?
src/opcodes.rs (line 494)
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self.mode() {
            OpMode::IA => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                " ",
                " "
            ),
            OpMode::IAB => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_B(),
                " "
            ),
            OpMode::IABC => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_B(),
                self.get_arg_C()
            ),
            OpMode::IAC => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                " ",
                self.get_arg_C()
            ),
            OpMode::IABx => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_Bx(),
                " "
            ),
            OpMode::IAsBx => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_sBx(),
                " "
            ),
            OpMode::IAx => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_Ax(),
                " ",
                " "
            ),
        }
    }
Examples found in repository?
src/proto.rs (line 147)
140
141
142
143
144
145
146
147
148
149
150
151
152
153
    pub fn fix_cond_jump_pos(&mut self, true_pos: usize, false_pos: usize, pc: usize) {
        let instruction = self.get_instruction(pc);
        let pos = if instruction.get_arg_A() == 0 {
            true_pos
        } else {
            false_pos
        };
        instruction.set_arg_sBx(pos as i32 - pc as i32 - 1);
    }

    pub fn fix_jump_pos(&mut self, pos: usize, pc: usize) {
        let instruction = self.get_instruction(pc);
        instruction.set_arg_sBx(pos as i32 - pc as i32 - 1);
    }
Examples found in repository?
src/proto.rs (line 46)
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
156
157
158
    pub fn code_return(&mut self, first: u32, nret: u32) -> usize {
        self.code
            .push(Instruction::create_ABC(OpCode::Return, first, nret + 1, 0));
        self.code.len() - 1
    }

    pub fn code_nil(&mut self, start_reg: u32, n: u32) -> usize {
        // TODO : optimize for duplicate LoadNil
        self.code.push(Instruction::create_ABC(
            OpCode::LoadNil,
            start_reg,
            n - 1,
            0,
        ));
        self.code.len() - 1
    }

    pub fn code_bool(&mut self, reg: u32, v: bool, pc: u32) -> usize {
        self.code.push(Instruction::create_ABC(
            OpCode::LoadBool,
            reg,
            if v { 1 } else { 0 },
            pc,
        ));
        self.code.len() - 1
    }

    pub fn code_const(&mut self, reg_index: u32, const_index: u32) -> usize {
        self.code.push(Instruction::create_ABx(
            OpCode::LoadK,
            reg_index,
            const_index,
        ));
        self.code.len() - 1
    }

    pub fn code_move(&mut self, reg: u32, src: u32) -> usize {
        self.code
            .push(Instruction::create_ABC(OpCode::Move, reg, src, 0));
        self.code.len() - 1
    }

    pub fn code_bin_op(&mut self, op: BinOp, target: u32, left: u32, right: u32) -> usize {
        let op_code = match op {
            BinOp::Add => OpCode::Add,
            BinOp::Minus => OpCode::Sub,
            BinOp::Mul => OpCode::Mul,
            BinOp::Mod => OpCode::Mod,
            BinOp::Pow => OpCode::Pow,
            BinOp::Div => OpCode::Div,
            BinOp::IDiv => OpCode::IDiv,
            BinOp::BAnd => OpCode::BAdd,
            BinOp::BOr => OpCode::BOr,
            BinOp::BXor => OpCode::BXor,
            BinOp::Shl => OpCode::Shl,
            BinOp::Shr => OpCode::Shr,
            BinOp::Concat => OpCode::Concat,
            _ => unreachable!(),
        };
        self.code
            .push(Instruction::create_ABC(op_code, target, left, right));
        self.code.len() - 1
    }

    pub fn code_comp(&mut self, op: BinOp, left: u32, right: u32) -> usize {
        let op_code = match op {
            BinOp::Lt | BinOp::Gt => OpCode::Lt,
            BinOp::Ne | BinOp::Eq => OpCode::Eq,
            BinOp::Le | BinOp::Ge => OpCode::Le,
            _ => unreachable!(),
        };
        let cond = if op == BinOp::Ne { 0 } else { 1 };
        self.code
            .push(Instruction::create_ABC(op_code, cond, left, right));
        self.code.len() - 1
    }

    pub fn code_un_op(&mut self, op: UnOp, target: u32, src: u32) -> usize {
        let op_code = match op {
            UnOp::Minus => OpCode::Unm,
            UnOp::BNot => OpCode::BNot,
            UnOp::Not => OpCode::Not,
            UnOp::Len => OpCode::Len,
            _ => unimplemented!(),
        };
        self.code
            .push(Instruction::create_ABC(op_code, target, src, 0));
        self.code.len() - 1
    }

    pub fn code_jmp(&mut self, offset: i32, upvars: u32) -> usize {
        self.code
            .push(Instruction::create_AsBx(OpCode::Jmp, upvars, offset));
        self.code.len() - 1
    }

    pub fn fix_cond_jump_pos(&mut self, true_pos: usize, false_pos: usize, pc: usize) {
        let instruction = self.get_instruction(pc);
        let pos = if instruction.get_arg_A() == 0 {
            true_pos
        } else {
            false_pos
        };
        instruction.set_arg_sBx(pos as i32 - pc as i32 - 1);
    }

    pub fn fix_jump_pos(&mut self, pos: usize, pc: usize) {
        let instruction = self.get_instruction(pc);
        instruction.set_arg_sBx(pos as i32 - pc as i32 - 1);
    }

    pub fn code_test_set(&mut self, set: u32, test: u32, to_test: u32) {
        self.code
            .push(Instruction::create_ABC(OpCode::TestSet, set, test, to_test));
    }
Examples found in repository?
src/proto.rs (lines 72-76)
71
72
73
74
75
76
77
78
    pub fn code_const(&mut self, reg_index: u32, const_index: u32) -> usize {
        self.code.push(Instruction::create_ABx(
            OpCode::LoadK,
            reg_index,
            const_index,
        ));
        self.code.len() - 1
    }
Examples found in repository?
src/proto.rs (line 136)
134
135
136
137
138
    pub fn code_jmp(&mut self, offset: i32, upvars: u32) -> usize {
        self.code
            .push(Instruction::create_AsBx(OpCode::Jmp, upvars, offset));
        self.code.len() - 1
    }
Examples found in repository?
src/proto.rs (line 191)
188
189
190
191
192
193
194
    pub fn save(&mut self, target: u32) -> usize {
        let last = self.code.last_mut();
        if let Some(code) = last {
            code.save(target);
        }
        self.code.len() - 1
    }
Examples found in repository?
src/opcodes.rs (line 448)
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self.mode() {
            OpMode::IA => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                " ",
                " "
            ),
            OpMode::IAB => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_B(),
                " "
            ),
            OpMode::IABC => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_B(),
                self.get_arg_C()
            ),
            OpMode::IAC => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                " ",
                self.get_arg_C()
            ),
            OpMode::IABx => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_Bx(),
                " "
            ),
            OpMode::IAsBx => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_A(),
                self.get_arg_sBx(),
                " "
            ),
            OpMode::IAx => write!(
                f,
                "| {:<10} | {:<5} | {:<5} | {:<5} |",
                format!("{:?}", self.get_op()),
                self.get_arg_Ax(),
                " ",
                " "
            ),
        }
    }

Trait Implementations§

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.