001: /*
002: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
003: * Distributed under the terms of either:
004: * - the common development and distribution license (CDDL), v1.0; or
005: * - the GNU Lesser General Public License, v2.1 or later
006: * $Id: TypesNode.java 3677 2007-03-01 09:47:39Z gbevin $
007: */
008: package com.uwyn.rife.continuations.instrument;
009:
010: import com.uwyn.rife.asm.Label;
011: import com.uwyn.rife.continuations.instrument.TypesContext;
012: import com.uwyn.rife.continuations.instrument.TypesInstruction;
013: import com.uwyn.rife.continuations.instrument.TypesNode;
014: import com.uwyn.rife.continuations.instrument.TypesSuccessor;
015: import java.util.ArrayList;
016: import java.util.Collection;
017:
018: class TypesNode {
019: final static int REGULAR = 0;
020: final static int EXCEPTION = 1;
021:
022: private ArrayList<TypesInstruction> mInstructions = new ArrayList<TypesInstruction>();
023:
024: private TypesNode mFollowingNode = null;
025: private boolean mIsSuccessor = false;
026: private TypesSuccessor mSuccessors = null;
027:
028: private int mLevel = 0;
029: private TypesContext mContext = null;
030: private boolean mProcessed = false;
031: private TypesNode mNextToProcess = null;
032: private TypesNode mPreceeder = null;
033:
034: private int mSort = REGULAR;
035:
036: void addInstruction(TypesInstruction instruction) {
037: mInstructions.add(instruction);
038: }
039:
040: Collection<TypesInstruction> getInstructions() {
041: return mInstructions;
042: }
043:
044: void setSort(int type) {
045: mSort = type;
046: }
047:
048: int getSort() {
049: return mSort;
050: }
051:
052: void setFollowingNode(TypesNode followingNode) {
053: mFollowingNode = followingNode;
054: }
055:
056: TypesNode getFollowingNode() {
057: return mFollowingNode;
058: }
059:
060: void addSuccessor(Label label) {
061: TypesSuccessor successor = new TypesSuccessor();
062:
063: successor.setLabel(label);
064: successor.setNextSuccessor(getSuccessors());
065:
066: setSuccessors(successor);
067: }
068:
069: void setSuccessors(TypesSuccessor successors) {
070: mSuccessors = successors;
071: }
072:
073: TypesSuccessor getSuccessors() {
074: return mSuccessors;
075: }
076:
077: void setNextToProcess(TypesNode nextNode) {
078: mNextToProcess = nextNode;
079: }
080:
081: TypesNode getNextToProcess() {
082: return mNextToProcess;
083: }
084:
085: void setPreceeder(boolean isSuccessor, TypesNode preceeder) {
086: mIsSuccessor = isSuccessor;
087: mPreceeder = preceeder;
088:
089: if (mIsSuccessor) {
090: mLevel = mPreceeder.getLevel() + 1;
091: } else {
092: mLevel = mPreceeder.getLevel();
093: }
094: }
095:
096: TypesNode getPreceeder() {
097: return mPreceeder;
098: }
099:
100: boolean getIsSuccessor() {
101: return mIsSuccessor;
102: }
103:
104: void setProcessed(boolean processed) {
105: mProcessed = processed;
106: }
107:
108: boolean isProcessed() {
109: return mProcessed;
110: }
111:
112: void setContext(TypesContext previousContext) {
113: mContext = previousContext;
114: }
115:
116: TypesContext getContext() {
117: return mContext;
118: }
119:
120: int getLevel() {
121: return mLevel;
122: }
123: }
|