Exemplo n.º 1
0
  public void genLLVM(Env env, Emitter emitter, Function function) {
    children[0].genLLVM(env, emitter, function);
    Instruction ptr = children[0].getPointer(env, emitter, function);

    if ((overload == null) && ptrAdd) {
      instruction = new GETELEMENTPTR().value(children[0].getInstruction()).addIndex(1);
      function.add(instruction);
      function.add(
          new STORE()
              .pointer(ptr)
              .value(instruction)
              ._volatile(children[0].getType().isVolatile()));
    } else if ((overload == null) && !ptrAdd) {
      instruction =
          new BINARY()
              .op("add")
              .type(LLVMType.getLLVMName(type))
              .lhs(children[0].getInstruction())
              .rhs("1");
      function.add(instruction);
      function.add(
          new STORE()
              .pointer(ptr)
              .value(instruction)
              ._volatile(children[0].getType().isVolatile()));
    } else {
      overload.genLLVM(env, emitter, function);
      instruction = overload.getInstruction();
    }
  }