Skip to content

Refactor OperatorMsg.chpl and BinOp.chpl #5409

@1RyanK

Description

@1RyanK

It might be good to refactor the procs so that rather than conditioning on types inside e.g. doBinOpvv, there's a where in the function signature that brings calls directly to the correct proc implementing that case. Furthermore, there's a lot of overlap between the actual operator handing; could there just be a few procs that do something like

      select op {
        when Mul { e = (l.a: etype * r.a: etype): etype; }
        when Add { e = (l.a: etype + r.a: etype): etype; }
        when Sub { e = (l.a: etype - r.a: etype): etype; }
        when Div { e = (l.a: etype / r.a: etype): etype; }
        when Mod {
          ref ea = e;
          ref la = l.a;
          ref ra = r.a;
          [(ei,li,ri) in zip(ea,la,ra)] ei = modHelper(li: etype, ri: etype): etype;
        }
        when FloorDiv {
          ref ea = e;
          ref la = l.a;
          ref ra = r.a;
          ea = floorDivision(la, ra, etype);
        }
        when Pow {
          e = ((l.a: etype) ** (r.a: etype)): etype;
        }
        otherwise do return MsgTuple.error(nie);
      }

and handle this for multiple functions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions