00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #define _GLOBLBSC_SOURCE_
00035
00036 #include "setup.h"
00037
00038 #if DEFGLOBAL_CONSTRUCT
00039
00040 #include "constrct.h"
00041 #include "extnfunc.h"
00042 #include "watch.h"
00043 #include "envrnmnt.h"
00044
00045 #include "globlcom.h"
00046 #include "globldef.h"
00047
00048 #if BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE
00049 #include "globlbin.h"
00050 #endif
00051
00052 #if CONSTRUCT_COMPILER && (! RUN_TIME)
00053 #include "globlcmp.h"
00054 #endif
00055
00056 #include "globlbsc.h"
00057
00058
00059
00060
00061
00062 static void SaveDefglobals(void *,void *,char *);
00063 static void ResetDefglobalAction(void *,struct constructHeader *,void *);
00064 #if DEBUGGING_FUNCTIONS && (! RUN_TIME)
00065 static unsigned DefglobalWatchAccess(void *,int,unsigned,struct expr *);
00066 static unsigned DefglobalWatchPrint(void *,char *,int,struct expr *);
00067 #endif
00068
00069
00070
00071
00072
00073 #if DEBUGGING_FUNCTIONS
00074 globle unsigned WatchGlobals = OFF;
00075 #endif
00076
00077
00078
00079
00080 globle void DefglobalBasicCommands(
00081 void *theEnv)
00082 {
00083 AddSaveFunction(theEnv,"defglobal",SaveDefglobals,40);
00084 EnvAddResetFunction(theEnv,"defglobal",ResetDefglobals,50);
00085
00086 #if ! RUN_TIME
00087 EnvDefineFunction2(theEnv,"get-defglobal-list",'m',PTIEF GetDefglobalListFunction,"GetDefglobalListFunction","01w");
00088 EnvDefineFunction2(theEnv,"undefglobal",'v',PTIEF UndefglobalCommand,"UndefglobalCommand","11w");
00089 EnvDefineFunction2(theEnv,"defglobal-module",'w',PTIEF DefglobalModuleFunction,"DefglobalModuleFunction","11w");
00090
00091 #if DEBUGGING_FUNCTIONS
00092 EnvDefineFunction2(theEnv,"list-defglobals",'v', PTIEF ListDefglobalsCommand,"ListDefglobalsCommand","01w");
00093 EnvDefineFunction2(theEnv,"ppdefglobal",'v',PTIEF PPDefglobalCommand,"PPDefglobalCommand","11w");
00094 AddWatchItem(theEnv,"globals",0,&WatchGlobals,0,DefglobalWatchAccess,DefglobalWatchPrint);
00095 #endif
00096
00097 #if (BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE)
00098 DefglobalBinarySetup(theEnv);
00099 #endif
00100
00101 #if CONSTRUCT_COMPILER && (! RUN_TIME)
00102 DefglobalCompilerSetup(theEnv);
00103 #endif
00104
00105 #endif
00106 }
00107
00108
00109
00110
00111
00112 globle void ResetDefglobals(
00113 void *theEnv)
00114 {
00115 if (! EnvGetResetGlobals(theEnv)) return;
00116 DoForAllConstructs(theEnv,ResetDefglobalAction,DefglobalData(theEnv)->DefglobalModuleIndex,TRUE,NULL);
00117 }
00118
00119
00120
00121
00122
00123 #if WIN_BTC
00124 #pragma argsused
00125 #endif
00126 static void ResetDefglobalAction(
00127 void *theEnv,
00128 struct constructHeader *theConstruct,
00129 void *buffer)
00130 {
00131 #if MAC_MCW || WIN_MCW || MAC_XCD
00132 #pragma unused(buffer)
00133 #endif
00134 struct defglobal *theDefglobal = (struct defglobal *) theConstruct;
00135 DATA_OBJECT assignValue;
00136
00137 if (EvaluateExpression(theEnv,theDefglobal->initial,&assignValue))
00138 {
00139 assignValue.type = SYMBOL;
00140 assignValue.value = EnvFalseSymbol(theEnv);
00141 }
00142
00143 QSetDefglobalValue(theEnv,theDefglobal,&assignValue,FALSE);
00144 }
00145
00146
00147
00148
00149
00150 static void SaveDefglobals(
00151 void *theEnv,
00152 void *theModule,
00153 char *logicalName)
00154 {
00155 SaveConstruct(theEnv,theModule,logicalName,DefglobalData(theEnv)->DefglobalConstruct);
00156 }
00157
00158
00159
00160
00161
00162 globle void UndefglobalCommand(
00163 void *theEnv)
00164 {
00165 UndefconstructCommand(theEnv,"undefglobal",DefglobalData(theEnv)->DefglobalConstruct);
00166 }
00167
00168
00169
00170
00171
00172 globle intBool EnvUndefglobal(
00173 void *theEnv,
00174 void *theDefglobal)
00175 {
00176 return(Undefconstruct(theEnv,theDefglobal,DefglobalData(theEnv)->DefglobalConstruct));
00177 }
00178
00179
00180
00181
00182
00183 globle void GetDefglobalListFunction(
00184 void *theEnv,
00185 DATA_OBJECT_PTR returnValue)
00186 {
00187 GetConstructListFunction(theEnv,"get-defglobal-list",returnValue,DefglobalData(theEnv)->DefglobalConstruct);
00188 }
00189
00190
00191
00192
00193
00194 globle void EnvGetDefglobalList(
00195 void *theEnv,
00196 DATA_OBJECT_PTR returnValue,
00197 void *theModule)
00198 {
00199 GetConstructList(theEnv,returnValue,DefglobalData(theEnv)->DefglobalConstruct,(struct defmodule *) theModule);
00200 }
00201
00202
00203
00204
00205
00206 globle void *DefglobalModuleFunction(
00207 void *theEnv)
00208 {
00209 return(GetConstructModuleCommand(theEnv,"defglobal-module",DefglobalData(theEnv)->DefglobalConstruct));
00210 }
00211
00212 #if DEBUGGING_FUNCTIONS
00213
00214
00215
00216
00217
00218 globle void PPDefglobalCommand(
00219 void *theEnv)
00220 {
00221 PPConstructCommand(theEnv,"ppdefglobal",DefglobalData(theEnv)->DefglobalConstruct);
00222 }
00223
00224
00225
00226
00227
00228 globle int PPDefglobal(
00229 void *theEnv,
00230 char *defglobalName,
00231 char *logicalName)
00232 {
00233 return(PPConstruct(theEnv,defglobalName,logicalName,DefglobalData(theEnv)->DefglobalConstruct));
00234 }
00235
00236
00237
00238
00239
00240 globle void ListDefglobalsCommand(
00241 void *theEnv)
00242 {
00243 ListConstructCommand(theEnv,"list-defglobals",DefglobalData(theEnv)->DefglobalConstruct);
00244 }
00245
00246
00247
00248
00249
00250 globle void EnvListDefglobals(
00251 void *theEnv,
00252 char *logicalName,
00253 void *vTheModule)
00254 {
00255 struct defmodule *theModule = (struct defmodule *) vTheModule;
00256
00257 ListConstruct(theEnv,DefglobalData(theEnv)->DefglobalConstruct,logicalName,theModule);
00258 }
00259
00260
00261
00262
00263
00264 #if WIN_BTC
00265 #pragma argsused
00266 #endif
00267 globle unsigned EnvGetDefglobalWatch(
00268 void *theEnv,
00269 void *theGlobal)
00270 {
00271 #if MAC_MCW || WIN_MCW || MAC_XCD
00272 #pragma unused(theEnv)
00273 #endif
00274
00275 return(((struct defglobal *) theGlobal)->watch);
00276 }
00277
00278
00279
00280
00281
00282 #if WIN_BTC
00283 #pragma argsused
00284 #endif
00285 globle void EnvSetDefglobalWatch(
00286 void *theEnv,
00287 unsigned newState,
00288 void *theGlobal)
00289 {
00290 #if MAC_MCW || WIN_MCW || MAC_XCD
00291 #pragma unused(theEnv)
00292 #endif
00293
00294 ((struct defglobal *) theGlobal)->watch = newState;
00295 }
00296
00297 #if ! RUN_TIME
00298
00299
00300
00301
00302
00303 #if WIN_BTC
00304 #pragma argsused
00305 #endif
00306 static unsigned DefglobalWatchAccess(
00307 void *theEnv,
00308 int code,
00309 unsigned newState,
00310 EXPRESSION *argExprs)
00311 {
00312 #if MAC_MCW || WIN_MCW || MAC_XCD
00313 #pragma unused(code)
00314 #endif
00315
00316 return(ConstructSetWatchAccess(theEnv,DefglobalData(theEnv)->DefglobalConstruct,newState,argExprs,
00317 EnvGetDefglobalWatch,EnvSetDefglobalWatch));
00318 }
00319
00320
00321
00322
00323
00324 #if WIN_BTC
00325 #pragma argsused
00326 #endif
00327 static unsigned DefglobalWatchPrint(
00328 void *theEnv,
00329 char *logName,
00330 int code,
00331 EXPRESSION *argExprs)
00332 {
00333 #if MAC_MCW || WIN_MCW || MAC_XCD
00334 #pragma unused(code)
00335 #endif
00336
00337 return(ConstructPrintWatchAccess(theEnv,DefglobalData(theEnv)->DefglobalConstruct,logName,argExprs,
00338 EnvGetDefglobalWatch,EnvSetDefglobalWatch));
00339 }
00340
00341 #endif
00342
00343 #endif
00344
00345 #endif
00346
00347