1 /* C file produced by GAC */
2 #include "compiled.h"
3 #define FILE_CRC  "58141340"
4 
5 /* global variables used in handlers */
6 static GVar G_Print;
7 static Obj  GF_Print;
8 static GVar G_runtest;
9 static GVar G_InfoLevel;
10 static Obj  GF_InfoLevel;
11 static GVar G_InfoDebug;
12 static Obj  GC_InfoDebug;
13 static GVar G_SetInfoLevel;
14 static Obj  GF_SetInfoLevel;
15 
16 /* record names used in handlers */
17 
18 /* information for the functions */
19 static Obj  NameFunc[3];
20 static Obj FileName;
21 
22 /* handler for function 2 */
HdlrFunc2(Obj self)23 static Obj  HdlrFunc2 (
24  Obj  self )
25 {
26  Obj t_1 = 0;
27  Obj t_2 = 0;
28  Obj t_3 = 0;
29  Obj t_4 = 0;
30  Bag oldFrame;
31 
32  /* allocate new stack frame */
33  SWITCH_TO_NEW_FRAME(self,0,0,oldFrame);
34 
35  /* Print( InfoLevel( InfoDebug ), "\n" ); */
36  t_1 = GF_Print;
37  t_3 = GF_InfoLevel;
38  t_4 = GC_InfoDebug;
39  CHECK_BOUND( t_4, "InfoDebug" );
40  if ( TNUM_OBJ( t_3 ) == T_FUNCTION ) {
41   t_2 = CALL_1ARGS( t_3, t_4 );
42  }
43  else {
44   t_2 = DoOperation2Args( CallFuncListOper, t_3, NewPlistFromArgs( t_4 ) );
45  }
46  CHECK_FUNC_RESULT( t_2 );
47  t_3 = MakeString( "\n" );
48  if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) {
49   CALL_2ARGS( t_1, t_2, t_3 );
50  }
51  else {
52   DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) );
53  }
54 
55  /* Info( ... ); */
56  t_1 = GC_InfoDebug;
57  CHECK_BOUND( t_1, "InfoDebug" );
58  t_3 = InfoCheckLevel( t_1, INTOBJ_INT(2) );
59  if ( t_3 == True ) {
60   t_2 = NEW_PLIST( T_PLIST, 1 );
61   SET_LEN_PLIST( t_2, 1 );
62   t_3 = MakeString( "Do not print" );
63   SET_ELM_PLIST( t_2, 1, t_3 );
64   CHANGED_BAG(t_2);
65   InfoDoPrint( t_1, INTOBJ_INT(2), t_2 );
66  }
67 
68  /* Info( ... ); */
69  t_1 = GC_InfoDebug;
70  CHECK_BOUND( t_1, "InfoDebug" );
71  t_3 = InfoCheckLevel( t_1, INTOBJ_INT(1) );
72  if ( t_3 == True ) {
73   t_2 = NEW_PLIST( T_PLIST, 1 );
74   SET_LEN_PLIST( t_2, 1 );
75   t_3 = MakeString( "print this A" );
76   SET_ELM_PLIST( t_2, 1, t_3 );
77   CHANGED_BAG(t_2);
78   InfoDoPrint( t_1, INTOBJ_INT(1), t_2 );
79  }
80 
81  /* SetInfoLevel( InfoDebug, 2 ); */
82  t_1 = GF_SetInfoLevel;
83  t_2 = GC_InfoDebug;
84  CHECK_BOUND( t_2, "InfoDebug" );
85  if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) {
86   CALL_2ARGS( t_1, t_2, INTOBJ_INT(2) );
87  }
88  else {
89   DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, INTOBJ_INT(2) ) );
90  }
91 
92  /* Print( InfoLevel( InfoDebug ), "\n" ); */
93  t_1 = GF_Print;
94  t_3 = GF_InfoLevel;
95  t_4 = GC_InfoDebug;
96  CHECK_BOUND( t_4, "InfoDebug" );
97  if ( TNUM_OBJ( t_3 ) == T_FUNCTION ) {
98   t_2 = CALL_1ARGS( t_3, t_4 );
99  }
100  else {
101   t_2 = DoOperation2Args( CallFuncListOper, t_3, NewPlistFromArgs( t_4 ) );
102  }
103  CHECK_FUNC_RESULT( t_2 );
104  t_3 = MakeString( "\n" );
105  if ( TNUM_OBJ( t_1 ) == T_FUNCTION ) {
106   CALL_2ARGS( t_1, t_2, t_3 );
107  }
108  else {
109   DoOperation2Args( CallFuncListOper, t_1, NewPlistFromArgs( t_2, t_3 ) );
110  }
111 
112  /* Info( ... ); */
113  t_1 = GC_InfoDebug;
114  CHECK_BOUND( t_1, "InfoDebug" );
115  t_3 = InfoCheckLevel( t_1, INTOBJ_INT(3) );
116  if ( t_3 == True ) {
117   t_2 = NEW_PLIST( T_PLIST, 1 );
118   SET_LEN_PLIST( t_2, 1 );
119   t_3 = MakeString( "Do not print" );
120   SET_ELM_PLIST( t_2, 1, t_3 );
121   CHANGED_BAG(t_2);
122   InfoDoPrint( t_1, INTOBJ_INT(3), t_2 );
123  }
124 
125  /* Info( ... ); */
126  t_1 = GC_InfoDebug;
127  CHECK_BOUND( t_1, "InfoDebug" );
128  t_3 = InfoCheckLevel( t_1, INTOBJ_INT(2) );
129  if ( t_3 == True ) {
130   t_2 = NEW_PLIST( T_PLIST, 1 );
131   SET_LEN_PLIST( t_2, 1 );
132   t_3 = MakeString( "print this B" );
133   SET_ELM_PLIST( t_2, 1, t_3 );
134   CHANGED_BAG(t_2);
135   InfoDoPrint( t_1, INTOBJ_INT(2), t_2 );
136  }
137 
138  /* Info( ... ); */
139  t_1 = GC_InfoDebug;
140  CHECK_BOUND( t_1, "InfoDebug" );
141  t_3 = InfoCheckLevel( t_1, INTOBJ_INT(1) );
142  if ( t_3 == True ) {
143   t_2 = NEW_PLIST( T_PLIST, 1 );
144   SET_LEN_PLIST( t_2, 1 );
145   t_3 = MakeString( "print this C" );
146   SET_ELM_PLIST( t_2, 1, t_3 );
147   CHANGED_BAG(t_2);
148   InfoDoPrint( t_1, INTOBJ_INT(1), t_2 );
149  }
150 
151  /* return; */
152  SWITCH_TO_OLD_FRAME(oldFrame);
153  return 0;
154 
155  /* return; */
156  SWITCH_TO_OLD_FRAME(oldFrame);
157  return 0;
158 }
159 
160 /* handler for function 1 */
HdlrFunc1(Obj self)161 static Obj  HdlrFunc1 (
162  Obj  self )
163 {
164  Obj t_1 = 0;
165  Obj t_2 = 0;
166  Bag oldFrame;
167 
168  /* allocate new stack frame */
169  SWITCH_TO_NEW_FRAME(self,0,0,oldFrame);
170 
171  /* runtest := function (  )
172       Print( InfoLevel( InfoDebug ), "\n" );
173       Info( InfoDebug, 2, "Do not print" );
174       Info( InfoDebug, 1, "print this A" );
175       SetInfoLevel( InfoDebug, 2 );
176       Print( InfoLevel( InfoDebug ), "\n" );
177       Info( InfoDebug, 3, "Do not print" );
178       Info( InfoDebug, 2, "print this B" );
179       Info( InfoDebug, 1, "print this C" );
180       return;
181   end; */
182  t_1 = NewFunction( NameFunc[2], 0, 0, HdlrFunc2 );
183  SET_ENVI_FUNC( t_1, STATE(CurrLVars) );
184  t_2 = NewFunctionBody();
185  SET_STARTLINE_BODY(t_2, 1);
186  SET_ENDLINE_BODY(t_2, 10);
187  SET_FILENAME_BODY(t_2, FileName);
188  SET_BODY_FUNC(t_1, t_2);
189  AssGVar( G_runtest, t_1 );
190 
191  /* return; */
192  SWITCH_TO_OLD_FRAME(oldFrame);
193  return 0;
194 
195  /* return; */
196  SWITCH_TO_OLD_FRAME(oldFrame);
197  return 0;
198 }
199 
200 /* 'PostRestore' restore gvars, rnams, functions */
PostRestore(StructInitInfo * module)201 static Int PostRestore ( StructInitInfo * module )
202 {
203 
204  /* global variables used in handlers */
205  G_Print = GVarName( "Print" );
206  G_runtest = GVarName( "runtest" );
207  G_InfoLevel = GVarName( "InfoLevel" );
208  G_InfoDebug = GVarName( "InfoDebug" );
209  G_SetInfoLevel = GVarName( "SetInfoLevel" );
210 
211  /* record names used in handlers */
212 
213  /* information for the functions */
214  NameFunc[1] = 0;
215  NameFunc[2] = 0;
216 
217  /* return success */
218  return 0;
219 
220 }
221 
222 
223 /* 'InitKernel' sets up data structures, fopies, copies, handlers */
InitKernel(StructInitInfo * module)224 static Int InitKernel ( StructInitInfo * module )
225 {
226 
227  /* global variables used in handlers */
228  InitFopyGVar( "Print", &GF_Print );
229  InitFopyGVar( "InfoLevel", &GF_InfoLevel );
230  InitCopyGVar( "InfoDebug", &GC_InfoDebug );
231  InitFopyGVar( "SetInfoLevel", &GF_SetInfoLevel );
232 
233  /* information for the functions */
234  InitGlobalBag( &FileName, "info.g:FileName("FILE_CRC")" );
235  InitHandlerFunc( HdlrFunc1, "info.g:HdlrFunc1("FILE_CRC")" );
236  InitGlobalBag( &(NameFunc[1]), "info.g:NameFunc[1]("FILE_CRC")" );
237  InitHandlerFunc( HdlrFunc2, "info.g:HdlrFunc2("FILE_CRC")" );
238  InitGlobalBag( &(NameFunc[2]), "info.g:NameFunc[2]("FILE_CRC")" );
239 
240  /* return success */
241  return 0;
242 
243 }
244 
245 /* 'InitLibrary' sets up gvars, rnams, functions */
InitLibrary(StructInitInfo * module)246 static Int InitLibrary ( StructInitInfo * module )
247 {
248  Obj func1;
249  Obj body1;
250 
251  /* Complete Copy/Fopy registration */
252  UpdateCopyFopyInfo();
253  FileName = MakeImmString( "info.g" );
254  PostRestore(module);
255 
256  /* create all the functions defined in this module */
257  func1 = NewFunction(NameFunc[1],0,0,HdlrFunc1);
258  SET_ENVI_FUNC( func1, STATE(CurrLVars) );
259  body1 = NewFunctionBody();
260  SET_BODY_FUNC( func1, body1 );
261  CHANGED_BAG( func1 );
262  CALL_0ARGS( func1 );
263 
264  /* return success */
265  return 0;
266 
267 }
268 
269 /* <name> returns the description of this module */
270 static StructInitInfo module = {
271  .type        = MODULE_DYNAMIC,
272  .name        = "info.g",
273  .crc         = 58141340,
274  .initKernel  = InitKernel,
275  .initLibrary = InitLibrary,
276  .postRestore = PostRestore,
277 };
278 
Init__Dynamic(void)279 StructInitInfo * Init__Dynamic ( void )
280 {
281  return &module;
282 }
283 
284 /* compiled code ends here */
285