mercredi 16 novembre 2016

How to pull object from previous function into current function in Java?

The function toWriteBack() receives an object from a previous function and toMemory(). I call toWriteBack() when toMemory() is true (i.e. not empty). Ans I also pass the The object at index 4 stored in an ArrayList called 'pipelineHolder' is

static void toMemory(Instruction currentInstruction){
    if(pipelineHolder.get(4).isStageStatus() == false){
        pipelineHolder.get(4).setStageStatus(true);
        //process memory operation
        pipelineHolder.get(4).setStageStatus(false);
    }
    else {
        System.out.println("Memory stage is not null");
        toWriteBack(currentInstruction);
    }
}
static void toWriteBack(Instruction currentInstruction){
    if(pipelineHolder.get(5).isStageStatus() == false){
        pipelineHolder.get(5).setStageStatus(true);            
        //WB operation
        pipelineHolder.get(5).setStageStatus(false);
    } 
    else {
        //here I want to get object from toMemory() to this function
    }
}

In the 'else' of toWriteBack(), how can I fetch object from toMemory() to my current function? Is it possible?

Aucun commentaire:

Enregistrer un commentaire