ic.d

来自「Object-Oriented Programming With ANSI-C这」· D 代码 · 共 60 行

D
60
字号
// new(Ic())//	wire() connects me to other object//	gate() sends something to my outlet; overwritten to receive// new(Mux())//	wire() connects me to many outputs//	gate() tries to send until it finds willing receiver// new(LineOut())//	gate() displays input as string// new(Button(), "text")//	gate() takes event, possibly sends text on// new(Event(), kind, data)//	something to send to Button// new(Calc())//	gate() combines input with state, sends result onenum react { reject, accept };% IcClass: Class  Ic: Object {	void * out;%-	void wire (Object @ to, _self);	enum react gate (_self, const void * item);%}% IcClass  Mux: Ic {	void * list;%}% IcClass  LineOut: Ic {%}% IcClass  Button: Ic {	const char * text;%}%prot#define	text(b)	(((const struct Button *) b) -> text)% Class  Event: Object {	int kind;				// 0 means string-data	void * data;			// not implicitly deleted%	int kind (const _self);	void * data (const _self);%}%prottypedef	int values[2];		// left and right operand stack% IcClass  Calc: Ic {	values value;			// left and right operand	int op;					// operator	int state;				// FSM state%}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?