Changeset 22487


Ignore:
Timestamp:
2014-09-29T23:53:59+02:00 (10 years ago)
Author:
adrpo
Message:

Fix bug #2851

  • handle named arguments for homotopy
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Compiler/FrontEnd/Static.mo

    r22436 r22487  
    718718
    719719    // homotopy replacement (usually used for debugging only)
    720     case (cache,env,Absyn.CALL(function_ = Absyn.CREF_IDENT("homotopy", _),functionArgs = Absyn.FUNCTIONARGS(args = args,argNames = _)),impl,st,doVect,pre,_,_)
     720    case (cache,env,Absyn.CALL(function_ = Absyn.CREF_IDENT("homotopy", _),functionArgs = Absyn.FUNCTIONARGS(args = args,argNames = nargs)),impl,st,doVect,pre,_,_)
    721721      equation
    722722        replaceWith = Flags.getConfigString(Flags.REPLACE_HOMOTOPY);
     
    725725        true = boolOr(stringEq(replaceWith, "actual"), stringEq(replaceWith, "simplified"));
    726726        // TODO, handle empy args and nargs for homotopy!
    727         {e1, e2} = args;
     727        {e1, e2} = getHomotopyArguments(args, nargs);
    728728        e = Util.if_(stringEq(replaceWith, "actual"), e1, e2);
    729729        (cache,e_1,prop,st_1) = elabExpInExpression(cache, env, e, impl, st, doVect, pre, info);
     
    899899  end matchcontinue;
    900900end elabExp2;
     901
     902public function getHomotopyArguments
     903  input list<Absyn.Exp> args;
     904  input list<Absyn.NamedArg> nargs;
     905  output list<Absyn.Exp> outPositionalArgs;
     906algorithm
     907  outPositionalArgs := matchcontinue(args, nargs)
     908    local
     909      Absyn.Exp e1, e2;
     910
     911    // only positional
     912    case ({e1, e2}, _) then {e1, e2};
     913    // only named
     914    case ({}, {Absyn.NAMEDARG("actual", e1), Absyn.NAMEDARG("simplified", e2)}) then {e1, e2};
     915    case ({}, {Absyn.NAMEDARG("simplified", e2), Absyn.NAMEDARG("actual", e1)}) then {e1, e2};
     916    // combination
     917    case ({e1}, {Absyn.NAMEDARG("simplified", e2)}) then {e1, e2};
     918    case (_, _)
     919      equation
     920        Error.addCompilerError("+replaceHomotopy: homotopy called with wrong arguments: " +&
     921          Dump.printFunctionArgsStr(Absyn.FUNCTIONARGS(args, nargs)));
     922      then
     923        fail();
     924  end matchcontinue;
     925end getHomotopyArguments;
    901926
    902927protected function elabIfExp
Note: See TracChangeset for help on using the changeset viewer.