Пример #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 checkTypes(Env env, Resolver resolver) throws CError {
    children[0].checkTypes(env, resolver);
    children[1].checkTypes(env, resolver);

    try {
      checkTypes_(env, resolver);
    } catch (CError e) {
      modnum = null;
      overload = new Overload(token, method);
      overload.operator("%").children(children);
      if (!overload.find(env, resolver)) throw e;
      overload.checkTypes(env, resolver);
      type = overload.getType();
    }
  }
Пример #3
0
  public void checkTypes(Env env, Resolver resolver) throws CError {
    children[0].checkTypes(env, resolver);
    children[0].checkPointer(true, token);

    try {
      checkTypes_(env, resolver);
    } catch (CError e) {
      overload = new Overload(token, method);
      OpAddress addrOf = new OpAddress(token, children[0]);
      addrOf.checkTypes(env, resolver);
      overload.operator("++").children(addrOf);
      if (!overload.find(env, resolver)) throw e;
      overload.checkTypes(env, resolver);
      type = overload.getType();
    }
  }
Пример #4
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();
    }
  }