Пример #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();
    }
  }
Пример #2
0
  public void genLLVM(Env env, Emitter emitter, Function function) {
    children[0].genLLVM(env, emitter, function);
    children[1].genLLVM(env, emitter, function);

    if (modnum != null) {
      coerce.lhsV(children[0].getInstruction());
      coerce.rhsV(children[1].getInstruction());
      coerce.genLLVM(env, emitter, function);
      modnum.lhs(coerce.getInstructionL());
      modnum.rhs(coerce.getInstructionR());
      modnum.genLLVM(env, emitter, function);
      instruction = modnum.getInstruction();

    } else {
      overload.genLLVM(env, emitter, function);
      instruction = overload.getInstruction();
    }
  }