996
|
1 /* -*- mode: C; coding: utf-8; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
|
|
2 *
|
|
3 * cfunge - A standard-conforming Befunge93/98/109 interpreter in C.
|
|
4 * Copyright (C) 2008-2009 Arvid Norlander <anmaster AT tele2 DOT se>
|
|
5 *
|
|
6 * This program is free software: you can redistribute it and/or modify
|
|
7 * it under the terms of the GNU General Public License as published by
|
|
8 * the Free Software Foundation, either version 3 of the License, or
|
|
9 * (at the proxy's option) any later version. Arvid Norlander is a
|
|
10 * proxy who can decide which future versions of the GNU General Public
|
|
11 * License can be used.
|
|
12 *
|
|
13 * This program is distributed in the hope that it will be useful,
|
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16 * GNU General Public License for more details.
|
|
17 *
|
|
18 * You should have received a copy of the GNU General Public License
|
|
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20 */
|
|
21
|
|
22 /**
|
|
23 * @file
|
|
24 * Header for interpreter.c (that contains the main loop and parser).
|
|
25 */
|
|
26
|
|
27 #ifndef FUNGE_HAD_SRC_INTERPRETER_H
|
|
28 #define FUNGE_HAD_SRC_INTERPRETER_H
|
|
29
|
|
30 #include "global.h"
|
|
31
|
|
32 #include <sys/types.h>
|
|
33 #include <stdint.h>
|
|
34
|
|
35 #include "ip.h"
|
|
36
|
|
37 // Certain instructions that are also used elsewhere.
|
|
38 /**
|
|
39 * Run a _ instruction.
|
|
40 * @param ip to IP to execute this instruction for.
|
|
41 */
|
|
42 FUNGE_ATTR_NONNULL FUNGE_ATTR_FAST
|
|
43 void if_east_west(instructionPointer * restrict ip);
|
|
44 /**
|
|
45 * Run a | instruction.
|
|
46 * @param ip to IP to execute this instruction for.
|
|
47 */
|
|
48 FUNGE_ATTR_NONNULL FUNGE_ATTR_FAST
|
|
49 void if_north_south(instructionPointer * restrict ip);
|
|
50
|
|
51 /**
|
|
52 * Run instruction. Different prototype depending on if CONCURRENT_FUNGE
|
|
53 * is defined or not.
|
|
54 * @param opcode Instruction to execute
|
|
55 * @param ip Instruction pointer to execute the instruction in.
|
|
56 * @param threadindex The thread index (only if CONCURRENT_FUNGE is defined)
|
|
57 * @returns
|
|
58 * Return value only if CONCURRENT_FUNGE is defined. If true we executed an
|
|
59 * instruction that took 0 ticks, so call me again right away (in main loop)!
|
|
60 */
|
|
61 #ifdef CONCURRENT_FUNGE
|
|
62 FUNGE_ATTR_NONNULL FUNGE_ATTR_FAST
|
|
63 bool execute_instruction(funge_cell opcode,
|
|
64 instructionPointer * restrict ip,
|
|
65 ssize_t * threadindex);
|
|
66 #else
|
|
67 FUNGE_ATTR_NONNULL FUNGE_ATTR_FAST
|
|
68 void execute_instruction(funge_cell opcode,
|
|
69 instructionPointer * restrict ip);
|
|
70 #endif
|
|
71
|
|
72 /**
|
|
73 * Start interpreter on a specific filename.
|
|
74 * @warning MUST only be called from main.c
|
|
75 * @param filename Filename to operate on.
|
|
76 */
|
|
77 FUNGE_ATTR_NORET FUNGE_ATTR_FAST
|
|
78 void interpreter_run(const char *filename);
|
|
79
|
|
80 #endif
|