Go to the source code of this file.
#define OFFSET_ADDRESS 12 |
#define DESCR1 |
( |
|
x) | |
((x)->unode.a[2]) |
#define DESCR2 |
( |
|
x) | |
((x)->unode.a[3]) |
#define PARENT |
( |
|
x) | |
(DESCR1(x)->unode.a[0]) |
#define NAME |
( |
|
x) | |
(DESCR1(x)->unode.a[2]) |
#define ADDRESS |
( |
|
x) | |
(DESCR1(x)->unode.n[3]) |
#define OFFSET |
( |
|
x) | |
(DESCR1(x)->unode.n[3]) |
#define VALUE |
( |
|
x) | |
(DESCR1(x)->unode.a[3]) |
#define LEVEL |
( |
|
x) | |
(DESCR1(x)->unode.b[4]) |
#define CTYPE |
( |
|
x) | |
(DESCR1(x)->unode.b[5]) |
#define PRIORITY |
( |
|
x) | |
(DESCR1(x)->unode.b[5]) |
#define LARGS |
( |
|
x) | |
(DESCR1(x)->unode.b[6]) |
#define RARGS |
( |
|
x) | |
(DESCR1(x)->unode.b[7]) |
#define DEFINITIONS |
( |
|
x) | |
(DESCR2(x)->unode.a[0]) |
#define LOCALS |
( |
|
x) | |
(DESCR2(x)->unode.a[1]) |
#define BINARY |
( |
|
x) | |
(DESCR2(x)->unode.a[3]) |
#define VARTYPE |
( |
|
x) | |
((x)->unode.b[5]) |
#define FLAG_PRIMITIVE 0x0001 |
#define FLAG_VARIABLE 0x0002 |
#define FLAG_FUNCTION 0x0004 |
#define FLAG_COMMAND 0x0008 |
#define FLAG_CAN_BE_UNARY 0x0010 |
#define FLAG_INFINITE_ARGS 0x0020 |
#define FLAG_MAY_SKIP_LAST_ARG 0x0040 |
#define FLAG_PROCESS_ARGS 0x0080 |
#define FLAG_PUSH_PARENT 0x0100 |
#define FLAG_SET_ONE_VAR 0x0200 |
#define FLAG_SET_ALL_VARS 0x0400 |
#define FLAG_MAY_HAVE_EXTRA_ARG 0x0800 |
#define FLAG_PUSH_FRAME 0x1000 |
#define FLAG_PRINT_VARS 0x2000 |
#define FLAG_EQUAL_VARS 0x4000 |
#define FLAG_PUSH_MODE 0x8000 |
#define ALL_VAR_FLAGS 0xFFFF |
#define VAR_TYPE_NORMAL 0x00 |
#define VAR_TYPE_RUNTIME 0x01 |
#define VAR_TYPE_TAG 0x02 |
#define VAR_TYPE_EXTERNAL 0x80 |
#define VAR_TYPE_INTERNAL 0xC0 |
#define FLAG_PRIORITY_MUL 0x010000 |
#define FLAG_PRIORITY_ADD 0x020000 |
#define FLAG_PRIORITY_LOG 0x040000 |
#define FLAG_PRIORITY_CMP 0x080000 |
#define BASE_OFFSET_PARAMS 12 |
#define BASE_OFFSET_PARAMSCOUNT 8 |
#define BASE_OFFSET_DYNAMIC 0 |
#define BASE_OFFSET_STATIC -4 |
#define BASE_OFFSET_PARENT -8 |
#define BASE_OFFSET_REPEATCHAIN -12 |
#define BASE_OFFSET_TEST -16 |
#define BASE_OFFSET_LOCALS -20 |
#define LOGO_VERSION TEXT("0.0") |
#define LOGO_DIALECT TEXT("Lhogho") |
#define IS_UNBOUND |
( |
|
x) | |
((x)==unbound) |
#define IS_STOPPED |
( |
|
x) | |
((x)==stopped) |
#define IS_EXTERNAL |
( |
|
x) | |
((VARTYPE(x)&0xC0)==VAR_TYPE_EXTERNAL) |
#define IS_INTERNAL |
( |
|
x) | |
((VARTYPE(x)&0xC0)==VAR_TYPE_INTERNAL) |
#define ROOT_VAR_NAME TEXT("%root%") |
#define GLOBALS_VAR_NAME TEXT("%globals%") |
as local variables to the root variable. The names of primitives are taken from TR_PRIMITIVES, the properties are taken from vars[]. Two words :to and :end are created.
Initializes the variables module by creating the system root variable which is named as defined by ROOT_VAR_NAME, and globals variable defined by
Definition at line 525 of file vars.c.
528 printf(
"<VAR> Vars initialized\n");
Finilizes the Vars module by freeing :to, :end and :root atoms. Deleting :root will recursively delete all other variables including the primitives.
Some system primitive variables like fullprintp, printwidthlimit, and printdepthlimit does not need individual finalization, because they are included in globals and finalized when globals is finalized.
Definition at line 661 of file vars.c.
721 printf(
"<VAR> Vars finalized\n");
- Parameters
-
name | word atom for the name of the variable |
parent | var atom for the parent of the variable |
attach | 1=attach to parent, 0=do not attach |
- Returns
- var atom
Creates a var atom describing a variable with given name and parent. The reference count of the var is set to 1, the reference count of name
is increased, the reference count of parent
is not changed. The function automatically creates the first descriptor of the var atom. The second descriptor is left uninitialized - it could be later created by need_descr2()
if needed.
The newly created var atom is included in the list of local variables of the parent only if attach
!= 0. Otherwise var has a parent, but the parent does not know about the child var.
Definition at line 750 of file vars.c.
780 printf(
"<ATOM> [%08x] var="STR"\n",(
int)a,
STRING(name));
791 #ifdef DEBUG_RUNTIME_ATOMS
795 dump_atom_address( a );
800 #ifdef DEBUG_COMPILETIME_ATOMS
804 dump_atom_address( a );
- Parameters
-
name | word atom for the name of the variable |
function | var atom for the parent of the variable |
quoted | shows whether the name is quoted |
- Returns
- var or error atom
Creates a local variable in a function. The input name
contains the name of the local variable together with the : or " character (if quoted!=0). If such local variable does not exist in the function, then it is created and returned to the caller. Otherwise an error atom of ERROR_DUPLICATE_INPUT error is returned.
Definition at line 1258 of file vars.c.
1261 assert( IS_VAR(
function) );
1265 assert(
LENGTH(name)>1 );
1274 real_name =
USE( name );
- Parameters
-
Deletes var atom by returning it back to the data pool. All structures pointed to by the var atom are dereferences (and most-likely) deleted.
Definition at line 864 of file vars.c.
- Parameters
-
a | atom to dump |
level | dump level |
Dumps var atom through the current outter function.
Definition at line 937 of file vars.c.
940 #define DUMP_BUF_SIZE 128
948 for( i=0; i<level; i++ )
outter(
TEXT(
" "), 3 );
- Parameters
-
name | word atom containing the searched name |
parent | var atom where to start the search |
- Returns
- found var atom or
NULL
if not found
- Note
- search is syntax-scope based
Searches a variable named name
starting from variable parent
. If not found found the search continues with the parent of parent
, then with its grandparent, and so on untill the root is reached. If still not found search continues within the globals variable.
This search schema can find only variables known at the time of compilation. Also, the search is strictly syntax-scope based.
Definition at line 1015 of file vars.c.
1023 #ifdef DEBUG_FIND_VAR
1024 printf(
"<FINDVAR> Search ");
dumpln(name);
1025 printf(
"<FINDVAR> Current var tree ");
dumpln(
root);
1030 for( ; parent; parent=
PARENT(parent) )
1032 #ifdef DEBUG_FIND_VAR
1033 printf(
"<FINDVAR> Search it in parent ");
dumpln(
NAME(parent));
1036 #ifdef DEBUG_FIND_VAR
1037 if( a ) { printf(
"<FINDVAR> Found in ");
dumpln(
NAME(parent)); }
1042 #ifdef DEBUG_FIND_VAR
1046 #ifdef DEBUG_FIND_VAR
1051 #ifdef DEBUG_FIND_VAR
1052 printf(
"<FINDVAR> Not found\n");
- Parameters
-
name | word atom containing the searched name |
parent | var atom where to start the search |
- Returns
- found var atom or
NULL
if not found
- Note
- search is syntax-scope based
Searches a variable named name
starting from variable parent
. If found returns the var atom, otherwise returns NULL
. The search scans only the variables parent
. It does not scan its parents.
This search schema can find only variables known at the time of compilation. Also, the search is strictly syntax-scope based.
If the parent is a list atom, then just scan its elements (as if this is the LOCALS field of a var)
Definition at line 1210 of file vars.c.
1228 if( !a )
return NULL;
- Parameters
-
name | word atom containing the searched name |
frame | starting frame for the search |
- Returns
- found var atom or
NULL
if not found
- Note
- search is syntax-scope based
Searches a variable named name
starting from the given stack frame. Search is done in the list of variables created at run-time.
If the variable is not found in the runtimers, then search continues with compile-time vars.
If still not found, the search moves to the parent frame.
If not found in all frames up to the root, then scan the globals var.
Definition at line 1133 of file vars.c.
1142 #ifdef DEBUG_FIND_RUNTIME_VAR
1143 printf(
"<FIND_RUNTIME_VAR> Search ");
dumpln(name);
1152 #ifdef DEBUG_FIND_RUNTIME_VAR
1153 if( var ) { printf(
"<FIND_RUNTIME_VAR> Found runtimer ");
dumpln(
NAME(var)); }
1155 if( var )
return var;
1160 #ifdef DEBUG_FIND_RUNTIME_VAR
1161 if( var ) { printf(
"<FIND_RUNTIME_VAR> Found local ");
dumpln(
NAME(var)); }
1163 if( var )
return var;
1166 if( parent==
root )
break;
1169 frame = *((
int*)(frame));
1175 #ifdef DEBUG_FIND_RUNTIME_VAR
1176 if( var ) { printf(
"<FIND_RUNTIME_VAR> Found global ");
dumpln(
NAME(var)); }
1178 if( var )
return var;
1181 #ifdef DEBUG_FIND_RUNTIME_VAR
1182 printf(
"<FIND_RUNTIME_VAR> Not found\n");
- Parameters
-
var | var which descriptor will be created |
- Returns
- 1 if descriptor was created
Creates the second descriptor of a var atom if it does not exist. All the values of the new second descriptor are set to empty lists.
Definition at line 826 of file vars.c.
829 if(
DESCR2(var) )
return 0;
void copy_local_vars |
( |
int |
frame) | |
|
- Parameters
-
frame | current frame pointer |
- Returns
- same atom as input
This function is called from the generated code. It copies all local variables of the current frame into the dynamic parent (i.e. caller).
Copying variables consideres these cases:
No Flag Type Action
- primitive * not copied
- * tag not copied
- variable normal
- variable runtime
- variable else not copied
- func/cmd normal
- func/cmd runtime
- func/cmd external
- func/cmd internal
Definition at line 1315 of file vars.c.
1318 int callee_frame = frame;
1352 *localsp =
new_list( to_var, *localsp );
1374 value = *(
atom_t*)((
char*)callee_frame+
OFFSET(from_var));
1378 value =
VALUE( from_var );
1388 *varptr =
USE( value );
1410 to_var =
USE( from_var );
1438 void copy_var_or_func(
atom_t from_var )
1457 if(
IS_VARIABLE( from_var ) ) copy_var( from_var, to_var );