001: /*
002: * Copyright 1994-2003 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package sun.tools.tree;
027:
028: import sun.tools.java.*;
029: import sun.tools.asm.Assembler;
030: import java.io.PrintStream;
031: import java.util.Hashtable;
032:
033: /**
034: * WARNING: The contents of this source file are not part of any
035: * supported API. Code that depends on them does so at its own risk:
036: * they are subject to change or removal without notice.
037: */
038: public class ExpressionStatement extends Statement {
039: Expression expr;
040:
041: /**
042: * Constructor
043: */
044: public ExpressionStatement(long where, Expression expr) {
045: super (EXPRESSION, where);
046: this .expr = expr;
047: }
048:
049: /**
050: * Check statement
051: */
052: Vset check(Environment env, Context ctx, Vset vset, Hashtable exp) {
053: checkLabel(env, ctx);
054: return expr.check(env, ctx, reach(env, vset), exp);
055: }
056:
057: /**
058: * Inline
059: */
060: public Statement inline(Environment env, Context ctx) {
061: if (expr != null) {
062: expr = expr.inline(env, ctx);
063: return (expr == null) ? null : this ;
064: }
065: return null;
066: }
067:
068: /**
069: * Create a copy of the statement for method inlining
070: */
071: public Statement copyInline(Context ctx, boolean valNeeded) {
072: ExpressionStatement s = (ExpressionStatement) clone();
073: s.expr = expr.copyInline(ctx);
074: return s;
075: }
076:
077: /**
078: * The cost of inlining this statement
079: */
080: public int costInline(int thresh, Environment env, Context ctx) {
081: return expr.costInline(thresh, env, ctx);
082: }
083:
084: /**
085: * Code
086: */
087: public void code(Environment env, Context ctx, Assembler asm) {
088: expr.code(env, ctx, asm);
089: }
090:
091: /**
092: * Check if the first thing is a constructor invocation
093: */
094: public Expression firstConstructor() {
095: return expr.firstConstructor();
096: }
097:
098: /**
099: * Print
100: */
101: public void print(PrintStream out, int indent) {
102: super .print(out, indent);
103: if (expr != null) {
104: expr.print(out);
105: } else {
106: out.print("<empty>");
107: }
108: out.print(";");
109: }
110: }
|