forked from shihyu/DesignPatternExample
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpu.c
More file actions
41 lines (31 loc) · 600 Bytes
/
Copy pathcpu.c
File metadata and controls
41 lines (31 loc) · 600 Bytes
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
#include <stdio.h>
#include "cpu.h"
static void CPU_freeze(CPU*);
static void CPU_jump(CPU*, long);
static void CPU_execute(CPU*);
CPU* CPU_construct(void* addr)
{
if (addr == NULL) {
return NULL;
}
CPU* cpu = addr;
cpu->freeze = CPU_freeze;
cpu->jump = CPU_jump;
cpu->execute = CPU_execute;
return cpu;
}
void CPU_destruct(CPU* cpu)
{
}
void CPU_freeze(CPU* cpu)
{
printf("CPU freeze!\n");
}
void CPU_jump(CPU* cpu, long position)
{
printf("CPU jump to position %ld!\n", position);
}
void CPU_execute(CPU* cpu)
{
printf("CPU execute!\n");
}