irods  4.2.8
About: iRODS (the integrated Rule Oriented Data System) is a distributed data-management system for creating data grids, digital libraries, persistent archives, and real-time data systems.
  Fossies Dox: irods-4.2.8.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

utils.cpp
Go to the documentation of this file.
1 /* For copyright information please refer to files in the COPYRIGHT directory
2  */
3 #include "utils.hpp"
4 #include "restructs.hpp"
5 #include "conversion.hpp"
6 #include "configuration.hpp"
7 #include "reVariableMap.gen.hpp"
8 /* make a new type by substituting tvars with fresh tvars */
10  Hashtable *varTable = newHashTable2( 100, r );
11  /* todo add oom handler here */
12  ExprType *dup = dupTypeAux( ty, r, varTable );
13  return dup;
14 
15 
16 }
17 
19  if ( getNodeType( a ) != getNodeType( b ) || getVararg( a ) != getVararg( b ) ) {
20  return 0;
21  }
22  switch ( getNodeType( a ) ) {
23  case T_CONS:
24  case T_TUPLE:
25  if ( T_CONS_ARITY( a ) == T_CONS_ARITY( b ) &&
26  ( getNodeType( a ) == T_TUPLE || strcmp( T_CONS_TYPE_NAME( a ), T_CONS_TYPE_NAME( b ) ) == 0 ) ) {
27  int i;
28  for ( i = 0; i < T_CONS_ARITY( a ); i++ ) {
29  if ( !typeEqSyntatic( T_CONS_TYPE_ARG( a, i ), T_CONS_TYPE_ARG( b, i ) ) ) {
30  return 0;
31  }
32  }
33  return 1;
34  }
35  return 0;
36  case T_VAR:
37  return T_VAR_ID( a ) == T_VAR_ID( b );
38  case T_IRODS:
39  return strcmp( a->text, b->text ) == 0;
40  default:
41  return 1;
42  }
43 
44 }
45 
46 ExprType *dupTypeAux( ExprType *ty, Region *r, Hashtable *varTable ) {
47  ExprType **paramTypes;
48  int i;
49  ExprType *newt;
50  ExprType *exist;
51  char *name;
52  char buf[128];
53  switch ( getNodeType( ty ) ) {
54  case T_CONS:
55  paramTypes = ( ExprType ** ) region_alloc( r, sizeof( ExprType * ) * T_CONS_ARITY( ty ) );
56  for ( i = 0; i < T_CONS_ARITY( ty ); i++ ) {
57  paramTypes[i] = dupTypeAux( T_CONS_TYPE_ARG( ty, i ), r, varTable );
58  }
59  newt = newConsType( T_CONS_ARITY( ty ), T_CONS_TYPE_NAME( ty ), paramTypes, r );
60  newt->option = ty->option;
61  break;
62  case T_TUPLE:
63  paramTypes = ( ExprType ** ) region_alloc( r, sizeof( ExprType * ) * T_CONS_ARITY( ty ) );
64  for ( i = 0; i < T_CONS_ARITY( ty ); i++ ) {
65  paramTypes[i] = dupTypeAux( T_CONS_TYPE_ARG( ty, i ), r, varTable );
66  }
67  newt = newTupleType( T_CONS_ARITY( ty ), paramTypes, r );
68  newt->option = ty->option;
69  break;
70  case T_VAR:
71  name = getTVarName( T_VAR_ID( ty ), buf );
72  exist = ( ExprType * )lookupFromHashTable( varTable, name );
73  if ( exist != NULL ) {
74  newt = exist;
75  }
76  else {
77  newt = newTVar2( T_VAR_NUM_DISJUNCTS( ty ), T_VAR_DISJUNCTS( ty ), r );
78  insertIntoHashTable( varTable, name, newt );
79 
80  }
81  newt->option = ty->option;
82  break;
83  case T_FLEX:
84  paramTypes = ( ExprType ** ) region_alloc( r, sizeof( ExprType * ) * 1 );
85  paramTypes[0] = dupTypeAux( ty->subtrees[0], r, varTable );
86  newt = newExprType( T_FLEX, 1, paramTypes, r );
87  newt->option = ty->option;
88  break;
89 
90  default:
91  newt = ty;
92  break;
93  }
94  return newt;
95 }
97  return ( getNodeType( a ) != T_CONS && getNodeType( a ) == getNodeType( b ) ) ||
98  ( getNodeType( b ) == T_DOUBLE && getNodeType( a ) == T_INT ) ||
99  ( getNodeType( b ) == T_DOUBLE && getNodeType( a ) == T_STRING ) ||
100  ( getNodeType( b ) == T_INT && getNodeType( a ) == T_DOUBLE ) ||
101  ( getNodeType( b ) == T_INT && getNodeType( a ) == T_STRING ) ||
102  ( getNodeType( b ) == T_STRING && getNodeType( a ) == T_INT ) ||
103  ( getNodeType( b ) == T_STRING && getNodeType( a ) == T_DOUBLE ) ||
104  ( getNodeType( b ) == T_STRING && getNodeType( a ) == T_BOOL ) ||
105  ( getNodeType( b ) == T_BOOL && getNodeType( a ) == T_STRING ) ||
106  ( getNodeType( b ) == T_DATETIME && getNodeType( a ) == T_INT ) ||
107  ( getNodeType( b ) == T_DATETIME && getNodeType( a ) == T_DOUBLE ) ||
108  ( getNodeType( b ) == T_DYNAMIC ) ||
109  ( getNodeType( a ) == T_DYNAMIC ) ||
110  ( getNodeType( a ) == T_CONS && getNodeType( b ) == T_CONS && coercible( T_CONS_TYPE_ARG( a, 0 ), T_CONS_TYPE_ARG( b, 0 ) ) );
111 }
112 /*
113  * unify a free tvar or union type with some other type
114  */
115 ExprType* unifyTVarL( ExprType *type, ExprType* expected, Hashtable *varTypes, Region *r ) {
116  char buf[128];
117  if ( T_VAR_NUM_DISJUNCTS( type ) == 0 ) { /* free */
118  if ( occursIn( type, expected ) ) {
119  return NULL;
120  }
121  insertIntoHashTable( varTypes, getTVarName( T_VAR_ID( type ), buf ), expected );
122  return dereference( expected, varTypes, r );
123  }
124  else { /* union type */
125  int i;
126  ExprType *ty = NULL;
127  for ( i = 0; i < T_VAR_NUM_DISJUNCTS( type ); i++ ) {
128  if ( getNodeType( T_VAR_DISJUNCT( type, i ) ) == getNodeType( expected ) ) { /* union types can only include primitive types */
129  ty = expected;
130  break;
131  }
132  }
133  if ( ty != NULL ) {
134  insertIntoHashTable( varTypes, getTVarName( T_VAR_ID( type ), buf ), expected );
135  }
136  return ty;
137  }
138 
139 }
140 ExprType* unifyTVarR( ExprType *type, ExprType* expected, Hashtable *varTypes, Region *r ) {
141  char buf[128];
142  if ( T_VAR_NUM_DISJUNCTS( expected ) == 0 ) { /* free */
143  if ( occursIn( expected, type ) ) {
144  return NULL;
145  }
146  insertIntoHashTable( varTypes, getTVarName( T_VAR_ID( expected ), buf ), type );
147  return dereference( expected, varTypes, r );
148  }
149  else { /* union type */
150  int i;
151  ExprType *ty = NULL;
152  for ( i = 0; i < T_VAR_NUM_DISJUNCTS( expected ); i++ ) {
153  if ( getNodeType( type ) == getNodeType( T_VAR_DISJUNCT( expected, i ) ) ) { /* union types can only include primitive types */
154  ty = type;
155  }
156  }
157  if ( ty != NULL ) {
158  insertIntoHashTable( varTypes, getTVarName( T_VAR_ID( expected ), buf ), ty );
159  return dereference( expected, varTypes, r );
160  }
161  return ty;
162  }
163 
164 }
169 ExprType* unifyWith( ExprType *type, ExprType* expected, Hashtable *varTypes, Region *r ) {
170  if ( getVararg( type ) != getVararg( expected ) ) {
171  return NULL;
172  }
173  char buf[128];
174  /* dereference types to get the most specific type */
175  /* as dereference only deref top level types, it is necessary to call dereference again */
176  /* when unification is needed for subexpressions of the types which can be performed by calling this function */
177  type = dereference( type, varTypes, r );
178  expected = dereference( expected, varTypes, r );
179  if ( getNodeType( type ) == T_UNSPECED ) {
180  return expected;
181  }
182  if ( getNodeType( expected ) == T_DYNAMIC ) {
183  return type;
184  }
185  if ( getNodeType( type ) == T_VAR && getNodeType( expected ) == T_VAR ) {
186  if ( T_VAR_ID( type ) == T_VAR_ID( expected ) ) {
187  /* if both dereference to the same tvar then do not modify var types table */
188  return type;
189  }
190  else if ( T_VAR_NUM_DISJUNCTS( type ) > 0 && T_VAR_NUM_DISJUNCTS( expected ) > 0 ) {
191  Node *c[10];
192  Node** cp = c;
193  int i, k;
194  for ( k = 0; k < T_VAR_NUM_DISJUNCTS( expected ); k++ ) {
195  for ( i = 0; i < T_VAR_NUM_DISJUNCTS( type ); i++ ) {
196  if ( getNodeType( T_VAR_DISJUNCT( type, i ) ) == getNodeType( T_VAR_DISJUNCT( expected, k ) ) ) {
197  *( cp++ ) = T_VAR_DISJUNCT( expected, k );
198  break;
199  }
200  }
201  }
202  if ( cp == c ) {
203  return NULL;
204  }
205  else {
206  ExprType *gcd;
207  if ( cp - c == 1 ) {
208  gcd = *c;
209  }
210  else {
211  gcd = newTVar2( cp - c, c, r );
212  }
213  updateInHashTable( varTypes, getTVarName( T_VAR_ID( type ), buf ), gcd );
214  updateInHashTable( varTypes, getTVarName( T_VAR_ID( expected ), buf ), gcd );
215  return gcd;
216  }
217  }
218  else {
219  if ( T_VAR_NUM_DISJUNCTS( type ) == 0 ) { /* free */
220  insertIntoHashTable( varTypes, getTVarName( T_VAR_ID( type ), buf ), expected );
221  return dereference( expected, varTypes, r );
222  }
223  else if ( T_VAR_NUM_DISJUNCTS( expected ) == 0 ) { /* free */
224  insertIntoHashTable( varTypes, getTVarName( T_VAR_ID( expected ), buf ), type );
225  return dereference( expected, varTypes, r );
226  }
227  else {
228  /* error unreachable */
229  return NULL;
230  }
231  }
232  }
233  else if ( getNodeType( type ) == T_VAR ) {
234  return unifyTVarL( type, expected, varTypes, r );
235  }
236  else if ( getNodeType( expected ) == T_VAR ) {
237  return unifyTVarR( type, expected, varTypes, r );
238  }
239  else {
240  return unifyNonTvars( type, expected, varTypes, r );
241  }
242 }
248 ExprType* unifyNonTvars( ExprType *type, ExprType *expected, Hashtable *varTypes, Region *r ) {
249  if ( getNodeType( type ) == T_CONS && getNodeType( expected ) == T_CONS ) {
250  if ( strcmp( T_CONS_TYPE_NAME( type ), T_CONS_TYPE_NAME( expected ) ) == 0
251  && T_CONS_ARITY( type ) == T_CONS_ARITY( expected ) ) {
252  ExprType **subtrees = ( ExprType ** ) region_alloc( r, sizeof( ExprType * ) * T_CONS_ARITY( expected ) );
253 
254  int i;
255  for ( i = 0; i < T_CONS_ARITY( type ); i++ ) {
256  ExprType *elemType = unifyWith(
257  T_CONS_TYPE_ARG( type, i ),
258  T_CONS_TYPE_ARG( expected, i ),
259  varTypes, r ); /* unifyWithCoercion performs dereference */
260  if ( elemType == NULL ) {
261  return NULL;
262  }
263  subtrees[i] = elemType;
264  }
265  return dereference( newConsType( T_CONS_ARITY( expected ), T_CONS_TYPE_NAME( expected ), subtrees, r ), varTypes, r );
266  }
267  else {
268  return NULL;
269  }
270  }
271  else if ( getNodeType( type ) == T_IRODS || getNodeType( expected ) == T_IRODS ) {
272  if ( strcmp( type->text, expected->text ) != 0 ) {
273  return NULL;
274  }
275  return expected;
276  }
277  else if ( getNodeType( expected ) == getNodeType( type ) ) { /* primitive types */
278  return expected;
279  }
280  else {
281  return newErrorType( RE_TYPE_ERROR, r );
282  }
283 }
284 /*
285 int unifyPrim(ExprType *type, TypeConstructor prim, Hashtable *typeVars, Region *r) {
286  ExprType primType;
287  primType.t = prim;
288  ExprType *unifiedType = unifyNonTvars(type, &primType, typeVars, r);
289  if(unifiedType == NULL) {
290  return 0;
291  } else {
292  return 1;
293  }
294 }
295 */
296 
297 /* utility function */
298 char* getTVarName( int vid, char name[128] ) {
299  snprintf( name, 128, "?%d", vid );
300  return name;
301 }
302 char* getTVarNameRegion( int vid, Region *r ) {
303  char *name = ( char * ) region_alloc( r, sizeof( char ) * 128 );
304  snprintf( name, 128, "?%d", vid );
305  return name;
306 }
308  return getTVarNameRegion( T_VAR_ID( tvar ), r );
309 }
310 
311 
312 int newTVarId() {
313  return ruleEngineConfig.tvarNumber ++;
314 }
315 
316 /* copy to new region
317  * If the new region is the same as the old region then do not copy.
318  */
319 /* Res *cpRes(Res *res0, Region *r) {
320  Res *res;
321  if(!IN_REGION(res0, r)) {
322  res = newRes(r);
323  *res = *res0;
324  } else {
325  res = res0;
326  }
327  if(res->exprType!=NULL) {
328  res->exprType = cpType(res->exprType, r);
329  }
330  if(res->text != NULL) {
331  res->text = cpString(res->text, r);
332  }
333  if(res->param!= NULL) {
334  res->param = newMsParam(cpString(res->param->type, r), res->param->inOutStruct, res->param->inpOutBuf, r);
335  }
336  int i;
337  if(res->subtrees!=NULL) {
338  if(!IN_REGION(res->subtrees, r)) {
339  Node **temp = (Node **)region_alloc(r, sizeof(Node *) * res->degree);
340  memcpy(temp, res->subtrees, sizeof(Node *) * res->degree);
341  res->subtrees = temp;
342  }
343  for(i=0;i<res->degree;i++) {
344  res->subtrees[i] = cpRes(res->subtrees[i], r);
345  }
346  }
347  return res;
348 }*/
349 
350 char *cpString( char *str, Region *r ) {
351  if ( IN_REGION( str, r ) ) {
352  return str;
353  }
354  else {
355  return cpStringExt( str, r );
356  }
357 }
358 char *cpStringExt( const char *str, Region *r ) {
359  char *strCp = ( char * )region_alloc( r, ( strlen( str ) + 1 ) * sizeof( char ) );
360  strcpy( strCp, str );
361  return strCp;
362 }
363 /* ExprType *cpType(ExprType *ty, Region *r) {
364  if(IN_REGION(ty, r)) {
365  return ty;
366  }
367  int i;
368  ExprType *newt;
369  newt = (ExprType *) region_alloc(r, sizeof(ExprType));
370  memcpy(newt, ty, sizeof(ExprType));
371  if(ty->subtrees != NULL) {
372  newt->subtrees = (ExprType **) region_alloc(r,sizeof(ExprType *)*ty->degree);
373  for(i=0;i<ty->degree;i++) {
374  newt->subtrees[i] = cpType(ty->subtrees[i],r);
375  }
376  }
377  if(ty->text != NULL) {
378  newt->text = cpString(ty->text, r);
379  }
380 
381  return newt;
382 }*/
383 /* copy res values from other region to r */
385  int i;
386 
387  for ( i = 0; i < env->size; i++ ) {
388  struct bucket *b = env->buckets[i];
389  while ( b != NULL ) {
390  b->value = cpRes( ( Res * )b->value, r );
391  b = b->next;
392  }
393  }
394 }
395 
396 void cpEnv( Env *env, Region *r ) {
397  cpHashtable( env->current, r );
398  if ( env->previous != NULL ) {
399  cpEnv( env->previous, r );
400  }
401 }
402 
403 /* copy from old region to new region
404  * If the new region is the same as the old region then do not copy.
405  */
406 /* Res *cpRes2(Res *res0, Region *oldr, Region *r) {
407  Res *res;
408  if(IN_REGION(res0, oldr)) {
409  res = newRes(r);
410  *res = *res0;
411  } else {
412  res = res0;
413  }
414  if(res->exprType!=NULL) {
415  res->exprType = cpType2(res->exprType, oldr, r);
416  }
417  if(res->text != NULL) {
418  res->text = cpString2(res->text, oldr, r);
419  }
420  if(res->param!= NULL && !(IN_REGION(res->param->type, r) && IN_REGION(res->param, r))) {
421  res->param = newMsParam(cpString2(res->param->type, oldr, r), res->param->inOutStruct, res->param->inpOutBuf, r);
422  }
423 
424  int i;
425  if(res->subtrees!=NULL) {
426  if(IN_REGION(res->subtrees, oldr)) {
427  Node **temp = (Node **)region_alloc(r, sizeof(Node *) * res->degree);
428  memcpy(temp, res->subtrees, sizeof(Node *) * res->degree);
429  res->subtrees = temp;
430  }
431  for(i=0;i<res->degree;i++) {
432  res->subtrees[i] = cpRes2(res->subtrees[i], oldr, r);
433  }
434  }
435  return res;
436 } */
437 
438 char *cpString2( char *str, Region *oldr, Region *r ) {
439  if ( !IN_REGION( str, oldr ) ) {
440  return str;
441  }
442  else {
443  return cpStringExt( str, r );
444  }
445 }
446 /* ExprType *cpType2(ExprType *ty, Region *oldr, Region *r) {
447  if(!IN_REGION(ty, oldr)) {
448  return ty;
449  }
450  int i;
451  ExprType *newt;
452  newt = (ExprType *) region_alloc(r, sizeof(ExprType));
453  memcpy(newt, ty, sizeof(ExprType));
454  if(ty->subtrees != NULL) {
455  newt->subtrees = (ExprType **) region_alloc(r,sizeof(ExprType *)*ty->degree);
456  for(i=0;i<ty->degree;i++) {
457  newt->subtrees[i] = cpType2(ty->subtrees[i],oldr, r);
458  }
459  }
460  if(ty->text != NULL) {
461  newt->text = cpString2(ty->text, oldr, r);
462  }
463 
464  return newt;
465 } */
466 /* copy res values from region oldr to r */
467 void cpHashtable2( Hashtable *env, Region *oldr, Region *r ) {
468  int i;
469 
470  for ( i = 0; i < env->size; i++ ) {
471  struct bucket *b = env->buckets[i];
472  while ( b != NULL ) {
473  b->value = cpRes2( ( Res * )b->value, oldr, r );
474  b = b->next;
475  }
476  }
477 }
478 
479 void cpEnv2( Env *env, Region *oldr, Region *r ) {
480  cpHashtable2( env->current, oldr, r );
481  if ( env->previous != NULL ) {
482  cpEnv2( env->previous, oldr, r );
483  }
484 }
485 
486 
487 void printIndent( int n ) {
488  int i;
489  for ( i = 0; i < n; i++ ) {
490  printf( "\t" );
491  }
492 }
493 
494 
496  Env *e = env->lower;
497  int i = 0;
498  while ( e != NULL ) {
499  i++;
500  e = e->lower;
501  }
502  printIndent( i );
503 }
504 
505 void printTreeDeref( Node *n, int indent, Hashtable *var_types, Region *r ) {
506  printIndent( indent );
507  printf( "%s:%d->", n->text, getNodeType( n ) );
508  printType( n->coercionType, var_types );
509  printf( "\n" );
510  int i;
511  for ( i = 0; i < n->degree; i++ ) {
512  printTreeDeref( n->subtrees[i], indent + 1, var_types, r );
513  }
514 
515 }
516 void printType( ExprType *type, Hashtable *var_types ) {
517  char buf[1024];
518  typeToString( type, var_types, buf, 1024 );
519  printf( "%s", buf );
520 }
521 
522 char* typeToString( ExprType *type, Hashtable *var_types, char *buf, int bufsize ) {
523  buf[0] = '\0';
524  Region *r = make_region( 0, NULL );
525  if ( getVararg( type ) != OPTION_VARARG_ONCE ) {
526  snprintf( buf + strlen( buf ), bufsize - strlen( buf ), "vararg " );
527  }
528  ExprType *etype = type;
529  if ( getNodeType( etype ) == T_VAR && var_types != NULL ) {
530  /* dereference */
531  etype = dereference( etype, var_types, r );
532  }
533 
534  if ( getNodeType( etype ) == T_VAR ) {
535  snprintf( buf + strlen( buf ), bufsize - strlen( buf ), "%s ", typeName_ExprType( etype ) );
536  snprintf( buf + strlen( buf ), bufsize - strlen( buf ), "%d", T_VAR_ID( etype ) );
537  if ( T_VAR_NUM_DISJUNCTS( type ) != 0 ) {
538  snprintf( buf + strlen( buf ), bufsize - strlen( buf ), "{" );
539  int i;
540  for ( i = 0; i < T_VAR_NUM_DISJUNCTS( type ); i++ ) {
541  snprintf( buf + strlen( buf ), bufsize - strlen( buf ), "%s ", typeName_ExprType( T_VAR_DISJUNCT( type, i ) ) );
542  }
543  snprintf( buf + strlen( buf ), bufsize - strlen( buf ), "}" );
544  }
545  }
546  else if ( getNodeType( etype ) == T_CONS ) {
547  if ( strcmp( etype->text, FUNC ) == 0 ) {
548  snprintf( buf + strlen( buf ), bufsize - strlen( buf ), "(" );
549  typeToString( T_CONS_TYPE_ARG( etype, 0 ), var_types, buf + strlen( buf ), bufsize - strlen( buf ) );
550  snprintf( buf + strlen( buf ), bufsize - strlen( buf ), ")" );
551  snprintf( buf + strlen( buf ), bufsize - strlen( buf ), "->" );
552  typeToString( T_CONS_TYPE_ARG( etype, 1 ), var_types, buf + strlen( buf ), bufsize - strlen( buf ) );
553  }
554  else {
555 
556  snprintf( buf + strlen( buf ), bufsize - strlen( buf ), "%s ", T_CONS_TYPE_NAME( etype ) );
557  int i;
558  if ( T_CONS_ARITY( etype ) != 0 ) {
559  snprintf( buf + strlen( buf ), bufsize - strlen( buf ), "(" );
560  for ( i = 0; i < T_CONS_ARITY( etype ); i++ ) {
561  if ( i != 0 ) {
562  snprintf( buf + strlen( buf ), bufsize - strlen( buf ), ", " );
563  }
564  typeToString( T_CONS_TYPE_ARG( etype, i ), var_types, buf + strlen( buf ), bufsize - strlen( buf ) );
565  }
566  snprintf( buf + strlen( buf ), bufsize - strlen( buf ), ")" );
567  }
568  }
569  }
570  else if ( getNodeType( etype ) == T_FLEX ) {
571  snprintf( buf + strlen( buf ), bufsize - strlen( buf ), "%s ", typeName_ExprType( etype ) );
572  typeToString( etype->subtrees[0], var_types, buf + strlen( buf ), bufsize - strlen( buf ) );
573  }
574  else if ( getNodeType( etype ) == T_FIXD ) {
575  snprintf( buf + strlen( buf ), bufsize - strlen( buf ), "%s ", typeName_ExprType( etype ) );
576  typeToString( etype->subtrees[0], var_types, buf + strlen( buf ), bufsize - strlen( buf ) );
577  snprintf( buf + strlen( buf ), bufsize - strlen( buf ), "=> " );
578  typeToString( etype->subtrees[1], var_types, buf + strlen( buf ), bufsize - strlen( buf ) );
579  }
580  else if ( getNodeType( etype ) == T_TUPLE ) {
581  if ( T_CONS_ARITY( etype ) == 0 ) {
582  snprintf( buf + strlen( buf ), bufsize - strlen( buf ), "unit" );
583  }
584  else {
585  if ( T_CONS_ARITY( etype ) == 1 ) {
586  snprintf( buf + strlen( buf ), bufsize - strlen( buf ), "(" );
587  }
588  int i;
589  for ( i = 0; i < T_CONS_ARITY( etype ); i++ ) {
590  if ( i != 0 ) {
591  snprintf( buf + strlen( buf ), bufsize - strlen( buf ), " * " );
592  }
593  typeToString( T_CONS_TYPE_ARG( etype, i ), var_types, buf + strlen( buf ), bufsize - strlen( buf ) );
594  }
595  if ( T_CONS_ARITY( etype ) == 1 ) {
596  snprintf( buf + strlen( buf ), bufsize - strlen( buf ), ")" );
597  }
598  }
599  }
600  else {
601  snprintf( buf + strlen( buf ), bufsize - strlen( buf ), "%s ", typeName_ExprType( etype ) );
602  }
603 
604  int i = strlen( buf ) - 1;
605  while ( buf[i] == ' ' ) {
606  i--;
607  }
608  buf[i + 1] = '\0';
609 
610  region_free( r );
611  return buf;
612 
613 }
614 void typingConstraintsToString( List *typingConstraints, char *buf, int bufsize ) {
615  char buf2[1024];
616  char buf3[1024];
617  ListNode *p = typingConstraints->head;
618  buf[0] = '\0';
619  while ( p != NULL ) {
620  snprintf( buf + strlen( buf ), bufsize - strlen( buf ), "%s<%s\n",
621  typeToString( TC_A( ( TypingConstraint * )p->value ), NULL, /*var_types,*/ buf2, 1024 ),
622  typeToString( TC_B( ( TypingConstraint * )p->value ), NULL, /*var_types,*/ buf3, 1024 ) );
623  p = p->next;
624  }
625 }
627  if ( getNodeType( type ) == T_VAR ) {
628  char name[128];
629  getTVarName( T_VAR_ID( type ), name );
630  /* printf("deref: %s\n", name); */
631  ExprType *deref = ( ExprType * )lookupFromHashTable( type_table, name );
632  if ( deref == NULL ) {
633  return type;
634  }
635  else {
636  return dereference( deref, type_table, r );
637  }
638  }
639  return type;
640 }
641 
642 ExprType *instantiate( ExprType *type, Hashtable *type_table, int replaceFreeVars, Region *r ) {
643  ExprType **paramTypes;
644  int i;
645  ExprType *typeInst;
646  int changed = 0;
647 
648  switch ( getNodeType( type ) ) {
649  case T_VAR:
650  typeInst = dereference( type, type_table, r );
651  if ( typeInst == type ) {
652  return replaceFreeVars ? newSimpType( T_UNSPECED, r ) : type;
653  }
654  else {
655  return instantiate( typeInst, type_table, replaceFreeVars, r );
656  }
657  default:
658  if ( type->degree != 0 ) {
659  paramTypes = ( ExprType ** ) region_alloc( r, sizeof( ExprType * ) * type->degree );
660  for ( i = 0; i < type->degree; i++ ) {
661  paramTypes[i] = instantiate( type->subtrees[i], type_table, replaceFreeVars, r );
662  if ( paramTypes[i] != type->subtrees[i] ) {
663  changed = 1;
664  }
665  }
666  }
667  if ( changed ) {
668  ExprType *inst = ( ExprType * ) region_alloc( r, sizeof( ExprType ) );
669  memcpy( inst, type, sizeof( ExprType ) );
670  inst->subtrees = paramTypes;
671  return inst;
672  }
673  else {
674  return type;
675  }
676 
677  }
678 }
679 
681 int writeToTmp( char *fileName, char *text ) {
682  char buf[1024];
683  snprintf( buf, sizeof( buf ), "/tmp/%s", fileName );
684  FILE *fp = fopen( buf, "a" );
685  if ( fp == NULL ) {
686  return 0;
687  }
688  fputs( text, fp );
689  fclose( fp );
690  return 1;
691 }
692 int writeIntToTmp( char *fileName, int text ) {
693  char buf[1024];
694  snprintf( buf, 1024, "%d", text );
695  writeToTmp( fileName, buf );
696  return 1;
697 }
698 
700  Env *e = env;
701  char buffer[1024];
702  while ( e != NULL ) {
703  if ( e != env ) {
704  printf( "%s\n===========\n", buffer );
705  }
706  printHashtable( e->current, buffer );
707  e = e->previous;
708  }
709  /*
710  int i;
711  for(i=0;i<env->size;i++) {
712  struct bucket *b = env->buckets[i];
713  while(b!=NULL) {
714  printf("%s=%s\n",b->key, TYPENAME((Res *)b->value));
715  b=b->next;
716  }
717  }
718  */
719 }
720 
722  int i;
723  for ( i = 0; i < env->size; i++ ) {
724  struct bucket *b = env->buckets[i];
725  while ( b != NULL ) {
726  printf( "%s=", b->key );
727  printType( ( ExprType * )b->value, NULL/*env*/ );
728  printf( "\n" );
729  b = b->next;
730  }
731  }
732 }
733 
734 
738 /*
739 void replace(Hashtable *varTypes, int a, ExprType *b) {
740  int i;
741  for(i=0;i<varTypes->size;i++) {
742  struct bucket *bucket= varTypes->buckets[i];
743  while(bucket!=NULL) {
744  ExprType *t = (ExprType *)bucket->value;
745  if(t->t==T_VAR && T_VAR_ID(t) == a) {
746  bucket -> value = b;
747  }
748  bucket = bucket->next;
749  }
750  }
751 }
752 */
753 
755  Env *global = env;
756  while ( global->previous != NULL ) {
757  global = global->previous;
758  }
759  return global;
760 }
761 
762 void logErrMsg( rError_t *errmsg, rError_t *system ) {
763  char errbuf[ERR_MSG_LEN * 16];
764  errMsgToString( errmsg, errbuf, ERR_MSG_LEN * 16 );
765 #ifdef DEBUG
766  writeToTmp( "err.log", "begin errlog\n" );
767  writeToTmp( "err.log", errbuf );
768  writeToTmp( "err.log", "end errlog\n" );
769 #endif
770  if ( system != NULL ) {
771  rodsLogAndErrorMsg( LOG_ERROR, system, RE_UNKNOWN_ERROR, "%s", errbuf );
772  }
773  else {
774  rodsLog( LOG_ERROR, "%s", errbuf );
775  }
776 }
777 
778 char *errMsgToString( rError_t *errmsg, char *errbuf, int buflen /* = 0 */ ) {
779  errbuf[0] = '\0';
780  int p = 0;
781  int i;
782  int first = 1;
783  int restart = 0;
784  for ( i = errmsg->len - 1; i >= 0; i-- ) {
785  if ( strcmp( errmsg->errMsg[i]->msg, ERR_MSG_SEP ) == 0 ) {
786  if ( first || restart ) {
787  continue;
788  }
789  else {
790  restart = 1;
791  continue;
792  }
793  }
794  if ( restart ) {
795  snprintf( errbuf + p, buflen - p, "%s\n", ERR_MSG_SEP );
796  p += strlen( errbuf + p );
797  }
798  if ( !first && !restart ) {
799  snprintf( errbuf + p, buflen - p, "caused by: %s\n", errmsg->errMsg[i]->msg );
800  }
801  else {
802  snprintf( errbuf + p, buflen - p, "%s\n", errmsg->errMsg[i]->msg );
803  first = 0;
804  restart = 0;
805 
806  }
807  p += strlen( errbuf + p );
808  }
809  return errbuf;
810 
811 }
812 
813 const void *lookupFromEnv( Env *env, const char *key ) {
814  const void* val = lookupFromHashTable( env->current, key );
815  if ( val == NULL && env->previous != NULL ) {
816  val = lookupFromEnv( env->previous, key );
817  }
818  return val;
819 }
820 
821 void updateInEnv( Env *env, char *varName, Res *res ) {
822  if ( NULL != env ) {
823  Env *defined = env;
824 
825  while ( NULL != defined && NULL == lookupFromHashTable( defined->current, varName ) ) {
826  defined = defined->previous;
827  }
828  if ( NULL != defined ) {
829  updateInHashTable( defined->current, varName, res );
830  }
831  else {
832  insertIntoHashTable( env->current, varName, res );
833  }
834  }
835 }
836 
838  Hashtable *ht = e->current;
839  int i;
840  for ( i = 0; i < ht->size; i++ ) {
841  struct bucket *b = ht->buckets[i];
842  while ( b != NULL ) {
843  Res *res = ( Res * ) b->value;
844  if ( TYPE( res ) == T_IRODS ) {
845  if ( RES_UNINTER_STRUCT( res ) != NULL ) {
846  free( RES_UNINTER_STRUCT( res ) );
847  }
848  if ( RES_UNINTER_BUFFER( res ) != NULL ) {
849  free( RES_UNINTER_BUFFER( res ) );
850  }
851  }
852  b = b->next;
853  }
854  }
855  if ( e->previous != NULL ) {
856  freeEnvUninterpretedStructs( e->previous );
857  }
858 }
859 int isPattern( Node *pattern ) {
860 
861  if ( getNodeType( pattern ) == N_APPLICATION || getNodeType( pattern ) == N_TUPLE ) {
862  int i;
863  for ( i = 0; i < pattern->degree; i++ ) {
864  if ( !isPattern( pattern->subtrees[i] ) ) {
865  return 0;
866  }
867  }
868  return 1;
869  }
870  else if ( getNodeType( pattern ) == TK_TEXT || getNodeType( pattern ) == TK_VAR || getNodeType( pattern ) == TK_STRING
871  || getNodeType( pattern ) == TK_BOOL || getNodeType( pattern ) == TK_INT || getNodeType( pattern ) == TK_DOUBLE ) {
872  return 1;
873  }
874  else {
875  return 0;
876 
877  }
878 }
879 
880 int isRecursive( Node *rule ) {
881  return invokedIn( rule->subtrees[0]->text, rule->subtrees[1] ) ||
882  invokedIn( rule->subtrees[0]->text, rule->subtrees[2] ) ||
883  invokedIn( rule->subtrees[0]->text, rule->subtrees[3] );
884 
885 }
886 
887 int invokedIn( char *fn, Node *expr ) {
888  int i;
889  switch ( getNodeType( expr ) ) {
890  case TK_TEXT:
891  if ( strcmp( expr->text, fn ) == 0 ) {
892  return 1;
893  }
894  break;
895 
896  case N_APPLICATION:
897  case N_ACTIONS:
898  case N_ACTIONS_RECOVERY:
899  for ( i = 0; i < expr->degree; i++ ) {
900  if ( invokedIn( fn, expr->subtrees[i] ) ) {
901  return 1;
902  }
903  }
904  break;
905  default:
906  break;
907  }
908 
909  return 0;
910 }
911 Node *lookupAVUFromMetadata( Node *metadata, char *a ) {
912  int i;
913  for ( i = 0; i < metadata->degree; i++ ) {
914  if ( strcmp( metadata->subtrees[i]->subtrees[0]->text, a ) == 0 ) {
915  return metadata->subtrees[i];
916  }
917  }
918  return NULL;
919 
920 }
921 
922 int isRuleGenSyntax( char *expr ) {
923  char *p = expr;
924  int mode = 0;
925  while ( *p != '\0' ) {
926  switch ( mode ) {
927  case 0:
928  if ( *p == '#' && *( p + 1 ) == '#' ) {
929  return 0;
930  }
931  else if ( *p == '#' ) {
932  mode = 1;
933  }
934  else if ( *p == '\'' ) {
935  mode = 2;
936  }
937  else if ( *p == '\"' ) {
938  mode = 3;
939  }
940  else if ( *p == '`' ) {
941  mode = 4;
942  }
943  break;
944  case 1: /* comments */
945  if ( *p == '\n' ) {
946  mode = 0;
947  }
948  break;
949  case 2: /* single qouted string */
950  if ( *p == '\\' ) {
951  p++;
952  if ( *p == '\0' ) {
953  break;
954  }
955  }
956  else if ( *p == '\'' ) {
957  mode = 0;
958  }
959  break;
960  case 3: /* double quoted string */
961  if ( *p == '\\' ) {
962  p++;
963  if ( *p == '\0' ) {
964  break;
965  }
966  }
967  else if ( *p == '\"' ) {
968  mode = 0;
969  }
970  break;
971  case 4: /* double backquoted string */
972  if ( *p == '`' && *( p + 1 ) == '`' ) {
973  p++;
974  mode = 0;
975  }
976  break;
977  }
978  p++;
979  }
980  return 1;
981 }
982 #define KEY_INSTANCE
984 #include "restruct.templates.hpp"
985 #include "end.instance.hpp"
986 void keyNode( Node *node, char *keyBuf ) {
987  /* memset(keyBuf, 0, KEY_SIZE); */
988  if ( node->degree > 0 ) {
989  snprintf( keyBuf, KEY_SIZE, "%p", node );
990  }
991  else {
992  char *p = keyBuf;
993  int len = snprintf( p, KEY_SIZE, "node::%d::%p::%lld::%p::%d::%s::%s::%d::%f::%lld::%p::%p::%p",
996  );
997  if ( len >= KEY_SIZE ) {
998  snprintf( keyBuf, KEY_SIZE, "pointer::%p", node );
999  return;
1000  }
1001  }
1002 }
1003 void keyBuf( unsigned char *buf, int size, char *keyBuf ) {
1004  if ( size * 2 + 1 <= KEY_SIZE ) {
1005  int i;
1006  char *p = keyBuf;
1007  for ( i = 0; i < size; i++ ) {
1008  *( p++ ) = 'A' + ( buf[i] & ( unsigned char ) 0xf );
1009  *( p++ ) = 'A' + ( buf[i] & ( unsigned char ) 0xf0 );
1010  }
1011  *( p++ ) = '\0';
1012  }
1013  else {
1014  snprintf( keyBuf, KEY_SIZE, "pointer::%p", buf );
1015 
1016  }
1017 }
1018 #undef KEY_INSTANCE
1019 
1021 #include "restruct.templates.hpp"
1022 #include "end.instance.hpp"
1023 
1025 #include "restruct.templates.hpp"
1026 #include "end.instance.hpp"
1027 
1028 #include "to.region.instance.hpp"
1029 #include "restruct.templates.hpp"
1030 #include "end.instance.hpp"
1031 
1032 #include "to.memory.instance.hpp"
1033 #include "restruct.templates.hpp"
1034 #include "end.instance.hpp"
1035 
1036 #ifdef RE_CACHE_CHECK
1037 #include "cache.check.instance.hpp"
1038 #include "restruct.templates.hpp"
1039 #include "end.instance.hpp"
1040 #endif
1041 
1042 #ifdef RE_REGION_CHECK
1043 #include "region.check.instance.hpp"
1044 #include "restruct.templates.hpp"
1045 #include "end.instance.hpp"
1046 #endif
to.memory.instance.hpp
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
key.instance.hpp
NULL
#define NULL
Definition: rodsDef.h:70
Cache::tvarNumber
int tvarNumber
Definition: configuration.hpp:64
region.check.instance.hpp
T_CONS_ARITY
#define T_CONS_ARITY(x)
Definition: restructs.hpp:28
TK_BOOL
@ TK_BOOL
Definition: restructs.hpp:116
rError_t::len
int len
Definition: rodsError.h:25
RE_UNKNOWN_ERROR
@ RE_UNKNOWN_ERROR
Definition: rodsErrorTable.h:713
bucket::key
char * key
Definition: irods_hashtable.h:12
unifyTVarR
ExprType * unifyTVarR(ExprType *type, ExprType *expected, Hashtable *varTypes, Region *r)
Definition: utils.cpp:140
cpHashtable
void cpHashtable(Hashtable *env, Region *r)
Definition: utils.cpp:384
FUNC
#define FUNC
Definition: reconstants.hpp:20
cpHashtable2
void cpHashtable2(Hashtable *env, Region *oldr, Region *r)
Definition: utils.cpp:467
utils.hpp
listNode
Definition: irods_list.h:8
region_alloc
void * region_alloc(Region *r, size_t s)
Definition: region.cpp:138
node::dval
double dval
Definition: restructs.hpp:256
node::ival
int ival
Definition: restructs.hpp:248
env::previous
Env * previous
Definition: restructs.hpp:228
T_UNSPECED
@ T_UNSPECED
Definition: restructs.hpp:156
node::param
msParam_t * param
Definition: restructs.hpp:260
getNodeType
#define getNodeType(x)
Definition: restructs.hpp:69
bucket
Definition: irods_hashtable.h:11
env
Definition: restructs.hpp:226
restructs.hpp
isPattern
int isPattern(Node *pattern)
Definition: utils.cpp:859
configuration.hpp
T_VAR_DISJUNCTS
#define T_VAR_DISJUNCTS(x)
Definition: restructs.hpp:36
keyNode
void keyNode(Node *node, char *keyBuf)
Definition: utils.cpp:986
cpEnv2
void cpEnv2(Env *env, Region *oldr, Region *r)
Definition: utils.cpp:479
pid_age.p
p
Definition: pid_age.py:13
T_DOUBLE
@ T_DOUBLE
Definition: restructs.hpp:159
newTVarId
int newTVarId()
Definition: utils.cpp:312
instantiate
ExprType * instantiate(ExprType *type, Hashtable *type_table, int replaceFreeVars, Region *r)
Definition: utils.cpp:642
N_APPLICATION
@ N_APPLICATION
Definition: restructs.hpp:128
make_region
Region * make_region(size_t is, jmp_buf *label)
Definition: region.cpp:85
node
Definition: restructs.hpp:244
KEY_SIZE
#define KEY_SIZE
Definition: key.proto.hpp:7
dupTypeAux
ExprType * dupTypeAux(ExprType *ty, Region *r, Hashtable *varTable)
Definition: utils.cpp:46
typeToString
char * typeToString(ExprType *type, Hashtable *var_types, char *buf, int bufsize)
Definition: utils.cpp:522
TYPE
#define TYPE(x)
Definition: restructs.hpp:23
T_VAR_DISJUNCT
#define T_VAR_DISJUNCT(x, n)
Definition: restructs.hpp:35
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
generate_iadmin_commands_for_41_to_42_upgrade.name
name
Definition: generate_iadmin_commands_for_41_to_42_upgrade.py:23
printHashtable
void printHashtable(Hashtable *env, char *buf2)
Definition: conversion.cpp:736
RES_UNINTER_BUFFER
#define RES_UNINTER_BUFFER(x)
Definition: restructs.hpp:66
IN_REGION
#define IN_REGION(x, r)
Definition: region.h:57
TK_INT
@ TK_INT
Definition: restructs.hpp:112
conversion.hpp
T_CONS
@ T_CONS
Definition: restructs.hpp:167
TC_B
#define TC_B(tc)
Definition: restructs.hpp:39
getTVarNameRegionFromExprType
char * getTVarNameRegionFromExprType(ExprType *tvar, Region *r)
Definition: utils.cpp:307
env::lower
Env * lower
Definition: restructs.hpp:229
cpString
char * cpString(char *str, Region *r)
Definition: utils.cpp:350
node::text
char * text
Definition: restructs.hpp:252
getTVarName
char * getTVarName(int vid, char name[128])
Definition: utils.cpp:298
printType
void printType(ExprType *type, Hashtable *var_types)
Definition: utils.cpp:516
TK_VAR
@ TK_VAR
Definition: restructs.hpp:119
occursIn
int occursIn(ExprType *var, ExprType *type)
Definition: typing.cpp:126
unifyTVarL
ExprType * unifyTVarL(ExprType *type, ExprType *expected, Hashtable *varTypes, Region *r)
Definition: utils.cpp:115
hashtable::buckets
struct bucket ** buckets
Definition: irods_hashtable.h:17
newHashTable2
Hashtable * newHashTable2(int size, Region *r)
Definition: hashtable.cpp:72
to.region.instance.hpp
rError_t
Definition: rodsError.h:24
cpRes2
#define cpRes2(p, oldr, r)
Definition: utils.hpp:50
T_IRODS
@ T_IRODS
Definition: restructs.hpp:172
rodsLogAndErrorMsg
void rodsLogAndErrorMsg(int level, rError_t *myError, int status, const char *formatStr,...)
Definition: rodsLog.cpp:231
N_ACTIONS
@ N_ACTIONS
Definition: restructs.hpp:134
TK_TEXT
@ TK_TEXT
Definition: restructs.hpp:114
node::subtrees
struct node ** subtrees
Definition: restructs.hpp:254
newExprType
Node * newExprType(NodeType t, int degree, Node **subtrees, Region *r)
Definition: restructs.cpp:39
freeEnvUninterpretedStructs
void freeEnvUninterpretedStructs(Env *e)
Definition: utils.cpp:837
N_ACTIONS_RECOVERY
@ N_ACTIONS_RECOVERY
Definition: restructs.hpp:135
keyBuf
void keyBuf(unsigned char *buf, int size, char *keyBuf)
Definition: utils.cpp:1003
RE_TYPE_ERROR
@ RE_TYPE_ERROR
Definition: rodsErrorTable.h:720
writeToTmp
int writeToTmp(char *fileName, char *text)
Definition: utils.cpp:681
printEnvToStdOut
void printEnvToStdOut(Env *env)
Definition: utils.cpp:699
T_DATETIME
@ T_DATETIME
Definition: restructs.hpp:162
node::degree
int degree
Definition: restructs.hpp:246
node::expr
rodsLong_t expr
Definition: restructs.hpp:253
TC_A
#define TC_A(tc)
Definition: restructs.hpp:38
unifyWith
ExprType * unifyWith(ExprType *type, ExprType *expected, Hashtable *varTypes, Region *r)
Definition: utils.cpp:169
lookupAVUFromMetadata
Node * lookupAVUFromMetadata(Node *metadata, char *a)
Definition: utils.cpp:911
node::lval
rodsLong_t lval
Definition: restructs.hpp:257
dupType
ExprType * dupType(ExprType *ty, Region *r)
Definition: utils.cpp:9
T_STRING
@ T_STRING
Definition: restructs.hpp:161
terminate_irods_processes.e
e
Definition: terminate_irods_processes.py:19
isRuleGenSyntax
int isRuleGenSyntax(char *expr)
Definition: utils.cpp:922
cpRes
#define cpRes(p, r)
Definition: utils.hpp:48
irods.pypyodbc.buffer
buffer
Definition: pypyodbc.py:46
newSimpType
ExprType * newSimpType(NodeType t, Region *r)
Definition: restructs.cpp:70
insertIntoHashTable
int insertIntoHashTable(Hashtable *h, const char *key, const void *value)
Definition: hashtable.cpp:99
invokedIn
int invokedIn(char *fn, Node *expr)
Definition: utils.cpp:887
rErrMsg_t::msg
char msg[1024]
Definition: rodsError.h:21
lookupFromEnv
const void * lookupFromEnv(Env *env, const char *key)
Definition: utils.cpp:813
cpEnv
void cpEnv(Env *env, Region *r)
Definition: utils.cpp:396
TK_DOUBLE
@ TK_DOUBLE
Definition: restructs.hpp:113
writeIntToTmp
int writeIntToTmp(char *fileName, int text)
Definition: utils.cpp:692
globalEnv
Env * globalEnv(Env *env)
Definition: utils.cpp:754
node::coercionType
ExprType * coercionType
Definition: restructs.hpp:251
lookupFromHashTable
const void * lookupFromHashTable(Hashtable *h, const char *key)
Definition: hashtable.cpp:222
node::base
char * base
Definition: restructs.hpp:255
printIndent
void printIndent(int n)
Definition: utils.cpp:487
T_FIXD
@ T_FIXD
Definition: restructs.hpp:165
OPTION_VARARG_ONCE
#define OPTION_VARARG_ONCE
Definition: restructs.hpp:72
region
Definition: region.h:45
T_BOOL
@ T_BOOL
Definition: restructs.hpp:163
end.instance.hpp
RES_UNINTER_STRUCT
#define RES_UNINTER_STRUCT(x)
Definition: restructs.hpp:65
region.to.region.instance.hpp
coercible
int coercible(ExprType *a, ExprType *b)
Definition: utils.cpp:96
irods.lib.indent
def indent(*text, **kwargs)
Definition: lib.py:138
list::head
ListNode * head
Definition: irods_list.h:15
node::exprType
ExprType * exprType
Definition: restructs.hpp:250
logErrMsg
void logErrMsg(rError_t *errmsg, rError_t *system)
Definition: utils.cpp:762
N_TUPLE
@ N_TUPLE
Definition: restructs.hpp:127
dereference
ExprType * dereference(ExprType *type, Hashtable *type_table, Region *r)
Definition: utils.cpp:626
updateInHashTable
const void * updateInHashTable(Hashtable *h, const char *key, const void *value)
Definition: hashtable.cpp:164
updateInEnv
void updateInEnv(Env *env, char *varName, Res *res)
Definition: utils.cpp:821
reVariableMap.gen.hpp
newTVar2
ExprType * newTVar2(int numDisjuncts, Node **disjuncts, Region *r)
Definition: restructs.cpp:51
irods.six.b
def b(s)
Definition: six.py:606
T_VAR
@ T_VAR
Definition: restructs.hpp:171
T_VAR_NUM_DISJUNCTS
#define T_VAR_NUM_DISJUNCTS(x)
Definition: restructs.hpp:37
T_INT
@ T_INT
Definition: restructs.hpp:160
printEnvIndent
void printEnvIndent(Env *env)
Definition: utils.cpp:495
T_TUPLE
@ T_TUPLE
Definition: restructs.hpp:166
newTupleType
ExprType * newTupleType(int arity, ExprType **typeArgs, Region *r)
Definition: restructs.cpp:116
env::current
Hashtable * current
Definition: restructs.hpp:227
TK_STRING
@ TK_STRING
Definition: restructs.hpp:115
region_free
void region_free(Region *r)
Definition: region.cpp:146
node::option
int option
Definition: restructs.hpp:247
newConsType
ExprType * newConsType(int arity, char *cons, ExprType **paramTypes, Region *r)
Definition: restructs.cpp:88
T_DYNAMIC
@ T_DYNAMIC
Definition: restructs.hpp:158
region.to.region2.instance.hpp
hashtable::size
int size
Definition: irods_hashtable.h:18
node::func
SmsiFuncTypePtr func
Definition: restructs.hpp:259
node::ruleIndexList
RuleIndexList * ruleIndexList
Definition: restructs.hpp:258
newErrorType
ExprType * newErrorType(int errcode, Region *r)
Definition: restructs.cpp:73
ruleEngineConfig
Cache ruleEngineConfig
Definition: configuration.cpp:68
hashtable
Definition: irods_hashtable.h:16
isRecursive
int isRecursive(Node *rule)
Definition: utils.cpp:880
size
long long size
Definition: filesystem.cpp:102
mode
int mode
Definition: filesystem.cpp:104
typeName_ExprType
char * typeName_ExprType(ExprType *s)
Definition: parser.cpp:3419
printTreeDeref
void printTreeDeref(Node *n, int indent, Hashtable *var_types, Region *r)
Definition: utils.cpp:505
typingConstraintsToString
void typingConstraintsToString(List *typingConstraints, char *buf, int bufsize)
Definition: utils.cpp:614
cpStringExt
char * cpStringExt(const char *str, Region *r)
Definition: utils.cpp:358
cpString2
char * cpString2(char *str, Region *oldr, Region *r)
Definition: utils.cpp:438
printVarTypeEnvToStdOut
void printVarTypeEnvToStdOut(Hashtable *env)
Definition: utils.cpp:721
getTVarNameRegion
char * getTVarNameRegion(int vid, Region *r)
Definition: utils.cpp:302
getVararg
#define getVararg(n)
Definition: restructs.hpp:87
T_CONS_TYPE_ARG
#define T_CONS_TYPE_ARG(x, n)
Definition: restructs.hpp:26
rError_t::errMsg
rErrMsg_t ** errMsg
Definition: rodsError.h:26
buf
static char buf[64+50+1]
Definition: rsAuthRequest.cpp:21
node::nodeType
int nodeType
Definition: restructs.hpp:245
type
int type
Definition: filesystem.cpp:103
T_VAR_ID
#define T_VAR_ID(x)
Definition: restructs.hpp:34
errMsgToString
char * errMsgToString(rError_t *errmsg, char *errbuf, int buflen)
Definition: utils.cpp:778
ERR_MSG_SEP
#define ERR_MSG_SEP
Definition: reconstants.hpp:21
restruct.templates.hpp
list
Definition: irods_list.h:13
typeEqSyntatic
int typeEqSyntatic(ExprType *a, ExprType *b)
Definition: utils.cpp:18
T_FLEX
@ T_FLEX
Definition: restructs.hpp:164
ERR_MSG_LEN
#define ERR_MSG_LEN
Definition: rodsError.h:16
T_CONS_TYPE_NAME
#define T_CONS_TYPE_NAME(x)
Definition: restructs.hpp:27
unifyNonTvars
ExprType * unifyNonTvars(ExprType *type, ExprType *expected, Hashtable *varTypes, Region *r)
Definition: utils.cpp:248