ficl.c (43078) | ficl.c (43139) |
---|---|
1/******************************************************************* 2** f i c l . c 3** Forth Inspired Command Language - external interface 4** Author: John Sadler (john_sadler@alum.mit.edu) 5** Created: 19 July 1997 6** 7*******************************************************************/ 8/* --- 15 unchanged lines hidden (view full) --- 24#ifdef TESTMAIN 25#include <stdlib.h> 26#else 27#include <stand.h> 28#endif 29#include <string.h> 30#include "ficl.h" 31 | 1/******************************************************************* 2** f i c l . c 3** Forth Inspired Command Language - external interface 4** Author: John Sadler (john_sadler@alum.mit.edu) 5** Created: 19 July 1997 6** 7*******************************************************************/ 8/* --- 15 unchanged lines hidden (view full) --- 24#ifdef TESTMAIN 25#include <stdlib.h> 26#else 27#include <stand.h> 28#endif 29#include <string.h> 30#include "ficl.h" 31 |
32#ifdef FICL_TRACE 33int ficl_trace = 0; 34#endif |
|
32 | 35 |
36 |
|
33/* 34** Local prototypes 35*/ 36 37 38/* 39** System statics 40** The system builds a global dictionary during its start --- 158 unchanged lines hidden (view full) --- 199 } 200 201 /* 202 ** the mysterious inner interpreter... 203 ** vmThrow gets you out of this loop with a longjmp() 204 */ 205 for (;;) 206 { | 37/* 38** Local prototypes 39*/ 40 41 42/* 43** System statics 44** The system builds a global dictionary during its start --- 158 unchanged lines hidden (view full) --- 203 } 204 205 /* 206 ** the mysterious inner interpreter... 207 ** vmThrow gets you out of this loop with a longjmp() 208 */ 209 for (;;) 210 { |
211#ifdef FICL_TRACE 212 char buffer[40]; 213 CELL *pc; 214#endif |
|
207 tempFW = *pVM->ip++; | 215 tempFW = *pVM->ip++; |
216#ifdef FICL_TRACE 217 if (ficl_trace && isAFiclWord(tempFW)) 218 { 219 extern void literalParen(FICL_VM*); 220 extern void stringLit(FICL_VM*); 221 extern void ifParen(FICL_VM*); 222 extern void branchParen(FICL_VM*); 223 extern void qDoParen(FICL_VM*); 224 extern void doParen(FICL_VM*); 225 extern void loopParen(FICL_VM*); 226 extern void plusLoopParen(FICL_VM*); 227 228 if (tempFW->code == literalParen) 229 { 230 CELL v = *++pc; 231 if (isAFiclWord(v.p)) 232 { 233 FICL_WORD *pLit = (FICL_WORD *)v.p; 234 sprintf(buffer, " literal %.*s (%#lx)", 235 pLit->nName, pLit->name, v.u); 236 } 237 else 238 sprintf(buffer, " literal %ld (%#lx)", v.i, v.u); 239 } 240 else if (tempFW->code == stringLit) 241 { 242 FICL_STRING *sp = (FICL_STRING *)(void *)++pc; 243 pc = (CELL *)alignPtr(sp->text + sp->count + 1) - 1; 244 sprintf(buffer, " s\" %.*s\"", sp->count, sp->text); 245 } 246 else if (tempFW->code == ifParen) 247 { 248 CELL c = *++pc; 249 if (c.i > 0) 250 sprintf(buffer, " if / while (branch rel %ld)", c.i); 251 else 252 sprintf(buffer, " until (branch rel %ld)", c.i); 253 } 254 else if (tempFW->code == branchParen) 255 { 256 CELL c = *++pc; 257 if (c.i > 0) 258 sprintf(buffer, " else (branch rel %ld)", c.i); 259 else 260 sprintf(buffer, " repeat (branch rel %ld)", c.i); 261 } 262 else if (tempFW->code == qDoParen) 263 { 264 CELL c = *++pc; 265 sprintf(buffer, " ?do (leave abs %#lx)", c.u); 266 } 267 else if (tempFW->code == doParen) 268 { 269 CELL c = *++pc; 270 sprintf(buffer, " do (leave abs %#lx)", c.u); 271 } 272 else if (tempFW->code == loopParen) 273 { 274 CELL c = *++pc; 275 sprintf(buffer, " loop (branch rel %#ld)", c.i); 276 } 277 else if (tempFW->code == plusLoopParen) 278 { 279 CELL c = *++pc; 280 sprintf(buffer, " +loop (branch rel %#ld)", c.i); 281 } 282 else /* default: print word's name */ 283 { 284 sprintf(buffer, " %.*s", tempFW->nName, tempFW->name); 285 } 286 287 vmTextOut(pVM, buffer, 1); 288 } 289 else if (ficl_trace) /* probably not a word - punt and print value */ 290 { 291 sprintf(buffer, " %ld (%#lx)", pc->i, pc->u); 292 vmTextOut(pVM, buffer, 1); 293 } 294#endif FICL_TRACE |
|
208 /* 209 ** inline code for 210 ** vmExecute(pVM, tempFW); 211 */ 212 pVM->runningWord = tempFW; 213 tempFW->code(pVM); 214 } 215 --- 218 unchanged lines hidden --- | 295 /* 296 ** inline code for 297 ** vmExecute(pVM, tempFW); 298 */ 299 pVM->runningWord = tempFW; 300 tempFW->code(pVM); 301 } 302 --- 218 unchanged lines hidden --- |