001: /* Soot - a J*va Optimization Framework
002: * Copyright (C) 1999 Patrick Lam
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the
016: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
017: * Boston, MA 02111-1307, USA.
018: */
019:
020: /*
021: * Modified by the Sable Research Group and others 1997-1999.
022: * See the 'credits' file distributed with Soot for the complete list of
023: * contributors. (Soot is distributed at http://www.sable.mcgill.ca/soot)
024: */
025:
026: package soot.jimple.internal;
027:
028: import soot.tagkit.*;
029: import soot.*;
030: import soot.jimple.*;
031: import soot.baf.*;
032: import soot.util.*;
033: import java.util.*;
034:
035: public class JEnterMonitorStmt extends AbstractStmt implements
036: EnterMonitorStmt {
037: ValueBox opBox;
038:
039: public JEnterMonitorStmt(Value op) {
040: this (Jimple.v().newImmediateBox(op));
041: }
042:
043: protected JEnterMonitorStmt(ValueBox opBox) {
044: this .opBox = opBox;
045: }
046:
047: public Object clone() {
048: return new JEnterMonitorStmt(Jimple.cloneIfNecessary(getOp()));
049: }
050:
051: public String toString() {
052: return Jimple.ENTERMONITOR + " " + opBox.getValue().toString();
053: }
054:
055: public void toString(UnitPrinter up) {
056: up.literal(Jimple.ENTERMONITOR);
057: up.literal(" ");
058: opBox.toString(up);
059: }
060:
061: public Value getOp() {
062: return opBox.getValue();
063: }
064:
065: public void setOp(Value op) {
066: opBox.setValue(op);
067: }
068:
069: public ValueBox getOpBox() {
070: return opBox;
071: }
072:
073: public List getUseBoxes() {
074: List list = new ArrayList();
075:
076: list.addAll(opBox.getValue().getUseBoxes());
077: list.add(opBox);
078:
079: return list;
080: }
081:
082: public void apply(Switch sw) {
083: ((StmtSwitch) sw).caseEnterMonitorStmt(this );
084:
085: }
086:
087: public void convertToBaf(JimpleToBafContext context, List<Unit> out) {
088: ((ConvertToBaf) (getOp())).convertToBaf(context, out);
089: Unit u;
090: out.add(u = Baf.v().newEnterMonitorInst());
091:
092: Unit currentUnit = this ;
093:
094: Iterator it = currentUnit.getTags().iterator();
095: while (it.hasNext()) {
096: u.addTag((Tag) it.next());
097: }
098:
099: }
100:
101: public boolean fallsThrough() {
102: return true;
103: }
104:
105: public boolean branches() {
106: return false;
107: }
108:
109: }
|