Ejemplo n.º 1
0
  private String methodBodiesString() throws IOException {
    StringBuilder ret = new StringBuilder();
    if (m_usesGarbageCollector) ret.append("#define USING_GARBAGE_COLLECTOR\n");

    /* a set is used so duplicates get filtered out */
    Set<String> bodies = new HashSet<String>();
    Set<OpenCLArrayType> new_types =
        new ArrayCopyTypeReduction().run(m_arrayTypes, m_methodHierarchies);
    bodies.add(new ArrayCopyGenerate().get(new_types));

    /* add all different kinds of bodies i.e. code */
    List<OpenCLMethod> methods = m_methodHierarchies.getMethods();
    for (OpenCLMethod method : methods) bodies.add(method.getMethodBody());
    List<OpenCLPolymorphicMethod> poly_methods = m_methodHierarchies.getPolyMorphicMethods();
    for (OpenCLPolymorphicMethod poly_method : poly_methods)
      bodies.addAll(poly_method.getMethodBodies());
    /* FieldTypeSwitch does something with the offsets ??? */
    FieldTypeSwitch type_switch = new FieldTypeSwitch();
    String field_bodies = m_fieldCodeGeneration.bodies(m_classes, type_switch);
    bodies.add(field_bodies);
    for (OpenCLArrayType array_type : m_arrayTypes) bodies.add(array_type.getBodies());
    for (OpenCLInstanceof type : m_instanceOfs) bodies.add(type.getBody());

    /* join all bodies together to one string (why not do it above? */
    ret.append(type_switch.getFunctions());
    final Iterator<String> iter = bodies.iterator();
    while (iter.hasNext()) ret.append(iter.next());

    return ret.toString();
  }
Ejemplo n.º 2
0
  private String methodPrototypesString() {
    // using a set so duplicates get filtered out.
    Set<String> protos = new HashSet<String>();
    StringBuilder ret = new StringBuilder();

    ArrayCopyGenerate arr_generate = new ArrayCopyGenerate();
    protos.add(arr_generate.getProto());

    List<OpenCLMethod> methods = m_methodHierarchies.getMethods();
    for (OpenCLMethod method : methods) protos.add(method.getMethodPrototype());
    List<OpenCLPolymorphicMethod> poly_methods = m_methodHierarchies.getPolyMorphicMethods();
    for (OpenCLPolymorphicMethod poly_method : poly_methods)
      protos.add(poly_method.getMethodPrototypes());
    protos.add(m_fieldCodeGeneration.prototypes(m_classes));
    for (OpenCLArrayType array_type : m_arrayTypes) protos.add(array_type.getPrototypes());
    for (OpenCLInstanceof type : m_instanceOfs) protos.add(type.getPrototype());
    Iterator<String> iter = protos.iterator();
    while (iter.hasNext()) ret.append(iter.next());
    return ret.toString();
  }