annotate Plugins/Visualization/paranormal/pn/pnscript.c @ 1717:837983bac90f trunk

[svn] Fixed a lot of warnings that only showed up on *BSD.
author js
date Sat, 16 Sep 2006 16:26:54 -0700
parents 1423ab8e5cbc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1507
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
1 /* Paranormal - A highly customizable audio visualization library
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
2 * Copyright (C) 2001 Jamie Gennis <jgennis@mindspring.com>
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
3 *
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
4 * This library is free software; you can redistribute it and/or
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
5 * modify it under the terms of the GNU Library General Public
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
6 * License as published by the Free Software Foundation; either
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
7 * version 2 of the License, or (at your option) any later version.
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
8 *
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
9 * This library is distributed in the hope that it will be useful,
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
12 * Library General Public License for more details.
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
13 *
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
14 * You should have received a copy of the GNU Library General Public
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
15 * License along with this library; if not, write to the Free
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
17 */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
18
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
19 #include <config.h>
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
20
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
21 #include <math.h>
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
22 #include "pnscript.h"
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
23
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
24 /* Initialization */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
25 static void pn_script_class_init (PnScriptClass *class);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
26
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
27 /* Internal parser */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
28 gboolean pn_script_internal_parse_string (PnScript *script,
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
29 const gchar *string);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
30
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
31 static GObjectClass *parent_class = NULL;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
32
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
33 GType
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
34 pn_script_get_type (void)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
35 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
36 static GType script_type = 0;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
37
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
38 if (! script_type)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
39 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
40 static const GTypeInfo script_info =
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
41 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
42 sizeof (PnScriptClass),
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
43 NULL, /* base_init */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
44 NULL, /* base_finalize */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
45 (GClassInitFunc) pn_script_class_init,
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
46 NULL, /* class_finalize */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
47 NULL, /* class_data */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
48 sizeof (PnScript),
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
49 0, /* n_preallocs */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
50 NULL /* instance_init */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
51 };
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
52
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
53 /* FIXME: should this be dynamic? */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
54 script_type = g_type_register_static (PN_TYPE_OBJECT,
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
55 "PnScript",
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
56 &script_info,
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
57 0);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
58 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
59 return script_type;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
60 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
61
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
62 static void
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
63 pn_script_class_init (PnScriptClass *class)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
64 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
65 GObjectClass *gobject_class;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
66 PnObjectClass *object_class;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
67
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
68 gobject_class = (GObjectClass *) class;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
69 object_class = (PnObjectClass *) class;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
70
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
71 parent_class = g_type_class_peek_parent (class);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
72 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
73
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
74 static void
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
75 pn_script_unref_variables (PnScript *script)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
76 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
77 g_return_if_fail (script != NULL);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
78 g_return_if_fail (PN_IS_SCRIPT (script));
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
79
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
80 if (script->code && script->symbol_table)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
81 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
82 guint *op;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
83
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
84 for (op = script->code; *op != PN_OP_END; op++)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
85 switch (*op)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
86 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
87 case PN_OP_PUSHC:
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
88 op++;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
89 break;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
90
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
91 case PN_OP_PUSHV:
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
92 pn_symbol_table_unref_variable (script->symbol_table, PN_VARIABLE (*(++op)));
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
93 break;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
94
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
95 case PN_OP_SET:
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
96 pn_symbol_table_unref_variable (script->symbol_table, PN_VARIABLE (*(++op)));
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
97 break;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
98 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
99 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
100 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
101
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
102 /**
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
103 * pn_script_new
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
104 *
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
105 * Creates a new #PnScript object.
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
106 *
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
107 * Returns: The newly created #PnScript object
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
108 */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
109 PnScript*
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
110 pn_script_new (void)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
111 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
112 return (PnScript *) g_object_new (PN_TYPE_SCRIPT, NULL);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
113 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
114
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
115 /**
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
116 * pn_script_parse_string
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
117 * @script: A #PnScript
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
118 * @symbol_table: the #PnSymbolTable to associate with the script
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
119 * @string: a string containing the script
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
120 *
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
121 * Parses a script, compiling it to a bytecode that is stored within the script object.
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
122 * All in-script variables within the script are added to the specified symbol table (if
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
123 * they are not already in it). If errors are encountered while parsing the script,
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
124 * they are output using pn_error().
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
125 *
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
126 * Returns: %TRUE on success; %FALSE otherwise
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
127 */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
128 gboolean
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
129 pn_script_parse_string (PnScript *script, PnSymbolTable *symbol_table, const gchar *string)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
130 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
131 g_return_val_if_fail (script != NULL, FALSE);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
132 g_return_val_if_fail (PN_IS_SCRIPT (script), FALSE);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
133 g_return_val_if_fail (symbol_table != NULL, FALSE);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
134 g_return_val_if_fail (PN_IS_SYMBOL_TABLE (symbol_table), FALSE);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
135 g_return_val_if_fail (string != NULL, FALSE);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
136
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
137 /* Make sure if it's the same symbol table, we don't destroy it */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
138 pn_object_ref (PN_OBJECT (symbol_table));
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
139 pn_object_sink (PN_OBJECT (symbol_table));
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
140
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
141 /* get rid of the old script */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
142 if (script->symbol_table)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
143 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
144 pn_script_unref_variables (script);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
145 pn_object_unref (PN_OBJECT (script->symbol_table));
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
146 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
147 if (script->stack)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
148 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
149 g_free (script->stack);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
150 script->stack = NULL;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
151 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
152 if (script->code)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
153 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
154 g_free (script->code);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
155 script->code = NULL;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
156 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
157 if (script->constant_table)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
158 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
159 g_free (script->constant_table);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
160 script->constant_table = NULL;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
161 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
162
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
163 /* Set our new symbol table */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
164 script->symbol_table = symbol_table;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
165
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
166 return pn_script_internal_parse_string (script, string);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
167 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
168
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
169 /**
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
170 * pn_script_execute
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
171 * @script: a #PnScript
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
172 *
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
173 * Executes a script, updating all variabes in the associated symbol
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
174 * table as the script dictates.
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
175 */
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
176 void
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
177 pn_script_execute (PnScript *script)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
178 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
179 guint *op;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
180 gdouble stack[64];
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
181 guint stack_top = 0;
1604
1423ab8e5cbc [svn] Fix up the warning fixes; by Torbj«Órn Svensson (a.k.a. Azoff on #audacious).
chainsaw
parents: 1593
diff changeset
182 gdouble temp;
1507
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
183
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
184 g_return_if_fail (script != NULL);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
185 g_return_if_fail (PN_IS_SCRIPT (script));
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
186
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
187 if (! script->code)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
188 return;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
189
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
190 for (op = script->code; *op != PN_OP_END; op++)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
191 switch (*op)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
192 {
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
193 #define PUSH(f) stack[stack_top++] = f;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
194 #define POP stack_top--;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
195 #define POPV (stack[--stack_top])
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
196 #define PEEK (stack[stack_top-1])
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
197 #define PEEKN(n) (stack[stack_top-n])
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
198 case PN_OP_PUSHC:
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
199 case PN_OP_PUSHV:
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
200 PUSH (* (gdouble *)(*(++op)));
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
201 break;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
202
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
203 case PN_OP_POP:
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
204 POP;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
205 break;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
206
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
207 case PN_OP_SET:
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
208 *(gdouble *)(*(++op)) = PEEK;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
209 break;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
210
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
211 case PN_OP_ADD:
1593
6647d5cc717c [svn] Additional (PPC?) warning squashing by Joseph Jezak from Gentoo.
chainsaw
parents: 1507
diff changeset
212 /* PEEKN (2) += POPV; */
6647d5cc717c [svn] Additional (PPC?) warning squashing by Joseph Jezak from Gentoo.
chainsaw
parents: 1507
diff changeset
213 temp = POPV;
1604
1423ab8e5cbc [svn] Fix up the warning fixes; by Torbj«Órn Svensson (a.k.a. Azoff on #audacious).
chainsaw
parents: 1593
diff changeset
214 PEEKN(1) += temp;
1507
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
215 break;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
216
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
217 case PN_OP_SUB:
1593
6647d5cc717c [svn] Additional (PPC?) warning squashing by Joseph Jezak from Gentoo.
chainsaw
parents: 1507
diff changeset
218 /* PEEKN (2) -= POPV; */
6647d5cc717c [svn] Additional (PPC?) warning squashing by Joseph Jezak from Gentoo.
chainsaw
parents: 1507
diff changeset
219 temp = POPV;
1604
1423ab8e5cbc [svn] Fix up the warning fixes; by Torbj«Órn Svensson (a.k.a. Azoff on #audacious).
chainsaw
parents: 1593
diff changeset
220 PEEKN(1) -= temp;
1507
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
221 break;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
222
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
223 case PN_OP_MUL:
1593
6647d5cc717c [svn] Additional (PPC?) warning squashing by Joseph Jezak from Gentoo.
chainsaw
parents: 1507
diff changeset
224 /* PEEKN (2) *= POPV; */
6647d5cc717c [svn] Additional (PPC?) warning squashing by Joseph Jezak from Gentoo.
chainsaw
parents: 1507
diff changeset
225 temp = POPV;
1604
1423ab8e5cbc [svn] Fix up the warning fixes; by Torbj«Órn Svensson (a.k.a. Azoff on #audacious).
chainsaw
parents: 1593
diff changeset
226 PEEKN(1) *= temp;
1507
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
227 break;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
228
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
229 case PN_OP_DIV:
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
230 if (PEEK != 0)
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
231 PEEKN (2) /= PEEK;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
232 else
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
233 PEEK = 0;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
234 POP;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
235 break;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
236
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
237 case PN_OP_NEG:
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
238 PEEK = -PEEK;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
239 break;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
240
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
241 case PN_OP_POW:
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
242 PEEKN (2) = pow (PEEKN (2), PEEK);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
243 POP;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
244 break;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
245
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
246 case PN_OP_ABS:
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
247 PEEK = ABS (PEEK);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
248 break;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
249
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
250 case PN_OP_MAX:
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
251 PEEKN (2) = MAX (PEEK, PEEKN (2));
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
252 POP;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
253 break;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
254
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
255 case PN_OP_MIN:
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
256 PEEKN (2) = MIN (PEEK, PEEKN (2));
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
257 POP;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
258 break;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
259
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
260 case PN_OP_SIN:
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
261 PEEK = sin (PEEK);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
262 break;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
263
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
264 case PN_OP_COS:
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
265 PEEK = cos (PEEK);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
266 break;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
267
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
268 case PN_OP_TAN:
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
269 PEEK = tan (PEEK);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
270 break;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
271
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
272 case PN_OP_ASIN:
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
273 PEEK = asin (PEEK);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
274 break;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
275
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
276 case PN_OP_ACOS:
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
277 PEEK = acos (PEEK);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
278 break;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
279
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
280 case PN_OP_ATAN:
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
281 PEEK = atan (PEEK);
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
282 break;
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
283 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
284 }
0c5fdcf3f947 [svn] - incomplete stuff
nenolod
parents:
diff changeset
285