コード例 #1
0
  private void construct(
      SourceObject scriptObject_,
      boolean isExecutable_,
      DebugObject debug_,
      TokenBase rootChunk_,
      ArrayList<TokenBase> remark_,
      ArrayList<ScriptInstruction> instructionRegistry_) {
    isExecutable = isExecutable_;
    if (rootChunk_ != null) {
      rootChunk = (TokenBase) rootChunk_.clone();
    }

    if (remark_ != null) {
      remark = (ArrayList<TokenBase>) remark_.clone();
    }

    retObjClassName = scriptObject_.returnClassName;

    if (instructionRegistry_ != null) {
      instructionRegistry = (ArrayList<JRInstruction>) instructionRegistry_.clone();
    }

    methodId = scriptObject_.methodId;

    if (debug_ != null) {
      debug = debug_.clone();
    }

    if (scriptObject_ != null) {
      source = scriptObject_.clone();
    }
  }
コード例 #2
0
  public static CompiledObject compileMethodCode(
      ScriptBase object_,
      ArrayList<String> code_,
      TwoTypeArrayList<String, String> arg_,
      String returnClassPath_) {
    final ScriptMethodCompiler smp = new ScriptMethodCompiler(object_);
    final SourceObject soV = new SourceObject("");

    soV.returnClassName = returnClassPath_;

    for (int i = 0; i < code_.size(); i++) {
      soV.code.add(code_.get(i));
    }

    for (int i = 0; i < arg_.size(); i++) {
      soV.addArgument(new ArgumentObject(arg_.getFirst(i), arg_.getSecond(i), null));
    }

    CompiledObject methodCompiledObject =
        smp.parse(
            soV,
            new ValueListener_Float() {
              @Override
              public void onValueChange(float newValue_) {}
            });

    // destroy references to help gc
    AsyncTimedEvent.startStatic(
        30,
        new BaseEventListener() {
          @Override
          public boolean onEvent(Object info_) {
            soV.destroy();
            smp.destroy();
            return false;
          }
        });

    return methodCompiledObject;
  }