Here you could do something like (I have not checked the names but you should get the idea):

    switch (gstate.getSrcFactor()) {
    case GE_SRC_ONE:    WRITE(p, "  vec4 srcFactor = vec4(1.0);"); break;
    case GE_SRC_DSTCOLOR:    WRITE(p, "  vec4 srcFactor = destColor;"); break;
    case GE_SRC_ONE_MINUS_DSTCOLOR_2X:    WRITE(p, "  vec4 srcFactor = 1.0 - 2.0 * destColor;"); break;
    ....
    }