/**-- CHAIN words - compare with win32forth Copyright (C) Tektronix, Inc. 1998 - 2001. All rights reserved. @see GNU LGPL @author Tektronix CTE @(#) %derived_by: guidod % @version %version: 1.12 % (%date_modified: Tue Jul 09 16:19:55 2002 %) @description This wordset implements CHAINs of words as seen in win32forth - unlike LINK-chains these chains will be watched by the system and referenced globabally via the chain-link variable. During FORGET we can prune these chains and keep them in the state they deserve to be at that point. In general, CHAINs are used as defer-chains which hold a series of of executions tokens in each chain item, and a call to `do-chain` will execute each one in that chain. new-chain semicolon-chain : items are usually called resolve-* new-chain forget-chain : items are usually called trim-* new-chain unload-chain : items are usually called release-* a chain-item is either a PRIMITIVE or a COLONWORD we simulate that it is part of a colonword - setting the IP to the address of the CHAIN-ITEM's body should make it callable. ITC: with XT: the XT at PRIM: HERE+1 | CODE* (simulating a prim XT) CTC: with XT: flatten XT being: CODE* | BODY* at PRIM CODE* STC variants: COLONWORDS are PRIMITIVES too, so just CODE* WARNING: this wordset is not complete - it should hang on to the forget-routine to be able to prune chains given that their chain-heads are registered in a system-wide chainlist too. This has not been implemented. */ /* The win32forth model has shown to be not directly usable within the pfe core parts - in win32forth each routine is itself just a forth routine while in pfe there is usually a difference between a colon-routine and a (C-made) primitive-routine so that they can not easily be universally referenced as XTs. It would be a rather complex endavour requiring quite some system runtime resources according to time and speed. Instead, the chain-wordlist system has been modelled at greater extents giving you largely the same functionality on different grounds. @{ */ #if defined(__version_control__) && defined(__GNUC__)static char* id __attribute__((unused)) = "@(#) $Id: %full_filespec: chain-ext.c~1.12:csrc:bln_mpt1!1 % $" #endif #define _P4_SOURCE 1 #include <pfe/pfe-base.h> #include <pfe/chain-ext.h> #include <pfe/debug-ext.h> #include <pfe/logging.h> #ifndef _export #define _export /*; use a linkvariable lvalue */ # define FX_LINK_COMMA(__link) do { \ register void** __here = (void*) p4_DP; \ __here[0] = (void*)(__link); \ (void*)(__link) = (void*)__here; \ p4_DP = (p4char*)(++__here); } while (0) /*use a linkvariable lvalue */ # define FX_LINK_COMMA_AT_END(__link) do { \ register void** __prev = (void**) &(__link); \ while (*__prev) __prev = (void**) (*__prev); \ *__prev = (void*)(p4_DP); FX_PCOMMA (0); } while (0) #endif
/* |
/**
|
/** |
struct _Link
|
struct _Chain
|
/**
|
/**
|
void p4_do_chain (Link* link)
|
void p4_do_chain (p4xt* link)
|
/**
|
/**
|
/**
|
P4_LISTWORDS (chain) =
|
/* |
/* |