13.07.2015 Views

The PowerPC 604 RISC Microprocessor - eisber.net

The PowerPC 604 RISC Microprocessor - eisber.net

The PowerPC 604 RISC Microprocessor - eisber.net

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Printed by andi from a0.complang.tuwien.ac.atMar 29 1996 16:42 Karel<strong>The</strong>Robotejava Page 15void put_object_at_poslint pos. Node node)if (pos 2)instruction . node;void print lint level) (if (count .= 01Karel<strong>The</strong>Robot.println(level, *ITERATE TIMES');elseKarel<strong>The</strong>Robot.println(level, 'ITERATE ' count • ' TIMES");Karel<strong>The</strong>Robot.print_instr(level, instruction);int exec_step() (it (Karel<strong>The</strong>Robot.offset 0)if ((count 0) 11 (instruction null))return incomplete_program_error;top++;if (top >- stack.length)return stack_overflow_error;stack(topl ■ count;Karel<strong>The</strong>Robot.instruction • instruction;else (►if 1--stack(topl > 0)Karel<strong>The</strong>Robot.offset 0;1Karel<strong>The</strong>Robot.inatruction ■) elsetop--;Karel<strong>The</strong>Robot.offset ■ offset;Karel<strong>The</strong>Robot.instruction ■ next;return 0;instruction;class If<strong>The</strong>nElseNode extends Node implements Globale (static final int description() .(if_then_else_node, is_test, is_stmt, is_stmt, is_undef);int test;Node then_stmt;Node else_stmt;If<strong>The</strong>nElseNodel)test . undef_test;then_stmt - null;else_stmt . null;int length()return 3;int description(int pos) (return description(pos);int get_int_at_pos(int pos)(if (pos 1)return test;return 0;void put_object_at_pos(int pos, int val)if (pos 1)Mar 29 1996 16:42 Karel<strong>The</strong>Robotjava Page 16test . val;Node get_node_at_pos(int pos)(if (pos 2)return then_stmt;else if (pos 3)return elee_stmt;return null;void put_object_at_pos(int pos. Node node) (if (pos 2)then_stmt ■ node;else if (poselse_stmt3)node;void print(int level)Karel<strong>The</strong>Robot.println(level, 'IF + test_names(test));Karel<strong>The</strong>Robot.println(level, 'THEW):Karel<strong>The</strong>Robot.print_instr(level, then_stmt);Karel<strong>The</strong>Robot.println(level, 'ELSE');Karel<strong>The</strong>Robot.print_instr(level, else_stmt);int exec_step()if (test 0)return incomplete_program_error;if (Karel<strong>The</strong>Robot.offset 0)if (KarelsWorld.test(teet))if (then_stmt null)return incomplete_program_error;Karel<strong>The</strong>Robot.inntruction • then_stmt;) elseif (else_stmt null)return incomplete_program_error;Karel<strong>The</strong>Robot.instruction ■ else_stmt;1) elseif (Karel<strong>The</strong>Robot.offset .. 4)BackBuffer.push(true);elseDackBuffer.push(false);Karel<strong>The</strong>Robot.offset . offset;Karel<strong>The</strong>Robot.i<strong>net</strong>ruction • next;return 0;final class CallNode extends Node implements Globalestatic final int description() ■(call_node, is_name, is_undef, is_undef, is_undef);Name definition;CallNode()definition . null;int description(int pos)return description(pos);Name get_name_at_pos(int pos)(if (pos .. 1)Karel<strong>The</strong>Robot.java 8

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!