MCPcopy Create free account
hub / github.com/AxlLind/AdventOfCode / execute

Method execute

2019/src/intcoder.rs:30–54  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

28 }
29
30 pub fn execute(&mut self) -> ExitCode {
31 loop {
32 let (op,a,b,c) = self.fetch_inst();
33 match op {
34 ADD => self.set(c, a + b),
35 MUL => self.set(c, a * b),
36 SLT => self.set(c, a < b),
37 SEQ => self.set(c, a == b),
38 BSE => self.rel_base += a,
39 JNZ => if a != 0 { self.pc = b },
40 JZ => if a == 0 { self.pc = b },
41 OUT => return ExitCode::Output(a),
42 HLT => return ExitCode::Halted,
43 IN => match self.input.pop_front() {
44 Some(i) => {
45 let a = self.fetch_write_adr(1);
46 self.set(a,i);
47 self.pc += 2;
48 }
49 None => return ExitCode::AwaitInput
50 }
51 _ => panic!("invalid opcode {}", op)
52 }
53 }
54 }
55
56 pub fn execute_until_output(&mut self) -> i64 {
57 match self.execute() {

Callers 13

execute_until_outputMethod · 0.80
part_twoFunction · 0.80
run_testFunction · 0.80
run_droidFunction · 0.80
explore_mapFunction · 0.80
part_twoFunction · 0.80
part_oneFunction · 0.80
part_twoFunction · 0.80
brute_force_solutionFunction · 0.80
play_manuallyFunction · 0.80
runFunction · 0.80
part_oneFunction · 0.80

Calls 3

fetch_instMethod · 0.80
setMethod · 0.80
fetch_write_adrMethod · 0.80

Tested by

no test coverage detected