@@ -1865,6 +1865,14 @@ algorithm
18651865 then
18661866 (exp, ty, ty, NONE (), fn);
18671867
1868+ case (Absyn . IDENT ("min" ), DAE . T_ENUMERATION ())
1869+ algorithm
1870+ v := Values . ENUM_LITERAL (Absyn . suffixPath(unboxedType. path,
1871+ List . last(unboxedType. names)), listLength(unboxedType. names));
1872+ (exp, ty) := Types . matchType(inExp, inType, DAE . T_ENUMERATION_DEFAULT , true );
1873+ then
1874+ (exp, ty, ty, SOME (v), fn);
1875+
18681876 case (Absyn . IDENT ("max" ), DAE . T_REAL ())
18691877 algorithm
18701878 r := realNeg(System . realMaxLit());
@@ -1895,6 +1903,13 @@ algorithm
18951903 then
18961904 (exp, ty, ty, SOME (v), fn);
18971905
1906+ case (Absyn . IDENT ("max" ), DAE . T_ENUMERATION ())
1907+ algorithm
1908+ v := Values . ENUM_LITERAL (Absyn . suffixPath(unboxedType. path, listHead(unboxedType. names)), 1 );
1909+ (exp, ty) := Types . matchType(inExp, inType, DAE . T_ENUMERATION_DEFAULT , true );
1910+ then
1911+ (exp, ty, ty, SOME (v), fn);
1912+
18981913 case (Absyn . IDENT ("sum" ), DAE . T_REAL ())
18991914 algorithm
19001915 v := Values . REAL (0 . 0 );
@@ -4508,62 +4523,54 @@ end elabBuiltinMin;
45084523protected function elabBuiltinMinMaxCommon
45094524 "Helper function to elabBuiltinMin and elabBuiltinMax, containing common
45104525 functionality."
4511- input FCore . Cache inCache ;
4512- input FCore . Graph inEnv ;
4526+ input output FCore . Cache cache ;
4527+ input FCore . Graph env ;
45134528 input String inFnName;
45144529 input list< Absyn . Exp > inFnArgs;
4515- input Boolean inImpl ;
4516- input Prefix . Prefix inPrefix ;
4530+ input Boolean impl ;
4531+ input Prefix . Prefix prefix ;
45174532 input SourceInfo info;
4518- output FCore . Cache outCache;
4519- output DAE . Exp outExp;
4520- output DAE . Properties outProperties;
4533+ output DAE . Exp outExp;
4534+ output DAE . Properties outProperties;
45214535algorithm
4522- (outCache, outExp, outProperties):=
4523- match (inCache, inEnv, inFnName, inFnArgs, inImpl, inPrefix, info)
4536+ (outExp, outProperties) := match inFnArgs
45244537 local
45254538 DAE . Exp arrexp_1,s1_1,s2_1, call;
45264539 DAE . Type tp;
45274540 DAE . Type ty,ty1,ty2,elt_ty;
45284541 DAE . Const c,c1,c2;
4529- FCore . Graph env;
45304542 Absyn . Exp arrexp,s1,s2;
4531- Boolean impl;
4532- FCore . Cache cache;
4533- Prefix . Prefix pre;
45344543 DAE . Properties p;
45354544
45364545 // min|max(vector)
4537- case (cache, env, _, {arrexp}, impl, pre, _)
4546+ case {arrexp}
45384547 equation
45394548 (cache, arrexp_1, DAE . PROP (ty, c), _) =
4540- elabExpInExpression(cache, env, arrexp, impl,NONE (), true , pre , info);
4549+ elabExpInExpression(cache, env, arrexp, impl,NONE (), true , prefix , info);
45414550 true = Types . isArray(ty);
45424551 arrexp_1 = Expression . matrixToArray(arrexp_1);
45434552 elt_ty = Types . arrayElementType(ty);
45444553 tp = Types . simplifyType(elt_ty);
45454554 false = Types . isString(tp);
45464555 call = Expression . makePureBuiltinCall(inFnName, {arrexp_1}, tp);
45474556 then
4548- (cache, call, DAE . PROP (elt_ty,c));
4557+ (call, DAE . PROP (elt_ty,c));
45494558
45504559 // min|max(x,y) where x & y are scalars.
4551- case (cache, env, _, {s1, s2}, impl, pre, _)
4560+ case {s1, s2}
45524561 equation
45534562 (cache, s1_1, DAE . PROP (ty1, c1), _) =
4554- elabExpInExpression(cache, env, s1, impl,NONE (), true , pre , info);
4563+ elabExpInExpression(cache, env, s1, impl, NONE (), true , prefix , info);
45554564 (cache, s2_1, DAE . PROP (ty2, c2), _) =
4556- elabExpInExpression(cache, env, s2, impl,NONE (), true , pre , info);
4565+ elabExpInExpression(cache, env, s2, impl, NONE (), true , prefix , info);
45574566
4558- ty = Types . scalarSuperType(ty1,ty2);
4559- (s1_1,_) = Types . matchType(s1_1, ty1, ty, true );
4560- (s2_1,_) = Types . matchType(s2_1, ty2, ty, true );
4567+ (s1_1, s2_1, ty, true ) = Types . checkTypeCompat(s1_1, ty1, s2_1, ty2);
45614568 c = Types . constAnd(c1, c2);
45624569 tp = Types . simplifyType(ty);
45634570 false = Types . isString(tp);
45644571 call = Expression . makePureBuiltinCall(inFnName, {s1_1, s2_1}, tp);
45654572 then
4566- (cache, call, DAE . PROP (ty,c));
4573+ (call, DAE . PROP (ty,c));
45674574
45684575 end match;
45694576end elabBuiltinMinMaxCommon;
0 commit comments