History

My first initial commit with all of mine experimental changes.

Dmitry Kabak (userdima committed 13 years ago

Commit d37b88d1 parent 3f5b46618352 files · +2598093 −-8690Browse files

Showing the changes to java/pkg/sun/tools/tree/ContinueStatement.java (1 of 18352 files). Show all

Unified · Split

java/pkg/sun/tools/tree/ContinueStatement.java+116−0
@@ -0,0 +1,116 @@
1+/*
2+ * Copyright (c) 1994, 2003, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package sun.tools.tree;
27+
28+import sun.tools.java.*;
29+import sun.tools.asm.Assembler;
30+import sun.tools.asm.Label;
31+import java.io.PrintStream;
32+import java.util.Hashtable;
33+
34+/**
35+ * WARNING: The contents of this source file are not part of any
36+ * supported API. Code that depends on them does so at its own risk:
37+ * they are subject to change or removal without notice.
38+ */
39+public
40+class ContinueStatement extends Statement {
41+ Identifier lbl;
42+
43+ /**
44+ * Constructor
45+ */
46+ public ContinueStatement(long where, Identifier lbl) {
47+ super(CONTINUE, where);
48+ this.lbl = lbl;
49+ }
50+
51+ /**
52+ * Check statement
53+ */
54+
55+ Vset check(Environment env, Context ctx, Vset vset, Hashtable exp) {
56+ checkLabel(env, ctx);
57+ reach(env, vset);
58+ // A new context is established here because the 'continue' statement
59+ // itself may be labelled, however erroneously. A 'CheckContext' must
60+ // be used here, as 'getContinueContext' is expected to return one.
61+ CheckContext destctx = (CheckContext)new CheckContext(ctx, this).getContinueContext(lbl);
62+ if (destctx != null) {
63+ switch (destctx.node.op) {
64+ case FOR:
65+ case DO:
66+ case WHILE:
67+ if (destctx.frameNumber != ctx.frameNumber) {
68+ env.error(where, "branch.to.uplevel", lbl);
69+ }
70+ destctx.vsContinue = destctx.vsContinue.join(vset);
71+ break;
72+ default:
73+ env.error(where, "invalid.continue");
74+ }
75+ } else {
76+ if (lbl != null) {
77+ env.error(where, "label.not.found", lbl);
78+ } else {
79+ env.error(where, "invalid.continue");
80+ }
81+ }
82+ CheckContext exitctx = ctx.getTryExitContext();
83+ if (exitctx != null) {
84+ exitctx.vsTryExit = exitctx.vsTryExit.join(vset);
85+ }
86+ return DEAD_END;
87+ }
88+
89+ /**
90+ * The cost of inlining this statement
91+ */
92+ public int costInline(int thresh, Environment env, Context ctx) {
93+ return 1;
94+ }
95+
96+ /**
97+ * Code
98+ */
99+ public void code(Environment env, Context ctx, Assembler asm) {
100+ CodeContext destctx = (CodeContext)ctx.getContinueContext(lbl);
101+ codeFinally(env, ctx, asm, destctx, null);
102+ asm.add(where, opc_goto, destctx.contLabel);
103+ }
104+
105+ /**
106+ * Print
107+ */
108+ public void print(PrintStream out, int indent) {
109+ super.print(out, indent);
110+ out.print("continue");
111+ if (lbl != null) {
112+ out.print(" " + lbl);
113+ }
114+ out.print(";");
115+ }
116+}