7 #define RE_ERROR(x); if(x) {goto error;}
8 #define RE_ERROR2(x,y); if(x) {localErrorMsg=(y);goto error;}
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 );
132 for ( i = 0; i <
type->degree; i++ ) {
145 while ( equiv2 !=
NULL ) {
166 for ( i = 0; i <
type->degree; i++ ) {
240 bn =
createType(
b, cr, nrn, typingEnv, equivalence, r );
275 an =
createType( a, cl, nln, typingEnv, equivalence, r );
301 for ( i = 0; i < ln; i++ ) {
304 for ( k = 0; k < rn; k++ ) {
307 for ( k = 0; k < rn; k++ ) {
308 for ( i = 0; i < ln; i++ ) {
323 for ( i = 0; i < ln; i++ ) {
324 if ( retl[i] !=
NULL ) {
325 nl[( *nln )++] = retl[i];
329 for ( k = 0; k < rn; k++ ) {
330 if ( retr[k] !=
NULL ) {
331 nr[( *nrn )++] = retr[k];
386 Node *cl[100], *cr[100];
390 if ( nln == 0 || nrn == 0 ) {
395 bn =
createType( expected, cr, nrn, typingEnv, equivalence, r );
407 #define logicalAnd(a, b, c) \
413 (c) = (b) == ABSURDITY ? ABSURDITY : CONTINGENCY; \
515 simplifyLocally( templb, tcb, flex,
node, typingEnv, equivalence, simpleTypingConstraints, r ), c );
519 return narrow( tca, tcb, flex,
node, typingEnv, equivalence, simpleTypingConstraints, r );
523 return simplifyL( tca, tcb, flex,
node, typingEnv, equivalence, simpleTypingConstraints, r );
527 return simplifyR( tca, tcb, flex,
node, typingEnv, equivalence, simpleTypingConstraints, r );
531 return splitVarL( tca, tcb, flex,
node, typingEnv, equivalence, simpleTypingConstraints, r );
535 return splitVarR( tca, tcb, flex,
node, typingEnv, equivalence, simpleTypingConstraints, r );
540 return splitConsOrTuple( tca, tcb, flex,
node, typingEnv, equivalence, simpleTypingConstraints, r );
563 nextNode = typingConstraints->
head;
564 while ( nextNode !=
NULL && !changed ) {
581 nextNode = typingConstraints->
head;
607 printf(
"error: simplified type does not have variable on either side.\n" );
610 nextNode = nextNode->
next;
615 while ( nextNode !=
NULL );
616 if ( !
consistent( typingConstraints, typingEnv, r ) ) {
635 changed = typingEnv->
len;
636 ln = typingConstraints->
head;
639 while ( ln !=
NULL ) {
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 ) );
673 typingConstraints->
head = simpleTypingConstraints->
head;
674 typingConstraints->
tail = simpleTypingConstraints->
tail;
675 simpleTypingConstraints->
head = simpleTypingConstraints->
tail =
NULL;
677 while ( changed < typingEnv->len );
711 char *typeName =
type->text;
712 switch ( nodeType ) {
765 Res *unified, *comp0, *comp1;
768 if ( strcmp(
type->text,
LIST ) == 0 ) {
779 derefedType =
dereference( derefedType, var_type_table, r );
795 Node *disjunctsElem[4];
857 if ( varType ==
NULL ) {
859 RE_ERROR2( 1,
"foreach is applied to a non collection type" );
866 if ( varType0 ==
NULL ) {
873 res3 =
typeExpression3( arg->
subtrees[1], dynamictyping, funcDesc, var_type_table, typingConstraints, errmsg, errnode, r );
875 res3 =
typeExpression3( arg->
subtrees[2], dynamictyping, funcDesc, var_type_table, typingConstraints, errmsg, errnode, r );
878 for ( i = 1; i < 3; i++ ) {
891 ExprType *fnType =
typeExpression3( fn, dynamictyping, funcDesc, var_type_table, typingConstraints, errmsg, errnode, r );
896 ExprType *argType =
typeExpression3( arg, dynamictyping, funcDesc, var_type_table, typingConstraints, errmsg, errnode, r );
909 !
isPattern( arg->
subtrees[0] ),
"the first argument of microservice assign is not a variable or a pattern" );
912 !
isPattern( arg->
subtrees[0] ),
"the first argument of microservice let is not a variable or a pattern" );
921 int fixParamN = paramType->
degree - 1;
923 int copyN = argN - fixParamN;
926 snprintf(
buf, 1024,
"unsolvable vararg typing constraint %s < %s %s",
934 for ( i = 0; i < fixParamN; i++ ) {
935 paramTypes[i] = subtrees[i];
937 for ( i = 0; i < copyN; i++ ) {
938 paramTypes[i + fixParamN] = subtrees[fixParamN];
950 RE_ERROR2(
true,
"parameter type error" );
969 snprintf( errmsgbuf,
ERR_MSG_LEN,
"type error: %s in %s", localErrorMsg, fn->
text );
982 for ( i = 0; i <
type->degree; i++ ) {
1019 ExprType *exprType =
typeExpression3( param, dynamictyping, funcDesc, varTypes, typingConstraints, errmsg, errnode, r );
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));
1060 if ( strcmp( expr->
text,
"nop" ) == 0 ) {
1079 for ( i = 0; i < expr->
degree; i++ ) {
1080 components[i] =
typeExpression3( expr->
subtrees[i], dynamictyping, funcDesc, varTypes, typingConstraints, errmsg, errnode, r );
1082 return expr->
exprType = components[i];
1089 return expr->
exprType = components[0];
1095 return expr->
exprType =
typeFunction3( expr, dynamictyping, funcDesc, varTypes, typingConstraints, errmsg, errnode, r );
1097 if ( expr->
degree == 0 ) {
1101 for ( i = 0; i < expr->
degree; i++ ) {
1103 res =
typeExpression3( expr->
subtrees[i], dynamictyping, funcDesc, varTypes, typingConstraints, errmsg, errnode, r );
1111 res =
typeExpression3( expr->
subtrees[0], dynamictyping, funcDesc, varTypes, typingConstraints, errmsg, errnode, r );
1115 res =
typeExpression3( expr->
subtrees[1], dynamictyping, funcDesc, varTypes, typingConstraints, errmsg, errnode, r );
1119 for ( i = 0; i < expr->
degree; i++ ) {
1120 res =
typeExpression3( expr->
subtrees[i], dynamictyping, funcDesc, varTypes, typingConstraints, errmsg, errnode, r );
1128 for ( i = 0; i < expr->
degree; i++ ) {
1129 res =
typeExpression3( expr->
subtrees[i], dynamictyping, funcDesc, varTypes, typingConstraints, errmsg, errnode, r );
1137 for ( i = 0; i < expr->
degree; i++ ) {
1138 res =
typeExpression3( expr->
subtrees[i], dynamictyping, funcDesc, varTypes, typingConstraints, errmsg, errnode, r );
1146 for ( i = 0; i < expr->
degree; i++ ) {
1147 res =
typeExpression3( expr->
subtrees[i], dynamictyping, funcDesc, varTypes, typingConstraints, errmsg, errnode, r );
1158 return expr->
exprType =
typeTypeAscription( expr, dynamictyping, funcDesc, varTypes, typingConstraints, errmsg, errnode, r );
1180 for ( i = 0; i < expr->
degree; i++ ) {
1190 for ( i = 0; i < expr->
degree; i++ ) {
1208 for ( i = 0; i < expr->
degree; i++ ) {
1225 for ( i = 0; i < expr->
degree; i++ ) {