Changeset: c4100c424cde for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c4100c424cde
Modified Files:
.github/workflows/linux.yml
clients/Tests/exports.stable.out
monetdb5/mal/mal_function.c
monetdb5/mal/mal_resolve.c
monetdb5/mal/mal_resolve.h
Branch: default
Log Message:
split resolving types and returning errors
lets upload mtest results
diffs (225 lines):
diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml
--- a/.github/workflows/linux.yml
+++ b/.github/workflows/linux.yml
@@ -56,9 +56,9 @@ jobs:
#cd build
#cmake --build . --target mtest
PATH=$HOME/${{ matrix.branch }}/bin:$PATH $HOME/${{ matrix.branch
}}/bin/Mtest.py -r --debug=0
- #-
- #uses: actions/upload-artifact@v3
- #name: Publish Linux binary wheels
- #with:
- #name: monetdbe-linux-wheel-${{ matrix.branch }}-${{
matrix.python-version }}
- #path: dist/*.whl
+ - name: Results
+ uses: actions/upload-artifact@v3
+ name: Publish mtest results
+ with:
+ name: mtest-${{ matrix.branch }}
+ path: ${{ matrix.branch }}/mTests
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -1190,7 +1190,7 @@ const char *replaceRef;
void resetMalBlk(MalBlkPtr mb);
void resetMalTypes(MalBlkPtr mb, int stop);
int resizeMalBlk(MalBlkPtr mb, int elements);
-int resolveType(int dsttype, int srctype);
+int resolvedType(int dsttype, int srctype);
const char *resultSetRef;
const char *revokeRef;
const char *revoke_functionRef;
diff --git a/monetdb5/mal/mal_function.c b/monetdb5/mal/mal_function.c
--- a/monetdb5/mal/mal_function.c
+++ b/monetdb5/mal/mal_function.c
@@ -198,8 +198,7 @@ chkFlow(MalBlkPtr mb)
getModuleId(sig), getFunctionId(sig));
} else if (ps->typechk == TYPE_RESOLVED)
for (e = 0; e < p->retc; e++) {
- if (resolveType(getArgType(mb, ps, e),
getArgType(mb, p, e))
- < 0) {
+ if (resolvedType(getArgType(mb, ps, e),
getArgType(mb, p, e)) < 0) {
str tpname =
getTypeName(getArgType(mb, p, e));
msg = createException(MAL,
"%s.%s RETURN type mismatch at type '%s'\n",
diff --git a/monetdb5/mal/mal_resolve.c b/monetdb5/mal/mal_resolve.c
--- a/monetdb5/mal/mal_resolve.c
+++ b/monetdb5/mal/mal_resolve.c
@@ -27,6 +27,68 @@ static malType getPolyType(malType t, in
static int updateTypeMap(int formal, int actual, int polytype[MAXTYPEVAR]);
static int typeKind(MalBlkPtr mb, InstrPtr p, int i);
+int
+resolvedType(int dsttype, int srctype)
+{
+ if (dsttype == srctype || dsttype == TYPE_any || srctype == TYPE_any ||
+ (isaBatType(srctype) && dsttype == TYPE_bat) ||
+ (isaBatType(dsttype) && srctype == TYPE_bat))
+ return 0;
+
+ if (isaBatType(dsttype) && isaBatType(srctype)) {
+ int t1 = getBatType(dsttype);
+ int t2 = getBatType(srctype);
+ if (t1 == t2 || t1 == TYPE_any || t2 == TYPE_any)
+ return 0;
+ }
+ return -1;
+}
+
+static int
+resolveType(int *rtype, int dsttype, int srctype)
+{
+ if (dsttype == srctype) {
+ *rtype = dsttype;
+ return 0;
+ }
+ if (dsttype == TYPE_any) {
+ *rtype = srctype;
+ return 0;
+ }
+ if (srctype == TYPE_any) {
+ *rtype = dsttype;
+ return 0;
+ }
+ /*
+ * A bat reference can be coerced to bat type.
+ */
+ if (isaBatType(srctype) && dsttype == TYPE_bat) {
+ *rtype = srctype;
+ return 0;
+ }
+ if (isaBatType(dsttype) && srctype == TYPE_bat) {
+ *rtype = dsttype;
+ return 0;
+ }
+ if (isaBatType(dsttype) && isaBatType(srctype)) {
+ int t1, t2, t3;
+ t1 = getBatType(dsttype);
+ t2 = getBatType(srctype);
+ if (t1 == t2)
+ t3 = t1;
+ else if (t1 == TYPE_any)
+ t3 = t2;
+ else if (t2 == TYPE_any)
+ t3 = t1;
+ else {
+ return -1;
+ }
+ *rtype = newBatType(t3);
+ return 0;
+ }
+ return -1;
+}
+
/*
* Since we now know the storage type of the receiving variable, we can
@@ -174,7 +236,7 @@ findFunctionType(Module scope, MalBlkPtr
* If it fails, we know this isn't the function
we are
* looking for.
*/
- if (resolveType(formal, actual) == -1) {
+ if (resolvedType(formal, actual) < 0) {
unmatched = i;
break;
}
@@ -203,7 +265,7 @@ findFunctionType(Module scope, MalBlkPtr
formal = getPolyType(formal,
polytype);
if (formal == actual || formal
== TYPE_any)
continue;
- if (resolveType(formal, actual)
== -1) {
+ if (resolvedType(formal,
actual) < 0) {
unmatched = i;
break;
}
@@ -224,7 +286,7 @@ findFunctionType(Module scope, MalBlkPtr
for (i = p->retc; i < p->argc; i++) {
int actual = getArgType(mb, p, i);
int formal = getArgType(s->def, sig, i);
- if (resolveType(formal, actual) == -1) {
+ if (resolvedType(formal, actual) < 0) {
unmatched = i;
break;
}
@@ -265,8 +327,7 @@ findFunctionType(Module scope, MalBlkPtr
s1 = getPolyType(formal, polytype);
- returntype[i] = resolveType(s1, actual);
- if (returntype[i] == -1) {
+ if (resolveType(returntype+i, s1, actual) < 0) {
s1 = -1;
break;
}
@@ -282,8 +343,7 @@ findFunctionType(Module scope, MalBlkPtr
if (actual == formal)
returntype[i] = actual;
else {
- returntype[i] = resolveType(formal,
actual);
- if (returntype[i] == -1) {
+ if (resolveType(returntype+i, formal,
actual) < 0) {
s1 = -1;
break;
}
@@ -425,40 +485,6 @@ findFunctionType(Module scope, MalBlkPtr
return -3;
}
-int
-resolveType(int dsttype, int srctype)
-{
- if (dsttype == srctype)
- return dsttype;
- if (dsttype == TYPE_any)
- return srctype;
- if (srctype == TYPE_any)
- return dsttype;
- /*
- * A bat reference can be coerced to bat type.
- */
- if (isaBatType(srctype) && dsttype == TYPE_bat)
- return srctype;
- if (isaBatType(dsttype) && srctype == TYPE_bat)
- return dsttype;
- if (isaBatType(dsttype) && isaBatType(srctype)) {
- int t1, t2, t3;
- t1 = getBatType(dsttype);
- t2 = getBatType(srctype);
- if (t1 == t2)
- t3 = t1;
- else if (t1 == TYPE_any)
- t3 = t2;
- else if (t2 == TYPE_any)
- t3 = t1;
- else {
- return -1;
- }
- return newBatType(t3);
- }
- return -1;
-}
-
/*
* We try to clear the type check flag by looking up the
* functions. Errors are simply ignored at this point of the game,
@@ -599,8 +625,7 @@ typeChecker(Module scope, MalBlkPtr mb,
int lhs = getArgType(mb, p, k);
if (rhs != TYPE_void) {
- s1 = resolveType(lhs, rhs);
- if (s1 == -1) {
+ if (resolveType(&s1, lhs, rhs) < 0) {
typeMismatch(mb, p, idx, lhs, rhs, silent);
return;
}
diff --git a/monetdb5/mal/mal_resolve.h b/monetdb5/mal/mal_resolve.h
--- a/monetdb5/mal/mal_resolve.h
+++ b/monetdb5/mal/mal_resolve.h
@@ -33,6 +33,6 @@ mal_export void typeChecker(Module scope
* i.e. of type 'any'. The type resolution algorithm creates the concrete
* type for subsequent use.
*/
-mal_export int resolveType(int dsttype, int srctype);
+mal_export int resolvedType(int dsttype, int srctype);
#endif /* _MAL_RESOLVE_H */
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]