Exemplo n.º 1
0
	/***
	 * Returns a shallow copy 
	 */
	StateVector* StateVector::clone() {
		StateVector *clone = new (gc) StateVector(currentReferences->size(), gc);

		for (int32_t i = 0; i < getNumberOfLocals(); i++) {
			TessaInstruction* currentReference = getLocal(i);
			clone->setLocal(i, currentReference);
		}

		return clone;
	}
Exemplo n.º 2
0
	/***
	 * You can get the basic block object by asking the Label to give you the basic block
	 * When you create a basic block, it also creates the parameter instructions for the current number of local variables.
	 * If you are tracking more than just local variables, you have to manually create a parameter instruction later.
	 */
	TessaVM::BasicBlock* TessaCreationApi::createNewBasicBlock() {
		TessaVM::BasicBlock* newBasicBlock = currentFunction->createNewBasicBlock();
		this->switchToBasicBlock(newBasicBlock);
		int localCount = currentFunction->getLocalCount();
		StateVector* beginStateVector = new (gc) StateVector(localCount, gc);

		for (int i = 0; i < localCount; i++) {
			beginStateVector->setLocal(i, new (gc) ParameterInstruction(NULL, newBasicBlock));
		}

		StateVector* endStateVector = beginStateVector->clone();

		newBasicBlock->setBeginState(beginStateVector);
		newBasicBlock->setEndState(endStateVector);
		return newBasicBlock;
	}
Exemplo n.º 3
0
	void TessaCreationApi::setLocalVariable(int localVariableNumber, TessaInstruction* newReference) {
		StateVector* endState = currentFunction->getCurrentBasicBlock()->getEndState();
		endState->setLocal(localVariableNumber, newReference);
	}
Exemplo n.º 4
0
	void TessaCreationApi::trackExtraVariableInEntryState(int index, TessaInstruction* reference, int startingNumberOfLocals) {
		BasicBlock* currentBlock = currentFunction->getCurrentBasicBlock();
		StateVector* beginState = currentBlock->getBeginState();
		//AvmAssert(index + startingNumberOfLocals <= beginState->getNumberOfLocals());
		beginState->setLocal(index + startingNumberOfLocals, reference);
	}