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)  

typing.cpp
Go to the documentation of this file.
1 /* For copyright information please refer to files in the COPYRIGHT directory
2  */
3 
4 #include "typing.hpp"
5 #include "functions.hpp"
6 #include "rcMisc.h"
7 #define RE_ERROR(x); if(x) {goto error;}
8 #define RE_ERROR2(x,y); if(x) {localErrorMsg=(y);goto error;}
9 #define N_BASE_TYPES 7
11  T_INT,
12  T_BOOL,
13  T_DOUBLE,
14  T_DATETIME,
15  T_STRING,
16  T_PATH,
17  T_IRODS,
18 };
19 void doNarrow( Node **l, Node **r, int ln, int rn, int flex, Node **nl, Node **nr, int *nln, int *nrn );
20 Satisfiability createSimpleConstraint( ExprType *a, ExprType *b, int flex, Node *node, Hashtable *typingEnv, Hashtable *equivalence, List *simpleTypingConstraints, Region *r );
21 ExprType *createType( ExprType *t, Node **nc, int nn, Hashtable *typingEnv, Hashtable *equivalence, Region *r );
23 
28 int typeParameters( ExprType** paramTypes, int len, Node** subtrees, int dynamictyping, Env* funcDesc, Hashtable *symbol_type_table, List *typingConstraints, rError_t *errmsg, Node **errnode, Region *r ) {
29  int i;
30  for ( i = 0; i < len; i++ ) {
31  paramTypes[i] = dereference( typeExpression3( subtrees[i], dynamictyping, funcDesc, symbol_type_table, typingConstraints, errmsg, errnode, r ), symbol_type_table, r );
32  if ( getNodeType( paramTypes[i] ) == T_ERROR ) {
33  return i;
34  }
35  }
36  return -1;
37 }
38 
39 int tautologyLt( ExprType *type, ExprType *expected ) {
40 
41  if ( typeEqSyntatic( type, expected ) ) {
42  return 1;
43  }
44  if ( getNodeType( type ) == T_DYNAMIC ) {
45  return 0;
46  }
47  if ( getNodeType( expected ) == T_DYNAMIC ) {
48  return 1;
49  }
50  int i;
51  ExprType a, b;
52  if ( getNodeType( type ) == T_VAR ) {
53  if ( T_VAR_NUM_DISJUNCTS( type ) > 0 ) {
54  for ( i = 0; i < T_VAR_NUM_DISJUNCTS( type ); i++ ) {
56  if ( !tautologyLt( &a, expected ) ) {
57  return 0;
58  }
59  }
60  return 1;
61  }
62  else {
63  return 0;
64  }
65 
66  }
67  else if ( getNodeType( expected ) == T_VAR ) {
68  if ( T_VAR_NUM_DISJUNCTS( expected ) > 0 ) {
69  for ( i = 0; i < T_VAR_NUM_DISJUNCTS( expected ); i++ ) {
70  setNodeType( &b, getNodeType( T_VAR_DISJUNCT( expected, i ) ) );
71  if ( !tautologyLt( type, &b ) ) {
72  return 0;
73  }
74  }
75  return 1;
76  }
77  else {
78  return 0;
79  }
80  }
81  else if ( ( getNodeType( type ) == T_CONS && getNodeType( expected ) == T_CONS ) || ( getNodeType( type ) == T_TUPLE && getNodeType( expected ) == T_TUPLE ) ) {
82  if ( getNodeType( type ) == T_CONS && strcmp( T_CONS_TYPE_NAME( type ), T_CONS_TYPE_NAME( expected ) ) != 0 ) {
83  return 0;
84  }
85  int i;
86  for ( i = 0; i < T_CONS_ARITY( type ); i++ ) {
87  if ( tautologyLt( T_CONS_TYPE_ARG( type, 0 ), T_CONS_TYPE_ARG( expected, 0 ) ) == 0 ) {
88  return 0;
89  }
90  }
91  return 1;
92  }
93  else {
94  return tautologyLtBase( type, expected );
95  }
96 }
97 char *getBaseTypeOrTVarId( ExprType *a, char buf[128] ) {
98  if ( isBaseType( a ) ) {
99  snprintf( buf, 128, "%s", typeName_ExprType( a ) );
100  }
101  else {
102  getTVarName( T_VAR_ID( a ), buf );
103  }
104  return buf;
105 }
107  if ( getNodeType( a ) != T_IRODS && getNodeType( a ) == getNodeType( b ) ) {
108  return 1;
109  }
110  if ( getNodeType( a ) == T_INT && getNodeType( b ) == T_DOUBLE ) {
111  return 1;
112  }
113  if ( getNodeType( a ) == T_IRODS && getNodeType( b ) == T_IRODS && ( a->text == NULL || b->text == NULL || strcmp( a->text, b->text ) == 0 ) ) {
114  return 1;
115  }
116  int i;
117  if ( a->exprType != 0 && TYPE( a ) == T_VAR ) {
118  for ( i = 0; i < a->exprType->degree; i++ ) {
119  if ( typeEqSyntatic( a->exprType->subtrees[i], b ) ) {
120  return 1;
121  }
122  }
123  }
124  return 0;
125 }
127  if ( getNodeType( type ) == T_VAR ) {
128  return T_VAR_ID( var ) == T_VAR_ID( type );
129  }
130  else {
131  int i;
132  for ( i = 0; i < type->degree; i++ ) {
133  if ( occursIn( var, type->subtrees[i] ) ) {
134  return 1;
135  }
136  }
137  return 0;
138  }
139 }
140 ExprType* getEquivalenceClassRep( ExprType *varOrBase, Hashtable *equivalence ) {
141  ExprType *equiv1 = NULL, *equiv2;
142  char name[128];
143  equiv2 = varOrBase;
144  int ref = 0;
145  while ( equiv2 != NULL ) {
146  equiv1 = equiv2;
147  equiv2 = ( ExprType * ) lookupFromHashTable( equivalence, getBaseTypeOrTVarId( equiv1, name ) );
148  ref ++;
149  }
150  if ( ref > 1 ) {
151  updateInHashTable( equivalence, getBaseTypeOrTVarId( varOrBase, name ), equiv1 );
152  }
153  return equiv1;
154 
155 }
156 
157 
158 int occursInEquiv( ExprType *var, ExprType *type, Hashtable *equivalence ) {
159  if ( getNodeType( type ) == T_VAR && isBaseType( type ) ) {
160  ExprType *varEquiv = getEquivalenceClassRep( var, equivalence );
161  ExprType *typeEquiv = getEquivalenceClassRep( type, equivalence );
162  return typeEqSyntatic( varEquiv, typeEquiv );
163  }
164  else {
165  int i;
166  for ( i = 0; i < type->degree; i++ ) {
167  if ( occursInEquiv( var, type->subtrees[i], equivalence ) ) {
168  return 1;
169  }
170  }
171  return 0;
172  }
173 }
174 
175 Satisfiability splitVarR( ExprType *consTuple, ExprType *var, int flex, Node *node, Hashtable *typingEnv, Hashtable *equivalence, List *simpleTypingConstraints, Region *r ) {
176  if ( occursInEquiv( var, consTuple, equivalence ) || isBaseType( getEquivalenceClassRep( var, equivalence ) ) ) {
177  return ABSURDITY;
178  }
179  char tvarname[128];
180  ExprType **typeArgs = ( ExprType ** ) region_alloc( r, sizeof( ExprType * ) * T_CONS_ARITY( consTuple ) );
181  int i;
182  ExprType *type;
183  for ( i = 0; i < T_CONS_ARITY( consTuple ); i++ ) {
184  typeArgs[i] = newTVar( r );
185  }
186  if ( getNodeType( consTuple ) == T_CONS ) {
187  type = newConsType( T_CONS_ARITY( consTuple ), T_CONS_TYPE_NAME( consTuple ), typeArgs, r );
188  }
189  else {
190  type = newTupleType( T_CONS_ARITY( consTuple ), typeArgs, r );
191  }
192  insertIntoHashTable( typingEnv, getTVarName( T_VAR_ID( var ), tvarname ), type );
193  return splitConsOrTuple( consTuple, type, flex, node, typingEnv, equivalence, simpleTypingConstraints, r );
194 
195 }
196 Satisfiability splitVarL( ExprType *var, ExprType *consTuple, int flex, Node *node, Hashtable *typingEnv, Hashtable *equivalence, List *simpleTypingConstraints, Region *r ) {
197  if ( occursInEquiv( var, consTuple, equivalence ) || isBaseType( getEquivalenceClassRep( var, equivalence ) ) ) {
198  return ABSURDITY;
199  }
200  char tvarname[128];
201  ExprType **typeArgs = ( ExprType ** ) region_alloc( r, sizeof( ExprType * ) * T_CONS_ARITY( consTuple ) );
202  int i;
203  ExprType *type;
204  for ( i = 0; i < T_CONS_ARITY( consTuple ); i++ ) {
205  typeArgs[i] = newTVar( r );
206  }
207  if ( getNodeType( consTuple ) == T_CONS ) {
208  type = newConsType( T_CONS_ARITY( consTuple ), T_CONS_TYPE_NAME( consTuple ), typeArgs, r );
209  }
210  else {
211  type = newTupleType( T_CONS_ARITY( consTuple ), typeArgs, r );
212  }
213  insertIntoHashTable( typingEnv, getTVarName( T_VAR_ID( var ), tvarname ), type );
214  return splitConsOrTuple( type, consTuple, flex, node, typingEnv, equivalence, simpleTypingConstraints, r );
215 
216 }
217 
218 /*
219  * simplify b which is a variable, bounded or unbounded, based on a which is a base type
220  * returns 1 tautology
221  * 0 contingency
222  * -1 absurdity
223  */
224 Satisfiability simplifyR( ExprType *a, ExprType *b, int flex, Node *node, Hashtable *typingEnv, Hashtable *equivalence, List *simpleTypingConstraints, Region *r ) {
225  ExprType *bm;
226  if ( T_VAR_NUM_DISJUNCTS( b ) == 0 ) {
227  bm = getFullyBoundedVar( r );
228  }
229  else {
230  bm = b;
231  }
233  int nln, nrn;
234  doNarrow( &a, T_VAR_DISJUNCTS( bm ), 1, T_VAR_NUM_DISJUNCTS( bm ), flex, cl, cr, &nln, &nrn );
235  ExprType *bn;
236  if ( nrn == 0 ) {
237  return ABSURDITY;
238  }
239  else {
240  bn = createType( b, cr, nrn, typingEnv, equivalence, r );
241  if ( bn == b ) {
242  return TAUTOLOGY;
243  }
244 // insertIntoHashTable( typingEnv, b->text, bn );
245  return createSimpleConstraint( a, bn, flex, node, typingEnv, equivalence, simpleTypingConstraints, r );
246  }
247 }
248 
250  ExprType **ds = ( ExprType ** ) region_alloc( r, sizeof( ExprType * ) * N_BASE_TYPES );
251  int i;
252  for ( i = 0; i < N_BASE_TYPES; i++ ) {
253  ds[i] = newSimpType( baseTypes[i], r );
254  }
255  ExprType *var = newTVar2( N_BASE_TYPES, ds, r );
256  return var;
257 }
258 
259 Satisfiability simplifyL( ExprType *a, ExprType *b, int flex, Node *node, Hashtable *typingEnv, Hashtable *equivalence, List *simpleTypingConstraints, Region *r ) {
260  ExprType *am;
261  if ( T_VAR_NUM_DISJUNCTS( a ) == 0 ) {
262  am = getFullyBoundedVar( r );
263  }
264  else {
265  am = a;
266  }
268  int nln, nrn;
269  doNarrow( T_VAR_DISJUNCTS( am ), &b, T_VAR_NUM_DISJUNCTS( am ), 1, flex, cl, cr, &nln, &nrn );
270  ExprType *an;
271  if ( nln == 0 ) {
272  return ABSURDITY;
273  }
274  else {
275  an = createType( a, cl, nln, typingEnv, equivalence, r );
276  if ( an == a ) {
277  return TAUTOLOGY;
278  }
279 // insertIntoHashTable( typingEnv, a->text, an );
280  return createSimpleConstraint( an, b, flex, node, typingEnv, equivalence, simpleTypingConstraints, r );
281  }
282 
283 }
284 
285 void addToEquivalenceClass( ExprType *a, ExprType *b, Hashtable *equivalence ) {
286  char name[128];
287  ExprType *an = getEquivalenceClassRep( a, equivalence );
288  ExprType *bn = getEquivalenceClassRep( b, equivalence );
289  if ( !typeEqSyntatic( an, bn ) ) {
290  if ( isBaseType( an ) ) {
291  insertIntoHashTable( equivalence, getTVarName( T_VAR_ID( bn ), name ), an );
292  }
293  else {
294  insertIntoHashTable( equivalence, getTVarName( T_VAR_ID( an ), name ), bn );
295  }
296  }
297 }
298 void doNarrow( Node **l, Node **r, int ln, int rn, int flex, Node **nl, Node **nr, int *nln, int *nrn ) {
300  int i, k;
301  for ( i = 0; i < ln; i++ ) {
302  retl[i] = NULL;
303  }
304  for ( k = 0; k < rn; k++ ) {
305  retr[k] = NULL;
306  }
307  for ( k = 0; k < rn; k++ ) {
308  for ( i = 0; i < ln; i++ ) {
309  if ( applyBaseTypeRule( l[i], r[k], flex ) == TAUTOLOGY ) {
310  retl[i] = l[i];
311  retr[k] = r[k];
312  if ( getNodeType( l[i] ) == T_IRODS && l[i]->text == NULL ) {
313  retl[i] = retr[k];
314  }
315  if ( getNodeType( r[k] ) == T_IRODS && r[k]->text == NULL ) {
316  retr[k] = retl[i];
317  }
318  /* break;*/
319  }
320  }
321  }
322  *nln = 0;
323  for ( i = 0; i < ln; i++ ) {
324  if ( retl[i] != NULL ) {
325  nl[( *nln )++] = retl[i];
326  }
327  }
328  *nrn = 0;
329  for ( k = 0; k < rn; k++ ) {
330  if ( retr[k] != NULL ) {
331  nr[( *nrn )++] = retr[k];
332  }
333  }
334 }
335 
336 Satisfiability createSimpleConstraint( ExprType *a, ExprType *b, int flex, Node *node, Hashtable *typingEnv, Hashtable *equivalence, List *simpleTypingConstraints, Region *r ) {
337  char name[128];
338  if ( isBaseType( a ) && isBaseType( b ) ) {
339  return TAUTOLOGY;
340  }
341  else {
342  addToEquivalenceClass( a, b, equivalence );
343  if ( flex ) {
344  listAppend( simpleTypingConstraints, newTypingConstraint( a, newUnaryType( T_FLEX, b, r ), TC_LT, node, r ), r );
345  return CONTINGENCY;
346  }
347  else {
348  if ( ( getNodeType( a ) == T_VAR && T_VAR_NUM_DISJUNCTS( a ) == 0 ) || isBaseType( b ) ) {
349  insertIntoHashTable( typingEnv, getTVarName( T_VAR_ID( a ), name ), b );
350  }
351  else if ( ( getNodeType( b ) == T_VAR && T_VAR_NUM_DISJUNCTS( b ) == 0 ) || isBaseType( a ) ) {
352  insertIntoHashTable( typingEnv, getTVarName( T_VAR_ID( b ), name ), a );
353  }
354  else { // T_VAR_NUM_DISJUNCTS(a) == T_VAR_NUM_DISJUNCTS(b)
355  insertIntoHashTable( typingEnv, getTVarName( T_VAR_ID( a ), name ), b );
356  }
357  return TAUTOLOGY;
358  }
359  }
360 }
361 ExprType *createType( ExprType *t, Node **nc, int nn, Hashtable *typingEnv, Hashtable *equivalence, Region *r ) {
362  char name[128];
363  ExprType *gcd;
364  if ( nn == T_VAR_NUM_DISJUNCTS( t ) ) {
365  gcd = t;
366  }
367  else {
368  if ( nn == 1 ) {
369  gcd = *nc;
370  }
371  else {
372  gcd = newTVar2( nn, nc, r );
373  }
374  insertIntoHashTable( typingEnv, getTVarName( T_VAR_ID( t ), name ), gcd );
375  addToEquivalenceClass( t, gcd, equivalence );
376  }
377  return gcd;
378 }
379 Satisfiability narrow( ExprType *type, ExprType *expected, int flex, Node *node, Hashtable *typingEnv, Hashtable *equivalence, List *simpleTypingConstraints, Region *r ) {
380 
381  if ( T_VAR_ID( type ) == T_VAR_ID( expected ) ) {
382  return TAUTOLOGY;
383  }
384  else if ( T_VAR_NUM_DISJUNCTS( type ) > 0 && T_VAR_NUM_DISJUNCTS( expected ) > 0 ) {
385  int nln, nrn;
386  Node *cl[100], *cr[100];
387  doNarrow( T_VAR_DISJUNCTS( type ), T_VAR_DISJUNCTS( expected ), T_VAR_NUM_DISJUNCTS( type ), T_VAR_NUM_DISJUNCTS( expected ), flex, cl, cr, &nln, &nrn );
388  ExprType *an;
389  ExprType *bn;
390  if ( nln == 0 || nrn == 0 ) {
391  return ABSURDITY;
392  }
393  else {
394  an = createType( type, cl, nln, typingEnv, equivalence, r );
395  bn = createType( expected, cr, nrn, typingEnv, equivalence, r );
396  }
397  return createSimpleConstraint( an, bn, flex, node, typingEnv, equivalence, simpleTypingConstraints, r );
398  }
399  else if ( T_VAR_NUM_DISJUNCTS( type ) == 0 ) { /* free */
400  return createSimpleConstraint( type, expected, flex, node, typingEnv, equivalence, simpleTypingConstraints, r );
401  }
402  else { /*if(T_VAR_NUM_DISJUNCTS(expected)==0)*/
403  /* free */
404  return createSimpleConstraint( type, expected, flex, node, typingEnv, equivalence, simpleTypingConstraints, r );
405  }
406 }
407 #define logicalAnd(a, b, c) \
408  { \
409  switch(a) { \
410  case ABSURDITY: \
411  (c) = ABSURDITY; \
412  case CONTINGENCY: \
413  (c) = (b) == ABSURDITY ? ABSURDITY : CONTINGENCY; \
414  case TAUTOLOGY: \
415  (c) = (b); \
416  } \
417  }
418 
419 Satisfiability splitConsOrTuple( ExprType *a, ExprType *b, int flex, Node *node, Hashtable *typingEnv, Hashtable *equivalence, List *simpleTypingConstraints, Region *r ) {
420  /* split composite constraints with same top level type constructor */
421  if ( ( getNodeType( a ) == T_CONS && strcmp( T_CONS_TYPE_NAME( a ), T_CONS_TYPE_NAME( b ) ) != 0 ) ||
422  T_CONS_ARITY( a ) != T_CONS_ARITY( b ) ) {
423  return ABSURDITY;
424  }
425  else {
426  int i;
428  for ( i = 0; i < T_CONS_ARITY( a ); i++ ) {
429  ExprType *simpa = T_CONS_TYPE_ARG( a, i );
430  ExprType *simpb = T_CONS_TYPE_ARG( b, i );
431  Satisfiability sat = simplifyLocally( simpa, simpb, flex, node, typingEnv, equivalence, simpleTypingConstraints, r );
432  switch ( sat ) {
433  case ABSURDITY:
434  return ABSURDITY;
435  case TAUTOLOGY:
436  break;
437  case CONTINGENCY:
438  ret = CONTINGENCY;
439  break;
440  }
441 
442  }
443  return ret;
444  }
445 }
446 
447 
448 int isBaseType( ExprType *t ) {
449  int i;
450  for ( i = 0; i < N_BASE_TYPES; i++ ) {
451  if ( getNodeType( t ) == baseTypes[i] ) {
452  return 1;
453  }
454  }
455  return 0;
456 }
457 
458 int applyBaseTypeRule( ExprType *tca, ExprType *tcb, int flex ) {
459  return ( flex && tautologyLtBase( tca, tcb ) ) ||
460  ( !flex && ( ( getNodeType( tca ) == T_IRODS && getNodeType( tcb ) == T_IRODS && ( tca->text == NULL || tcb->text == NULL ) ) ||
461  typeEqSyntatic( tca, tcb ) ) );
462 }
463 
464 int baseRuleApplies( ExprType *ta, ExprType *tb, int flex, ExprType **templa, ExprType **templb, Region *r ) {
465  if ( isBaseType( ta ) && isBaseType( tb ) && applyBaseTypeRule( ta, tb, flex ) ) {
466  *templa = ta;
467  *templb = tb;
468  return 1;
469  }
470  else if ( flex && isIterableBaseRuleType( ta, templa, templb, r ) && getNodeType( tb ) == T_CONS ) {
471  return 1;
472  }
473  else {
474  return 0;
475  }
476 }
477 
478 Satisfiability simplifyLocally( ExprType *tca, ExprType *tcb, int flex, Node *node, Hashtable *typingEnv, Hashtable *equivalence, List *simpleTypingConstraints, Region *r ) {
479  /*
480  char buf[1024], buf2[1024], buf3[1024], buf4[ERR_MSG_LEN];
481  generateErrMsg("simplifyLocally: constraint generated from ", NODE_EXPR_POS(node), node->base, buf4);
482  printf("%s", buf4);
483  snprintf(buf, 1024, "\t%s<%s\n",
484  typeToString(tca, NULL, buf2, 1024),
485  typeToString(tcb, NULL, buf3, 1024));
486  printf("%s", buf);
487  snprintf(buf, 1024, "\tinstantiated: %s<%s\n",
488  typeToString(tca, typingEnv, buf2, 1024),
489  typeToString(tcb, typingEnv, buf3, 1024));
490  printf("%s", buf);
491  */
492  if ( tca == tcb ) {
493  return TAUTOLOGY;
494  }
495 
496  if ( getNodeType( tcb ) == T_FLEX ) {
497  tcb = tcb->subtrees[0];
498  flex = 1;
499  }
500  else if ( getNodeType( tcb ) == T_FIXD ) {
501  tcb = tcb->subtrees[0];
502  }
503 
504  tca = dereference( tca, typingEnv, r );
505  tcb = dereference( tcb, typingEnv, r );
506 
507  ExprType *templa, *templb;
508 
509  if ( getNodeType( tca ) == T_UNSPECED || getNodeType( tca ) == T_DYNAMIC || getNodeType( tcb ) == T_DYNAMIC ) { /* is an undefined variable argument or a parameter with dynamic type */
510  return TAUTOLOGY;
511  }
512  else if ( baseRuleApplies( tca, tcb, flex, &templa, &templb, r ) ) {
514  logicalAnd( simplifyLocally( tca, templa, flex, node, typingEnv, equivalence, simpleTypingConstraints, r ),
515  simplifyLocally( templb, tcb, flex, node, typingEnv, equivalence, simpleTypingConstraints, r ), c );
516  return c;
517  }
518  else if ( getNodeType( tca ) == T_VAR && getNodeType( tcb ) == T_VAR ) {
519  return narrow( tca, tcb, flex, node, typingEnv, equivalence, simpleTypingConstraints, r );
520 
521  }
522  else if ( getNodeType( tca ) == T_VAR && isBaseType( tcb ) ) {
523  return simplifyL( tca, tcb, flex, node, typingEnv, equivalence, simpleTypingConstraints, r );
524 
525  }
526  else if ( getNodeType( tcb ) == T_VAR && isBaseType( tca ) ) {
527  return simplifyR( tca, tcb, flex, node, typingEnv, equivalence, simpleTypingConstraints, r );
528 
529  }
530  else if ( getNodeType( tca ) == T_VAR && ( getNodeType( tcb ) == T_CONS || getNodeType( tcb ) == T_TUPLE ) ) {
531  return splitVarL( tca, tcb, flex, node, typingEnv, equivalence, simpleTypingConstraints, r );
532 
533  }
534  else if ( getNodeType( tcb ) == T_VAR && ( getNodeType( tca ) == T_CONS || getNodeType( tca ) == T_TUPLE ) ) {
535  return splitVarR( tca, tcb, flex, node, typingEnv, equivalence, simpleTypingConstraints, r );
536 
537  }
538  else if ( ( getNodeType( tca ) == T_CONS && getNodeType( tcb ) == T_CONS )
539  || ( getNodeType( tca ) == T_TUPLE && getNodeType( tcb ) == T_TUPLE ) ) {
540  return splitConsOrTuple( tca, tcb, flex, node, typingEnv, equivalence, simpleTypingConstraints, r );
541  }
542  else {
543  return ABSURDITY;
544  }
545 }
546 /*
547  * not 0 solved
548  * 0 not solved
549  */
550 Satisfiability solveConstraints( List *typingConstraints, Hashtable *typingEnv, rError_t *errmsg, Node ** errnode, Region *r ) {
551  /*
552  char buf0[1024];
553  typingConstraintsToString(typingConstraints, buf0, 1024);
554  printf("solving constraints: %s\n", buf0);
555  */
556  ListNode *nextNode = NULL;
557  do {
558  Satisfiability sat = simplify( typingConstraints, typingEnv, errmsg, errnode, r );
559  if ( sat == ABSURDITY ) {
560  return ABSURDITY;
561  }
562  int changed = 0;
563  nextNode = typingConstraints->head;
564  while ( nextNode != NULL && !changed ) {
565  TypingConstraint *tc = ( TypingConstraint * )nextNode->value;
566  /*
567  char buf2[1024], buf3[1024];
568  */
569  /* printf("dereferencing %s and %s.\n", typeToString(TC_A(tc), typingEnv, buf2, 1024), typeToString(TC_B(tc), typingEnv, buf3, 1024)); */
570  ExprType *a = dereference( TC_A( tc ), typingEnv, r );
571  ExprType *b = dereference( TC_B( tc ), typingEnv, r );
572  if ( getNodeType( b ) == T_FLEX || getNodeType( b ) == T_FIXD ) {
573  b = b->subtrees[0];
574  }
575  /*
576  printf("warning: collasping %s with %s.\n", typeToString(a, typingEnv, buf2, 1024), typeToString(b, typingEnv, buf3, 1024));
577  */
578  /*printVarTypeEnvToStdOut(typingEnv); */
579  if ( getNodeType( a ) == T_VAR && getNodeType( b ) == T_VAR && T_VAR_ID( a ) == T_VAR_ID( b ) ) {
580  listRemove( typingConstraints, nextNode );
581  nextNode = typingConstraints->head;
582  changed = 1;
583  /* } else if (getNodeType(a) == T_VAR && T_VAR_NUM_DISJUNCTS(a) == 0 &&
584  (getNodeType(b) != T_VAR || T_VAR_NUM_DISJUNCTS(b) != 0)) {
585  insertIntoHashTable(typingEnv, getTVarName(T_VAR_ID(a), buf), b);
586  listRemove(typingConstraints, nextNode);
587  nextNode = typingConstraints->head;
588  changed = 1;
589  } else if (getNodeType(b) == T_VAR && T_VAR_NUM_DISJUNCTS(b) == 0 &&
590  (getNodeType(a) != T_VAR || T_VAR_NUM_DISJUNCTS(a) != 0)) {
591  insertIntoHashTable(typingEnv, getTVarName(T_VAR_ID(b), buf), a);
592  listRemove(typingConstraints, nextNode);
593  nextNode = typingConstraints->head;
594  changed = 1;
595  } else if (getNodeType(a) == T_VAR && getNodeType(b) == T_VAR &&
596  T_VAR_NUM_DISJUNCTS(a) != 0 && T_VAR_NUM_DISJUNCTS(b) != 0) {
597  if(T_VAR_NUM_DISJUNCTS(a) > T_VAR_NUM_DISJUNCTS(b)) {
598  insertIntoHashTable(typingEnv, getTVarName(T_VAR_ID(b), buf), a);
599  } else {
600  insertIntoHashTable(typingEnv, getTVarName(T_VAR_ID(a), buf), b);
601  }
602  listRemove(typingConstraints, nextNode);
603  nextNode = typingConstraints->head;
604  changed = 1;*/
605  }
606  else if ( getNodeType( a ) != T_VAR && getNodeType( b ) != T_VAR ) {
607  printf( "error: simplified type does not have variable on either side.\n" );
608  }
609  else {
610  nextNode = nextNode->next;
611  }
612  /* printVarTypeEnvToStdOut(typingEnv); */
613  }
614  }
615  while ( nextNode != NULL );
616  if ( !consistent( typingConstraints, typingEnv, r ) ) {
617  return ABSURDITY;
618  }
619  return typingConstraints->head == NULL ? TAUTOLOGY : CONTINGENCY;
620 }
621 
623  return 1;
624 }
625 Satisfiability simplify( List *typingConstraints, Hashtable *typingEnv, rError_t *errmsg, Node **errnode, Region *r ) {
626  ListNode *ln;
627  int changed;
628  Hashtable *equivalence = newHashTable2( 10, r );
629  List *simpleTypingConstraints = newList( r );
630  /* printf("start\n"); */
631  /*char buf[1024];
632  typingConstraintsToString(typingConstraints, buf, 1024);*/
634  do {
635  changed = typingEnv->len;
636  ln = typingConstraints->head;
637  /*typingConstraintsToString(typingConstraints, buf, 1024);
638  printf("constraints: \n%s\n\n", buf);*/
639  while ( ln != NULL ) {
640  TypingConstraint *tc = ( TypingConstraint * )ln->value;
641  switch ( simplifyLocally( TC_A( tc ), TC_B( tc ), 0, TC_NODE( tc ), typingEnv, equivalence, simpleTypingConstraints, r ) ) {
642  case TAUTOLOGY:
643  break;
644  case CONTINGENCY:
645  /* printf("contingency\n"); */
646  /* printf("tautology\n"); */
647  /* TypingConstraint *tcp;
648  tcp = tc;
649  while(tcp!=NULL) {
650  printf("simplified %s<%s to %s<%s.\n",
651  typeToString(a, NULL, buf3, 1024), typeToString(b, NULL, buf4, 1024),
652  typeToString(tcp->a, NULL, buf1, 1024), typeToString(tcp->b, NULL, buf2, 1024));
653  tcp = tcp->next;
654  }*/
655  ret = CONTINGENCY;
656  break;
657  case ABSURDITY:
658  *errnode = TC_NODE( tc );
659  char errmsgbuf1[ERR_MSG_LEN], errmsgbuf2[ERR_MSG_LEN], buf2[1024], buf3[1024];
660  snprintf( errmsgbuf1, ERR_MSG_LEN, "simplify: unsolvable typing constraint %s < %s.\n", typeToString( TC_A( tc ), typingEnv, buf2, 1024 ), typeToString( TC_B( tc ), typingEnv, buf3, 1024 ) );
661  generateErrMsg( errmsgbuf1, NODE_EXPR_POS( ( *errnode ) ), ( *errnode )->base, errmsgbuf2 );
662  addRErrorMsg( errmsg, RE_TYPE_ERROR, errmsgbuf2 );
663  /*printVarTypeEnvToStdOut(typingEnv); */
664  /* printf("absurdity\n"); */
665  return ABSURDITY;
666  }
667  ln = ln->next;
668  }
669  /*typingConstraintsToString(typingConstraints, buf, 1024);
670  printf("simplified constraints: \n%s\n\n", buf);
671  printHashtable(typingEnv, buf);
672  printf("env: \n%s\n", buf);*/
673  typingConstraints->head = simpleTypingConstraints->head;
674  typingConstraints->tail = simpleTypingConstraints->tail;
675  simpleTypingConstraints->head = simpleTypingConstraints->tail = NULL;
676  }
677  while ( changed < typingEnv->len );
678 
679  return ret;
680 }
681 
682 /* return the elem type of special iterable types
683  * assume that type is a special iterable type */
685  if ( getNodeType( type ) == T_STRING ) {
686  return newSimpType( T_STRING, r );
687  }
688  else if ( getNodeType( type ) == T_PATH || strcmp( type->text, CollInp_MS_T ) == 0 ) {
689  return newIRODSType( DataObjInp_MS_T, r );
690  }
691  else if ( strcmp( type->text, IntArray_MS_T ) == 0 ) {
692  return newSimpType( T_INT, r );
693  }
694  else if ( strcmp( type->text, StrArray_MS_T ) == 0 ) {
695  return newSimpType( T_STRING, r );
696  }
697  else if ( strcmp( type->text, GenQueryOut_MS_T ) == 0 ) {
698  return newIRODSType( KeyValPair_MS_T, r );
699  }
700  else if ( strcmp( type->text, KeyValPair_MS_T ) == 0 ) {
701  return newSimpType( T_STRING, r );
702  }
703  return NULL;
704 }
705 /*
706  * param templa a template type which this type must conform to in order to be used in a base rule.
707  * templb a template type which the supertype must conform to in order to be used in a base rule.
708  */
709 int isIterableBaseRuleType( ExprType *type, ExprType **templa, ExprType **templb, Region *r ) {
710  int nodeType = getNodeType( type );
711  char *typeName = type->text;
712  switch ( nodeType ) {
713  case T_IRODS:
714  if ( strcmp( typeName, CollInp_MS_T ) == 0 ) {
715  *templa = type;
716  }
717  else if ( strcmp( typeName, IntArray_MS_T ) == 0 ) {
718  *templa = type;
719  }
720  else if ( strcmp( typeName, StrArray_MS_T ) == 0 ) {
721  *templa = type;
722  }
723  else if ( strcmp( typeName, GenQueryOut_MS_T ) == 0 ) {
724  *templa = type;
725  }
726  else if ( strcmp( typeName, KeyValPair_MS_T ) == 0 ) {
727  *templa = type;
728  }
729  else {
730  return 0;
731  }
732  *templb = newCollType( getElemType( type, r ), r );
733  return 1;
734  case T_STRING:
735  *templa = type;
736  *templb = newCollType( newSimpType( T_STRING, r ), r );
737  return 1;
738  case T_PATH:
739  *templa = type;
740  *templb = newCollType( getElemType( type, r ), r );
741  return 1;
742  case T_TUPLE:
743  if ( T_CONS_ARITY( type ) == 2 ) {
744  ExprType **compTypes = ( ExprType ** )region_alloc( r, sizeof( ExprType * ) * 2 );
745  compTypes[0] = newIRODSType( GenQueryInp_MS_T, r );
746  compTypes[1] = newIRODSType( GenQueryOut_MS_T, r );
747  *templa = newTupleType( 2, compTypes, r );
748  *templb = newCollType( newIRODSType( KeyValPair_MS_T, r ), r );
749  return 1;
750  }
751  else {
752  return 0;
753  }
754  default:
755  return 0;
756  }
757 }
758 /* return the elem type if type is iterable
759  * null if type is not iterable
760  * type does not need to be dereferenced
761  */
762 ExprType* isIterable( ExprType *type, Hashtable* var_type_table, Region *r ) {
763  ExprType *derefedType = dereference( type, var_type_table, r );
764  Node *disjuncts[6];
765  Res *unified, *comp0, *comp1;
766  switch ( getNodeType( derefedType ) ) {
767  case T_CONS:
768  if ( strcmp( type->text, LIST ) == 0 ) { /* list */
769  /* dereference element type as only top level vars are dereferenced by the dereference function and we are accessing a subtree of the type */
770  return dereference( T_CONS_TYPE_ARG( derefedType, 0 ), var_type_table, r );
771  }
772  else {
773  return NULL;
774  }
775  case T_VAR:
776  if ( T_VAR_NUM_DISJUNCTS( derefedType ) == 0 ) { /* not a union type */
777  /* overwrite type of collection variable */
778  unifyTVarL( derefedType, newCollType( newTVar( r ), r ), var_type_table, r );
779  derefedType = dereference( derefedType, var_type_table, r );
780  return dereference( T_CONS_TYPE_ARG( derefedType, 0 ), var_type_table, r );
781  }
782  /* no break */
783  disjuncts[0] = newSimpType( T_STRING, r );
784  disjuncts[1] = newIRODSType( CollInp_MS_T, r );
785  disjuncts[2] = newIRODSType( IntArray_MS_T, r );
786  disjuncts[3] = newIRODSType( StrArray_MS_T, r );
787  disjuncts[4] = newIRODSType( GenQueryOut_MS_T, r );
788  disjuncts[5] = newSimpType( T_PATH, r );
789 
790  unified = unifyTVarL( derefedType, newTVar2( 6, disjuncts, r ), var_type_table, r );
791  if ( getNodeType( unified ) == T_ERROR ) {
792  return NULL;
793  }
794  if ( unified->nodeType == T_VAR ) { /* more than one possible types */
795  Node *disjunctsElem[4];
796  int i;
797  for ( i = 0; i < T_VAR_NUM_DISJUNCTS( unified ); i++ ) {
798  disjunctsElem[i] = getElemType( T_VAR_DISJUNCT( unified, i ), r );
799  }
800  return newTVar2( T_VAR_NUM_DISJUNCTS( unified ), disjunctsElem, r );
801  }
802  else {
803  return getElemType( unified, r );
804  }
805 
806  case T_IRODS:
807  case T_STRING:
808  case T_PATH:
809  return getElemType( derefedType, r );
810 
811  case T_TUPLE:
812  if ( T_CONS_ARITY( derefedType ) != 2 ) {
813  return NULL;
814  }
815  comp0 = dereference( T_CONS_TYPE_ARG( derefedType, 0 ), var_type_table, r );
816  comp1 = dereference( T_CONS_TYPE_ARG( derefedType, 1 ), var_type_table, r );
817  if ( getNodeType( comp0 ) != T_IRODS ||
818  strcmp( T_CONS_TYPE_NAME( comp0 ), GenQueryInp_MS_T ) != 0 ||
819  getNodeType( comp1 ) != T_IRODS ||
820  strcmp( T_CONS_TYPE_NAME( comp1 ), GenQueryOut_MS_T ) != 0 ) {
821  return NULL;
822  }
823  return newIRODSType( KeyValPair_MS_T, r );
824 
825  case T_DYNAMIC:
826  return type;
827  default:
828  return NULL;
829  }
830 }
831 
832 
833 ExprType* typeFunction3( Node* node, int dynamictyping, Env* funcDesc, Hashtable* var_type_table, List *typingConstraints, rError_t *errmsg, Node **errnode, Region *r ) {
834  /*printTree(node, 0); */
835  int i;
836  char *localErrorMsg;
837  ExprType *res3 = NULL;
838  /*char buf[1024];*/
839  /*printf("typeing %s\n",fn); */
840  /*printVarTypeEnvToStdOut(var_type_table); */
841  Node *fn = node->subtrees[0];
842  Node *arg = node->subtrees[1];
843  char buf[ERR_MSG_LEN];
844  /* char errbuf[ERR_MSG_LEN]; */
845  char typebuf[ERR_MSG_LEN];
846  char typebuf2[ERR_MSG_LEN];
847 
848  if ( getNodeType( fn ) == TK_TEXT && strcmp( fn->text, "foreach" ) == 0 ) {
849  RE_ERROR2( getNodeType( arg ) != N_TUPLE || arg->degree != 3, "wrong number of arguments to microservice" );
850  RE_ERROR2( getNodeType( arg->subtrees[0] ) != TK_VAR, "argument form error" );
851  char* varname = arg->subtrees[0]->text;
852  ExprType *varType0 = ( ExprType * )lookupFromHashTable( var_type_table, varname );
853  ExprType *varType;
854  ExprType *collType = varType0 == NULL ? NULL : dereference( varType0, var_type_table, r );
855  if ( collType != NULL ) {
856  varType = isIterable( collType, var_type_table, r );
857  if ( varType == NULL ) {
858  /* error if res is not an iterable type */
859  RE_ERROR2( 1, "foreach is applied to a non collection type" );
860  }
861  }
862  else {
863  varType = newTVar( r );
864  collType = newCollType( varType, r );
865  }
866  if ( varType0 == NULL ) {
867  insertIntoHashTable( var_type_table, varname, varType );
868  }
869  else {
870  updateInHashTable( var_type_table, varname, varType );
871  }
872  arg->subtrees[0]->exprType = collType;
873  res3 = typeExpression3( arg->subtrees[1], dynamictyping, funcDesc, var_type_table, typingConstraints, errmsg, errnode, r );
874  RE_ERROR2( getNodeType( res3 ) == T_ERROR, "foreach loop type error" );
875  res3 = typeExpression3( arg->subtrees[2], dynamictyping, funcDesc, var_type_table, typingConstraints, errmsg, errnode, r );
876  RE_ERROR2( getNodeType( res3 ) == T_ERROR, "foreach recovery type error" );
878  for ( i = 1; i < 3; i++ ) {
879  setIOType( arg->subtrees[i], IO_TYPE_ACTIONS );
880  }
881  ExprType **typeArgs = allocSubtrees( r, 3 );
882  typeArgs[0] = collType;
883  typeArgs[1] = newTVar( r );
884  typeArgs[2] = newTVar( r );
885  arg->coercionType = newTupleType( 3, typeArgs, r );
886 
887  updateInHashTable( var_type_table, varname, collType ); /* restore type of collection variable */
888  return res3;
889  }
890  else {
891  ExprType *fnType = typeExpression3( fn, dynamictyping, funcDesc, var_type_table, typingConstraints, errmsg, errnode, r );
892  if ( getNodeType( fnType ) == T_ERROR ) {
893  return fnType;
894  }
895  N_TUPLE_CONSTRUCT_TUPLE( arg ) = 1; /* arg must be a N_TUPLE node */
896  ExprType *argType = typeExpression3( arg, dynamictyping, funcDesc, var_type_table, typingConstraints, errmsg, errnode, r );
897  if ( getNodeType( argType ) == T_ERROR ) {
898  return argType;
899  }
900 
901  ExprType *fType = getNodeType( fnType ) == T_CONS && strcmp( fnType->text, FUNC ) == 0 ? fnType : unifyWith( fnType, newFuncType( newTVar( r ), newTVar( r ), r ), var_type_table, r );
902 
903  RE_ERROR2( getNodeType( fType ) == T_ERROR, "the first component of a function application does not have a function type" );
904  ExprType *paramType = dereference( fType->subtrees[0], var_type_table, r );
905  ExprType *retType = dereference( fType->subtrees[1], var_type_table, r );
906 
907  RE_ERROR2( getNodeType( fn ) == TK_TEXT && strcmp( fn->text, "assign" ) == 0 &&
908  arg->degree > 0 &&
909  !isPattern( arg->subtrees[0] ), "the first argument of microservice assign is not a variable or a pattern" );
910  RE_ERROR2( getNodeType( fn ) == TK_TEXT && strcmp( fn->text, "let" ) == 0 &&
911  arg->degree > 0 &&
912  !isPattern( arg->subtrees[0] ), "the first argument of microservice let is not a variable or a pattern" );
913 
914  /*
915  printf("start typing %s\n", fn);
916  printTreeDeref(node, 0, var_type_table, r);
917  */
918  ExprType *t = NULL;
919  if ( getVararg( fType ) != OPTION_VARARG_ONCE ) {
920  /* generate instance of vararg tuple so that no vararg tuple goes into typing constraints */
921  int fixParamN = paramType->degree - 1;
922  int argN = node->subtrees[1] ->degree;
923  int copyN = argN - fixParamN;
924  ExprType **subtrees = paramType->subtrees;
925  if ( copyN < ( getVararg( fType ) == OPTION_VARARG_PLUS ? 1 : 0 ) || ( getVararg( fType ) == OPTION_VARARG_OPTIONAL && copyN > 1 ) ) {
926  snprintf( buf, 1024, "unsolvable vararg typing constraint %s < %s %s",
927  typeToString( argType, var_type_table, typebuf, ERR_MSG_LEN ),
928  typeToString( paramType, var_type_table, typebuf2, ERR_MSG_LEN ),
929  getVararg( fType ) == OPTION_VARARG_PLUS ? "*" : getVararg( fType ) == OPTION_VARARG_OPTIONAL ? "?" : "+" );
930  RE_ERROR2( 1, buf );
931  }
932  ExprType **paramTypes = allocSubtrees( r, argN );
933  int i;
934  for ( i = 0; i < fixParamN; i++ ) {
935  paramTypes[i] = subtrees[i];
936  }
937  for ( i = 0; i < copyN; i++ ) {
938  paramTypes[i + fixParamN] = subtrees[fixParamN];
939  }
940  t = newTupleType( argN, paramTypes, r );
941  }
942  else {
943  t = paramType;
944  }
945  /*t = replaceDynamicWithNewTVar(t, r);
946  argType = replaceDynamicWithNewTVar(argType, r);*/
947  int ret = typeFuncParam( node->subtrees[1], argType, t, var_type_table, typingConstraints, errmsg, r );
948  if ( ret != 0 ) {
949  *errnode = node->subtrees[1];
950  RE_ERROR2( true, "parameter type error" );
951  }
952  int i;
953  for ( i = 0; i < node->subtrees[1]->degree; i++ ) {
954  setIOType( node->subtrees[1]->subtrees[i], getIOType( t->subtrees[i] ) );
955  }
956 
957  arg->coercionType = t; /* set coersion to parameter type */
958 
959  /*
960  printTreeDeref(node, 0, var_type_table, r);
961  printf("finish typing %s\n", fn);
962  */
963  return instantiate( replaceDynamicWithNewTVar( retType, r ), var_type_table, 0, r );
964  }
965  char errbuf[ERR_MSG_LEN];
966  char errmsgbuf[ERR_MSG_LEN];
967 error:
968  *errnode = node;
969  snprintf( errmsgbuf, ERR_MSG_LEN, "type error: %s in %s", localErrorMsg, fn->text );
970  generateErrMsg( errmsgbuf, NODE_EXPR_POS( ( *errnode ) ), ( *errnode )->base, errbuf );
971  addRErrorMsg( errmsg, RE_TYPE_ERROR, errbuf );
972  return newSimpType( T_ERROR, r );
973 }
975  ExprType *newt = ( ExprType * )region_alloc( r, sizeof( ExprType ) );
976  *newt = *type;
977  if ( getNodeType( type ) == T_DYNAMIC ) {
978  setNodeType( newt, T_VAR );
979  T_VAR_ID( newt ) = newTVarId();
980  }
981  int i;
982  for ( i = 0; i < type->degree; i++ ) {
983  newt->subtrees[i] = replaceDynamicWithNewTVar( type->subtrees[i], r );
984  }
985  return newt;
986 }
987 int typeFuncParam( Node *param, Node *paramType, Node *formalParamType, Hashtable *var_type_table, List *typingConstraints, rError_t *errmsg, Region *r ) {
988  /*char buf[ERR_MSG_LEN];
989  char errbuf[ERR_MSG_LEN];
990  char typebuf[ERR_MSG_LEN];
991  char typebuf2[ERR_MSG_LEN]; */
992  /* printf("typing param %s < %s\n",
993  typeToString(paramType, var_type_table, typebuf, ERR_MSG_LEN),
994  typeToString(formalParamType, var_type_table, typebuf2, ERR_MSG_LEN)); */
995 
996 
997  TypingConstraint *tc = newTypingConstraint( paramType, formalParamType, TC_LT, param, r );
998  listAppend( typingConstraints, tc, r );
999  Node *errnode;
1000  Satisfiability tcons = simplify( typingConstraints, var_type_table, errmsg, &errnode, r );
1001  switch ( tcons ) {
1002  case TAUTOLOGY:
1003  break;
1004  case CONTINGENCY:
1005  break;
1006  case ABSURDITY:
1007  return -1;
1008  }
1009  return 0;
1010 }
1011 
1012 ExprType* typeTypeAscription( Node *expr, int dynamictyping, Env *funcDesc, Hashtable *varTypes, List *typingConstraints, rError_t *errmsg, Node **errnode, Region *r ) {
1013  char errbuf[ERR_MSG_LEN];
1014  char errmsgbuf[ERR_MSG_LEN];
1015  char typebuf[ERR_MSG_LEN];
1016  char typebuf2[ERR_MSG_LEN];
1017  Node *param = expr->subtrees[0];
1018  ExprType *ascType = expr->subtrees[1];
1019  ExprType *exprType = typeExpression3( param, dynamictyping, funcDesc, varTypes, typingConstraints, errmsg, errnode, r );
1020  if ( getNodeType( exprType ) == T_ERROR ) {
1021  return exprType;
1022  }
1023 
1024  ExprType *t = unifyWith( exprType, ascType, varTypes, r );
1025  if ( t == NULL ) {
1026  *errnode = expr;
1027  snprintf( errmsgbuf, ERR_MSG_LEN, "type error: cannot unify source %s and target %s", typeToString(exprType, varTypes, typebuf, ERR_MSG_LEN), typeToString(ascType, varTypes, typebuf2, ERR_MSG_LEN));
1028  generateErrMsg( errmsgbuf, NODE_EXPR_POS( ( *errnode ) ), ( *errnode )->base, errbuf );
1029  addRErrorMsg( errmsg, RE_TYPE_ERROR, errbuf );
1030  return newSimpType( T_ERROR, r );
1031  }
1032  return t;
1033 }
1034 
1035 ExprType* typeExpression3( Node *expr, int dynamictyping, Env *funcDesc, Hashtable *varTypes, List *typingConstraints, rError_t *errmsg, Node **errnode, Region *r ) {
1036  ExprType *res = NULL;
1037  ExprType **components;
1038  ExprType* t = NULL;
1039  int i;
1040  expr->option |= OPTION_TYPED;
1041  switch ( getNodeType( expr ) ) {
1042  case TK_BOOL:
1043  return expr->exprType = dynamictyping ? newSimpType( T_DYNAMIC, r ) : newSimpType( T_BOOL, r );
1044  case TK_INT:
1045  return expr->exprType = dynamictyping ? newSimpType( T_DYNAMIC, r ) : newSimpType( T_INT, r );
1046  case TK_DOUBLE:
1047  return expr->exprType = dynamictyping ? newSimpType( T_DYNAMIC, r ) : newSimpType( T_DOUBLE, r );
1048  case TK_STRING:
1049  return expr->exprType = dynamictyping ? newSimpType( T_DYNAMIC, r ) : newSimpType( T_STRING, r );
1050  case TK_VAR:
1051  t = ( ExprType * )lookupFromHashTable( varTypes, expr->text );
1052  if ( t == NULL ) {
1053  /* define new variable */
1054  t = newTVar( r );
1055  insertIntoHashTable( varTypes, expr->text, t );
1056  }
1057  t = dereference( t, varTypes, r );
1058  return expr->exprType = t;
1059  case TK_TEXT:
1060  if ( strcmp( expr->text, "nop" ) == 0 ) {
1061  return expr->exprType = newFuncType( newTupleType( 0, NULL, r ), newSimpType( T_INT, r ), r );
1062  }
1063  else {
1064  /* not a variable, evaluate as a function */
1065  FunctionDesc *fDesc;
1066  if ( funcDesc != NULL && ( fDesc = ( FunctionDesc* )lookupFromEnv( funcDesc, expr->text ) ) != NULL && fDesc->exprType != NULL ) {
1067  return expr->exprType = dupType( fDesc->exprType, r );
1068  }
1069  else {
1070  ExprType *paramType = newSimpType( T_DYNAMIC, r );
1071  setIOType( paramType, IO_TYPE_DYNAMIC );
1072  ExprType *fType = newFuncType( newUnaryType( T_TUPLE, paramType, r ), newSimpType( T_DYNAMIC, r ), r );
1073  setVararg( fType, OPTION_VARARG_STAR );
1074  return expr->exprType = fType;
1075  }
1076  }
1077  case N_TUPLE:
1078  components = ( ExprType ** ) region_alloc( r, sizeof( ExprType * ) * expr->degree );
1079  for ( i = 0; i < expr->degree; i++ ) {
1080  components[i] = typeExpression3( expr->subtrees[i], dynamictyping, funcDesc, varTypes, typingConstraints, errmsg, errnode, r );
1081  if ( getNodeType( components[i] ) == T_ERROR ) {
1082  return expr->exprType = components[i];
1083  }
1084  }
1085  if ( N_TUPLE_CONSTRUCT_TUPLE( expr ) || expr->degree != 1 ) {
1086  return expr->exprType = newTupleType( expr->degree, components, r );
1087  }
1088  else {
1089  return expr->exprType = components[0];
1090  }
1091 
1092  case N_APPLICATION:
1093  /* try to type as a function */
1094  /* the exprType is used to store the type of the return value */
1095  return expr->exprType = typeFunction3( expr, dynamictyping, funcDesc, varTypes, typingConstraints, errmsg, errnode, r );
1096  case N_ACTIONS:
1097  if ( expr->degree == 0 ) {
1098  /* type of empty action sequence == T_INT */
1099  return expr->exprType = newSimpType( T_INT, r );
1100  }
1101  for ( i = 0; i < expr->degree; i++ ) {
1102  /*printf("typing action in actions"); */
1103  res = typeExpression3( expr->subtrees[i], dynamictyping, funcDesc, varTypes, typingConstraints, errmsg, errnode, r );
1104  /*printVarTypeEnvToStdOut(varTypes); */
1105  if ( getNodeType( res ) == T_ERROR ) {
1106  return expr->exprType = res;
1107  }
1108  }
1109  return expr->exprType = res;
1110  case N_ACTIONS_RECOVERY:
1111  res = typeExpression3( expr->subtrees[0], dynamictyping, funcDesc, varTypes, typingConstraints, errmsg, errnode, r );
1112  if ( getNodeType( res ) == T_ERROR ) {
1113  return expr->exprType = res;
1114  }
1115  res = typeExpression3( expr->subtrees[1], dynamictyping, funcDesc, varTypes, typingConstraints, errmsg, errnode, r );
1116  return expr->exprType = res;
1117  case N_ATTR:
1118  /* todo type */
1119  for ( i = 0; i < expr->degree; i++ ) {
1120  res = typeExpression3( expr->subtrees[i], dynamictyping, funcDesc, varTypes, typingConstraints, errmsg, errnode, r );
1121  if ( getNodeType( res ) == T_ERROR ) {
1122  return expr->exprType = res;
1123  }
1124  }
1125  return expr->exprType = newSimpType( T_DYNAMIC, r );
1126  case N_QUERY_COND_JUNCTION:
1127  /* todo type */
1128  for ( i = 0; i < expr->degree; i++ ) {
1129  res = typeExpression3( expr->subtrees[i], dynamictyping, funcDesc, varTypes, typingConstraints, errmsg, errnode, r );
1130  if ( getNodeType( res ) == T_ERROR ) {
1131  return expr->exprType = res;
1132  }
1133  }
1134  return expr->exprType = newSimpType( T_DYNAMIC, r );
1135  case N_QUERY:
1136  /* todo type */
1137  for ( i = 0; i < expr->degree; i++ ) {
1138  res = typeExpression3( expr->subtrees[i], dynamictyping, funcDesc, varTypes, typingConstraints, errmsg, errnode, r );
1139  if ( getNodeType( res ) == T_ERROR ) {
1140  return expr->exprType = res;
1141  }
1142  }
1143  return expr->exprType = newSimpType( T_DYNAMIC, r );
1144  case N_QUERY_COND:
1145  /* todo type */
1146  for ( i = 0; i < expr->degree; i++ ) {
1147  res = typeExpression3( expr->subtrees[i], dynamictyping, funcDesc, varTypes, typingConstraints, errmsg, errnode, r );
1148  if ( getNodeType( res ) == T_ERROR ) {
1149  return expr->exprType = res;
1150  }
1151  }
1152  return expr->exprType = newSimpType( T_DYNAMIC, r );
1153  case TK_COL:
1154  /* todo type */
1155  return expr->exprType = newSimpType( T_DYNAMIC, r );
1156 
1157  case N_EXTERN_DEF:
1158  return expr->exprType = typeTypeAscription( expr, dynamictyping, funcDesc, varTypes, typingConstraints, errmsg, errnode, r );
1159  default:
1160  break;
1161  }
1162  *errnode = expr;
1163  char errbuf[ERR_MSG_LEN], errbuf0[ERR_MSG_LEN];
1164  snprintf( errbuf0, ERR_MSG_LEN, "error: unsupported ast node %d", getNodeType( expr ) );
1165  generateErrMsg( errbuf0, NODE_EXPR_POS( expr ), expr->base, errbuf );
1166  addRErrorMsg( errmsg, RE_TYPE_ERROR, errbuf );
1167  return expr->exprType = newSimpType( T_ERROR, r );
1168 
1169 }
1170 /*
1171  * This process is based on a few assumptions:
1172  * If the type coerced to cannot be inferred, i.e., an expression is to be coerced to some tvar, bounded to a union type or free,
1173  * then we leave further type checking to runtime, which can be done locally under the assumption of indistinguishable inclusion.
1174  *
1175  */
1176 void postProcessCoercion( Node *expr, Hashtable *varTypes, rError_t *errmsg, Node **errnode, Region *r ) {
1177  expr->coercionType = expr->coercionType == NULL ? NULL : instantiate( expr->coercionType, varTypes, 0, r );
1178  expr->exprType = expr->exprType == NULL ? NULL : instantiate( expr->exprType, varTypes, 0, r );
1179  int i;
1180  for ( i = 0; i < expr->degree; i++ ) {
1181  postProcessCoercion( expr->subtrees[i], varTypes, errmsg, errnode, r );
1182  }
1183  if ( expr->coercionType != NULL && expr->exprType != NULL ) {
1184  /*char buf[128];*/
1185  /*typeToString(expr->coercionType, NULL, buf, 128);
1186  printf("%s", buf);*/
1187  if ( getNodeType( expr ) == N_TUPLE ) {
1188  ExprType **csubtrees = expr->coercionType->subtrees;
1189  int i;
1190  for ( i = 0; i < expr->degree; i++ ) {
1191  if ( typeEqSyntatic( expr->subtrees[i]->exprType, csubtrees[i] ) ) {
1192  expr->subtrees[i]->option &= ~OPTION_COERCE;
1193  }
1194  else {
1195  expr->subtrees[i]->option |= OPTION_COERCE;
1196  }
1197  }
1198  }
1199  }
1200 }
1201 /*
1202  * convert single action to actions if the parameter is of type actions
1203  */
1204 void postProcessActions( Node *expr, Env *systemFunctionTables, rError_t *errmsg, Node **errnode, Region *r ) {
1205  int i;
1206  switch ( getNodeType( expr ) ) {
1207  case N_TUPLE:
1208  for ( i = 0; i < expr->degree; i++ ) {
1209  if ( getIOType( expr->subtrees[i] ) == IO_TYPE_ACTIONS && getNodeType( expr->subtrees[i] ) != N_ACTIONS ) {
1210  setIOType( expr->subtrees[i], IO_TYPE_INPUT );
1211  Node **params = ( Node ** )region_alloc( r, sizeof( Node * ) * 1 );
1212  params[0] = expr->subtrees[i];
1213  Label pos;
1214  pos.base = expr->base;
1215  pos.exprloc = NODE_EXPR_POS( expr );
1216  expr->subtrees[i] = createActionsNode( params, 1, &pos, r );
1217  setIOType( expr->subtrees[i], IO_TYPE_ACTIONS );
1218  expr->subtrees[i]->exprType = params[0]->exprType;
1219  }
1220  }
1221  break;
1222  default:
1223  break;
1224  }
1225  for ( i = 0; i < expr->degree; i++ ) {
1226  postProcessActions( expr->subtrees[i], systemFunctionTables, errmsg, errnode, r );
1227  }
1228 }
createSimpleConstraint
Satisfiability createSimpleConstraint(ExprType *a, ExprType *b, int flex, Node *node, Hashtable *typingEnv, Hashtable *equivalence, List *simpleTypingConstraints, Region *r)
Definition: typing.cpp:336
dupType
ExprType * dupType(ExprType *ty, Region *r)
Definition: utils.cpp:9
occursInEquiv
int occursInEquiv(ExprType *var, ExprType *type, Hashtable *equivalence)
Definition: typing.cpp:158
NULL
#define NULL
Definition: rodsDef.h:70
baseRuleApplies
int baseRuleApplies(ExprType *ta, ExprType *tb, int flex, ExprType **templa, ExprType **templb, Region *r)
Definition: typing.cpp:464
T_CONS_ARITY
#define T_CONS_ARITY(x)
Definition: restructs.hpp:28
getBaseTypeOrTVarId
char * getBaseTypeOrTVarId(ExprType *a, char buf[128])
Definition: typing.cpp:97
TK_BOOL
@ TK_BOOL
Definition: restructs.hpp:116
lookupFromEnv
const void * lookupFromEnv(Env *env, const char *key)
Definition: utils.cpp:813
newTypingConstraint
TypingConstraint * newTypingConstraint(ExprType *a, ExprType *b, NodeType type, Node *node, Region *r)
Definition: restructs.cpp:307
N_BASE_TYPES
#define N_BASE_TYPES
Definition: typing.cpp:9
newIRODSType
ExprType * newIRODSType(const char *name, Region *r)
Definition: restructs.cpp:99
FUNC
#define FUNC
Definition: reconstants.hpp:20
getElemType
ExprType * getElemType(ExprType *type, Region *r)
Definition: typing.cpp:684
DataObjInp_MS_T
#define DataObjInp_MS_T
Definition: msParam.h:30
GenQueryInp_MS_T
#define GenQueryInp_MS_T
Definition: msParam.h:46
N_ATTR
@ N_ATTR
Definition: restructs.hpp:130
IO_TYPE_EXPRESSION
#define IO_TYPE_EXPRESSION
Definition: restructs.hpp:84
listNode
Definition: irods_list.h:8
Satisfiability
enum satisfiability Satisfiability
simplify
Satisfiability simplify(List *typingConstraints, Hashtable *typingEnv, rError_t *errmsg, Node **errnode, Region *r)
Definition: typing.cpp:625
region_alloc
void * region_alloc(Region *r, size_t s)
Definition: region.cpp:138
T_UNSPECED
@ T_UNSPECED
Definition: restructs.hpp:156
TC_NODE
#define TC_NODE(tc)
Definition: restructs.hpp:40
getNodeType
#define getNodeType(x)
Definition: restructs.hpp:69
getFullyBoundedVar
ExprType * getFullyBoundedVar(Region *r)
Definition: typing.cpp:249
env
Definition: restructs.hpp:226
splitConsOrTuple
Satisfiability splitConsOrTuple(ExprType *a, ExprType *b, int flex, Node *node, Hashtable *typingEnv, Hashtable *equivalence, List *simpleTypingConstraints, Region *r)
Definition: typing.cpp:419
T_VAR_DISJUNCTS
#define T_VAR_DISJUNCTS(x)
Definition: restructs.hpp:36
IO_TYPE_ACTIONS
#define IO_TYPE_ACTIONS
Definition: restructs.hpp:85
N_TUPLE_CONSTRUCT_TUPLE
#define N_TUPLE_CONSTRUCT_TUPLE(x)
Definition: restructs.hpp:52
typeToString
char * typeToString(ExprType *type, Hashtable *var_types, char *buf, int bufsize)
Definition: utils.cpp:522
rcMisc.h
TC_LT
@ TC_LT
Definition: restructs.hpp:174
tautologyLtBase
int tautologyLtBase(ExprType *a, ExprType *b)
Definition: typing.cpp:106
T_DOUBLE
@ T_DOUBLE
Definition: restructs.hpp:159
T_PATH
@ T_PATH
Definition: restructs.hpp:168
newUnaryType
ExprType * newUnaryType(NodeType nodeType, ExprType *typeArg, Region *r)
Definition: restructs.cpp:119
N_APPLICATION
@ N_APPLICATION
Definition: restructs.hpp:128
setNodeType
#define setNodeType(x, t)
Definition: restructs.hpp:70
node
Definition: restructs.hpp:244
simplifyLocally
Satisfiability simplifyLocally(ExprType *tca, ExprType *tcb, int flex, Node *node, Hashtable *typingEnv, Hashtable *equivalence, List *simpleTypingConstraints, Region *r)
Definition: typing.cpp:478
newTVarId
int newTVarId()
Definition: utils.cpp:312
occursIn
int occursIn(ExprType *var, ExprType *type)
Definition: typing.cpp:126
TYPE
#define TYPE(x)
Definition: restructs.hpp:23
T_VAR_DISJUNCT
#define T_VAR_DISJUNCT(x, n)
Definition: restructs.hpp:35
OPTION_VARARG_OPTIONAL
#define OPTION_VARARG_OPTIONAL
Definition: restructs.hpp:75
generate_iadmin_commands_for_41_to_42_upgrade.name
name
Definition: generate_iadmin_commands_for_41_to_42_upgrade.py:23
label::exprloc
long exprloc
Definition: restructs.hpp:289
TK_INT
@ TK_INT
Definition: restructs.hpp:112
createType
ExprType * createType(ExprType *t, Node **nc, int nn, Hashtable *typingEnv, Hashtable *equivalence, Region *r)
Definition: typing.cpp:361
OPTION_COERCE
#define OPTION_COERCE
Definition: restructs.hpp:77
T_CONS
@ T_CONS
Definition: restructs.hpp:167
TC_B
#define TC_B(tc)
Definition: restructs.hpp:39
newTVar
ExprType * newTVar(Region *r)
Definition: restructs.cpp:62
StrArray_MS_T
#define StrArray_MS_T
Definition: msParam.h:44
baseTypes
NodeType baseTypes[7]
Definition: typing.cpp:10
list::tail
ListNode * tail
Definition: irods_list.h:16
newCollType
ExprType * newCollType(ExprType *elemType, Region *r)
Definition: restructs.cpp:110
IO_TYPE_DYNAMIC
#define IO_TYPE_DYNAMIC
Definition: restructs.hpp:83
node::text
char * text
Definition: restructs.hpp:252
functions.hpp
GenQueryOut_MS_T
#define GenQueryOut_MS_T
Definition: msParam.h:47
typeExpression3
ExprType * typeExpression3(Node *expr, int dynamictyping, Env *funcDesc, Hashtable *varTypes, List *typingConstraints, rError_t *errmsg, Node **errnode, Region *r)
Definition: typing.cpp:1035
TK_VAR
@ TK_VAR
Definition: restructs.hpp:119
isBaseType
int isBaseType(ExprType *t)
Definition: typing.cpp:448
isIterable
ExprType * isIterable(ExprType *type, Hashtable *var_type_table, Region *r)
Definition: typing.cpp:762
IO_TYPE_INPUT
#define IO_TYPE_INPUT
Definition: restructs.hpp:81
newHashTable2
Hashtable * newHashTable2(int size, Region *r)
Definition: hashtable.cpp:72
rError_t
Definition: rodsError.h:24
T_IRODS
@ T_IRODS
Definition: restructs.hpp:172
replaceDynamicWithNewTVar
ExprType * replaceDynamicWithNewTVar(ExprType *type, Region *r)
Definition: typing.cpp:974
N_ACTIONS
@ N_ACTIONS
Definition: restructs.hpp:134
TK_TEXT
@ TK_TEXT
Definition: restructs.hpp:114
MAX_NUM_DISJUNCTS
#define MAX_NUM_DISJUNCTS
Definition: reconstants.hpp:10
N_EXTERN_DEF
@ N_EXTERN_DEF
Definition: restructs.hpp:152
node::subtrees
struct node ** subtrees
Definition: restructs.hpp:254
logicalAnd
#define logicalAnd(a, b, c)
Definition: typing.cpp:407
N_ACTIONS_RECOVERY
@ N_ACTIONS_RECOVERY
Definition: restructs.hpp:135
N_QUERY
@ N_QUERY
Definition: restructs.hpp:133
RE_TYPE_ERROR
@ RE_TYPE_ERROR
Definition: rodsErrorTable.h:720
narrow
Satisfiability narrow(ExprType *type, ExprType *expected, int flex, Node *node, Hashtable *typingEnv, Hashtable *equivalence, List *simpleTypingConstraints, Region *r)
Definition: typing.cpp:379
applyBaseTypeRule
int applyBaseTypeRule(ExprType *tca, ExprType *tcb, int flex)
Definition: typing.cpp:458
typeEqSyntatic
int typeEqSyntatic(ExprType *a, ExprType *b)
Definition: utils.cpp:18
N_QUERY_COND
@ N_QUERY_COND
Definition: restructs.hpp:131
T_DATETIME
@ T_DATETIME
Definition: restructs.hpp:162
node::degree
int degree
Definition: restructs.hpp:246
listAppend
void listAppend(List *list, void *value, Region *r)
Definition: list.cpp:45
listNode::value
void * value
Definition: irods_list.h:10
postProcessCoercion
void postProcessCoercion(Node *expr, Hashtable *varTypes, rError_t *errmsg, Node **errnode, Region *r)
Definition: typing.cpp:1176
TC_A
#define TC_A(tc)
Definition: restructs.hpp:38
N_QUERY_COND_JUNCTION
@ N_QUERY_COND_JUNCTION
Definition: restructs.hpp:132
getEquivalenceClassRep
ExprType * getEquivalenceClassRep(ExprType *varOrBase, Hashtable *equivalence)
Definition: typing.cpp:140
TK_COL
@ TK_COL
Definition: restructs.hpp:124
T_STRING
@ T_STRING
Definition: restructs.hpp:161
NODE_EXPR_POS
#define NODE_EXPR_POS(x)
Definition: restructs.hpp:68
splitVarL
Satisfiability splitVarL(ExprType *var, ExprType *consTuple, int flex, Node *node, Hashtable *typingEnv, Hashtable *equivalence, List *simpleTypingConstraints, Region *r)
Definition: typing.cpp:196
isPattern
int isPattern(Node *pattern)
Definition: utils.cpp:859
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
listRemove
void listRemove(List *list, ListNode *node)
Definition: list.cpp:68
label::base
char * base
Definition: restructs.hpp:290
addRErrorMsg
int addRErrorMsg(rError_t *myError, int status, const char *msg)
Definition: rcMisc.cpp:121
allocSubtrees
Node ** allocSubtrees(Region *r, int size)
Definition: restructs.cpp:34
newFuncType
ExprType * newFuncType(ExprType *paramType, ExprType *retType, Region *r)
Definition: restructs.cpp:79
collType
ReIterableType collType(Res *coll)
Definition: functions.cpp:323
OPTION_VARARG_PLUS
#define OPTION_VARARG_PLUS
Definition: restructs.hpp:74
postProcessActions
void postProcessActions(Node *expr, Env *systemFunctionTables, rError_t *errmsg, Node **errnode, Region *r)
Definition: typing.cpp:1204
TK_DOUBLE
@ TK_DOUBLE
Definition: restructs.hpp:113
unifyWith
ExprType * unifyWith(ExprType *type, ExprType *expected, Hashtable *varTypes, Region *r)
Definition: utils.cpp:169
hashtable::len
int len
Definition: irods_hashtable.h:19
OPTION_VARARG_STAR
#define OPTION_VARARG_STAR
Definition: restructs.hpp:73
node::coercionType
ExprType * coercionType
Definition: restructs.hpp:251
tautologyLt
int tautologyLt(ExprType *type, ExprType *expected)
Definition: typing.cpp:39
lookupFromHashTable
const void * lookupFromHashTable(Hashtable *h, const char *key)
Definition: hashtable.cpp:222
node::base
char * base
Definition: restructs.hpp:255
T_FIXD
@ T_FIXD
Definition: restructs.hpp:165
OPTION_VARARG_ONCE
#define OPTION_VARARG_ONCE
Definition: restructs.hpp:72
dereference
ExprType * dereference(ExprType *type, Hashtable *tt, Region *r)
Definition: utils.cpp:626
doNarrow
void doNarrow(Node **l, Node **r, int ln, int rn, int flex, Node **nl, Node **nr, int *nln, int *nrn)
Definition: typing.cpp:298
region
Definition: region.h:45
T_BOOL
@ T_BOOL
Definition: restructs.hpp:163
CollInp_MS_T
#define CollInp_MS_T
Definition: msParam.h:39
simplifyL
Satisfiability simplifyL(ExprType *a, ExprType *b, int flex, Node *node, Hashtable *typingEnv, Hashtable *equivalence, List *simpleTypingConstraints, Region *r)
Definition: typing.cpp:259
typing.hpp
typeFuncParam
int typeFuncParam(Node *param, Node *paramType, Node *formalParamType, Hashtable *var_type_table, List *typingConstraints, rError_t *errmsg, Region *r)
Definition: typing.cpp:987
createActionsNode
Node * createActionsNode(Node **params, int paramsLen, Label *exprloc, Region *r)
Definition: restructs.cpp:443
list::head
ListNode * head
Definition: irods_list.h:15
get_db_schema_version.l
l
Definition: get_db_schema_version.py:19
listNode::next
ListNode * next
Definition: irods_list.h:9
typeParameters
int typeParameters(ExprType **paramTypes, int len, Node **subtrees, int dynamictyping, Env *funcDesc, Hashtable *symbol_type_table, List *typingConstraints, rError_t *errmsg, Node **errnode, Region *r)
Definition: typing.cpp:28
newList
List * newList(Region *r)
Definition: list.cpp:6
node::exprType
ExprType * exprType
Definition: restructs.hpp:250
solveConstraints
Satisfiability solveConstraints(List *typingConstraints, Hashtable *typingEnv, rError_t *errmsg, Node **errnode, Region *r)
Definition: typing.cpp:550
N_TUPLE
@ N_TUPLE
Definition: restructs.hpp:127
NodeType
enum node_type NodeType
updateInHashTable
const void * updateInHashTable(Hashtable *h, const char *key, const void *value)
Definition: hashtable.cpp:164
KeyValPair_MS_T
#define KeyValPair_MS_T
Definition: msParam.h:37
addToEquivalenceClass
void addToEquivalenceClass(ExprType *a, ExprType *b, Hashtable *equivalence)
Definition: typing.cpp:285
newTVar2
ExprType * newTVar2(int numDisjuncts, Node **disjuncts, Region *r)
Definition: restructs.cpp:51
unifyTVarL
ExprType * unifyTVarL(ExprType *type, ExprType *expected, Hashtable *varTypes, Region *r)
Definition: utils.cpp:115
irods.six.b
def b(s)
Definition: six.py:606
T_VAR
@ T_VAR
Definition: restructs.hpp:171
error
int error
Definition: filesystem.cpp:101
T_VAR_NUM_DISJUNCTS
#define T_VAR_NUM_DISJUNCTS(x)
Definition: restructs.hpp:37
T_INT
@ T_INT
Definition: restructs.hpp:160
T_TUPLE
@ T_TUPLE
Definition: restructs.hpp:166
TAUTOLOGY
@ TAUTOLOGY
Definition: typing.hpp:13
generateErrMsg
char * generateErrMsg(char *msg, long errloc, char *ruleBaseName, char errbuf[1024])
Definition: parser.cpp:3555
ABSURDITY
@ ABSURDITY
Definition: typing.hpp:13
newTupleType
ExprType * newTupleType(int arity, ExprType **typeArgs, Region *r)
Definition: restructs.cpp:116
TK_STRING
@ TK_STRING
Definition: restructs.hpp:115
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
splitVarR
Satisfiability splitVarR(ExprType *consTuple, ExprType *var, int flex, Node *node, Hashtable *typingEnv, Hashtable *equivalence, List *simpleTypingConstraints, Region *r)
Definition: typing.cpp:175
hashtable
Definition: irods_hashtable.h:16
typeFunction3
ExprType * typeFunction3(Node *node, int dynamictyping, Env *funcDesc, Hashtable *var_type_table, List *typingConstraints, rError_t *errmsg, Node **errnode, Region *r)
Definition: typing.cpp:833
instantiate
ExprType * instantiate(ExprType *type, Hashtable *type_table, int replaceFreeVars, Region *r)
Definition: utils.cpp:642
consistent
int consistent(List *, Hashtable *, Region *)
Definition: typing.cpp:622
label
Definition: restructs.hpp:288
typeName_ExprType
char * typeName_ExprType(ExprType *s)
Definition: parser.cpp:3419
isIterableBaseRuleType
int isIterableBaseRuleType(ExprType *type, ExprType **templa, ExprType **templb, Region *r)
Definition: typing.cpp:709
CONTINGENCY
@ CONTINGENCY
Definition: typing.hpp:13
setVararg
#define setVararg(n, v)
Definition: restructs.hpp:88
T_ERROR
@ T_ERROR
Definition: restructs.hpp:157
getVararg
#define getVararg(n)
Definition: restructs.hpp:87
setIOType
#define setIOType(n, v)
Definition: restructs.hpp:90
T_CONS_TYPE_ARG
#define T_CONS_TYPE_ARG(x, n)
Definition: restructs.hpp:26
simplifyR
Satisfiability simplifyR(ExprType *a, ExprType *b, int flex, Node *node, Hashtable *typingEnv, Hashtable *equivalence, List *simpleTypingConstraints, Region *r)
Definition: typing.cpp:224
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
OPTION_TYPED
#define OPTION_TYPED
Definition: restructs.hpp:78
RE_ERROR2
#define RE_ERROR2(x, y)
Definition: typing.cpp:8
list
Definition: irods_list.h:13
getIOType
#define getIOType(n)
Definition: restructs.hpp:89
T_FLEX
@ T_FLEX
Definition: restructs.hpp:164
typeTypeAscription
ExprType * typeTypeAscription(Node *expr, int dynamictyping, Env *funcDesc, Hashtable *varTypes, List *typingConstraints, rError_t *errmsg, Node **errnode, Region *r)
Definition: typing.cpp:1012
ERR_MSG_LEN
#define ERR_MSG_LEN
Definition: rodsError.h:16
IntArray_MS_T
#define IntArray_MS_T
Definition: msParam.h:45
T_CONS_TYPE_NAME
#define T_CONS_TYPE_NAME(x)
Definition: restructs.hpp:27
LIST
#define LIST
Definition: reconstants.hpp:14
getTVarName
char * getTVarName(int vid, char name[128])
Definition: utils.cpp:298