001/*
002 * Copyright 2010-2013 JetBrains s.r.o.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.jetbrains.jet.lang.cfg;
018
019import org.jetbrains.annotations.NotNull;
020import org.jetbrains.annotations.Nullable;
021import org.jetbrains.jet.lang.cfg.pseudocode.Pseudocode;
022import org.jetbrains.jet.lang.psi.*;
023
024import java.util.Collection;
025import java.util.List;
026
027public class JetControlFlowBuilderAdapter implements JetControlFlowBuilder {
028    protected @Nullable JetControlFlowBuilder builder;
029
030    @Override
031    public void read(@NotNull JetElement element) {
032        assert builder != null;
033        builder.read(element);
034    }
035
036    @Override
037    public void readUnit(@NotNull JetExpression expression) {
038        assert builder != null;
039        builder.readUnit(expression);
040    }
041
042    @Override
043    @NotNull
044    public Label createUnboundLabel() {
045        assert builder != null;
046        return builder.createUnboundLabel();
047    }
048
049    @NotNull
050    @Override
051    public Label createUnboundLabel(@NotNull String name) {
052        assert builder != null;
053        return builder.createUnboundLabel(name);
054    }
055
056    @Override
057    public void bindLabel(@NotNull Label label) {
058        assert builder != null;
059        builder.bindLabel(label);
060    }
061
062    @Override
063    public void jump(@NotNull Label label) {
064        assert builder != null;
065        builder.jump(label);
066    }
067
068    @Override
069    public void jumpOnFalse(@NotNull Label label) {
070        assert builder != null;
071        builder.jumpOnFalse(label);
072    }
073
074    @Override
075    public void jumpOnTrue(@NotNull Label label) {
076        assert builder != null;
077        builder.jumpOnTrue(label);
078    }
079
080    @Override
081    public void nondeterministicJump(Label label) {
082        assert builder != null;
083        builder.nondeterministicJump(label);
084    }
085
086    @Override
087    public void nondeterministicJump(List<Label> labels) {
088        assert builder != null;
089        builder.nondeterministicJump(labels);
090    }
091
092    @Override
093    public void jumpToError() {
094        assert builder != null;
095        builder.jumpToError();
096    }
097
098    @Override
099    public void throwException(@NotNull JetThrowExpression throwExpression) {
100        assert builder != null;
101        builder.throwException(throwExpression);
102    }
103    
104    public Label getEntryPoint(@NotNull JetElement labelElement) {
105        assert builder != null;
106        return builder.getEntryPoint(labelElement);
107    }
108
109    @Override
110    public Label getExitPoint(@NotNull JetElement labelElement) {
111        assert builder != null;
112        return builder.getExitPoint(labelElement);
113    }
114
115    @Override
116    public LoopInfo enterLoop(@NotNull JetExpression expression, @Nullable Label loopExitPoint, Label conditionEntryPoint) {
117        assert builder != null;
118        return builder.enterLoop(expression, loopExitPoint, conditionEntryPoint);
119    }
120
121    @Override
122    public void exitLoop(@NotNull JetExpression expression) {
123        assert builder != null;
124        builder.exitLoop(expression);
125    }
126
127    @Override
128    @Nullable
129    public JetElement getCurrentLoop() {
130        assert builder != null;
131        return builder.getCurrentLoop();
132    }
133
134    @Override
135    public void enterTryFinally(@NotNull GenerationTrigger trigger) {
136        assert builder != null;
137        builder.enterTryFinally(trigger);
138    }
139
140    @Override
141    public void exitTryFinally() {
142        assert builder != null;
143        builder.exitTryFinally();
144    }
145
146    @Override
147    public void enterSubroutine(@NotNull JetElement subroutine) {
148        assert builder != null;
149        builder.enterSubroutine(subroutine);
150    }
151
152    @Override
153    public Pseudocode exitSubroutine(@NotNull JetElement subroutine) {
154        assert builder != null;
155        return builder.exitSubroutine(subroutine);
156    }
157
158    @NotNull
159    @Override
160    public JetElement getCurrentSubroutine() {
161        assert builder != null;
162        return builder.getCurrentSubroutine();
163    }
164
165    @Override
166    @Nullable
167    public JetElement getReturnSubroutine() {
168        assert builder != null;
169        return builder.getReturnSubroutine();
170    }
171
172    @Override
173    public void returnValue(@NotNull JetExpression returnExpression, @NotNull JetElement subroutine) {
174        assert builder != null;
175        builder.returnValue(returnExpression, subroutine);
176    }
177
178    @Override
179    public void returnNoValue(@NotNull JetElement returnExpression, @NotNull JetElement subroutine) {
180        assert builder != null;
181        builder.returnNoValue(returnExpression, subroutine);
182    }
183
184    @Override
185    public void unsupported(JetElement element) {
186        assert builder != null;
187        builder.unsupported(element);
188    }
189
190    @Override
191    public void write(@NotNull JetElement assignment, @NotNull JetElement lValue) {
192        assert builder != null;
193        builder.write(assignment, lValue);
194    }
195
196    @Override
197    public void declare(@NotNull JetParameter parameter) {
198        assert builder != null;
199        builder.declare(parameter);
200    }
201
202    @Override
203    public void declare(@NotNull JetVariableDeclaration property) {
204        assert builder != null;
205        builder.declare(property);
206    }
207
208    @Override
209    public void repeatPseudocode(@NotNull Label startLabel, @NotNull Label finishLabel) {
210        assert builder != null;
211        builder.repeatPseudocode(startLabel, finishLabel);
212    }
213}