diff --git a/core/src/main/java/org/teavm/wasm/decompile/BlockBreakLabel.java b/core/src/main/java/org/teavm/wasm/decompile/BlockBreakLabel.java new file mode 100644 index 000000000..351fc3a3f --- /dev/null +++ b/core/src/main/java/org/teavm/wasm/decompile/BlockBreakLabel.java @@ -0,0 +1,31 @@ +/* + * Copyright 2016 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.wasm.decompile; + +import org.teavm.wasm.model.expression.WasmBlock; + +public class BlockBreakLabel implements Label { + private WasmBlock target; + + public BlockBreakLabel(WasmBlock target) { + this.target = target; + } + + @Override + public WasmBlock getTarget() { + return target; + } +} diff --git a/core/src/main/java/org/teavm/wasm/decompile/Context.java b/core/src/main/java/org/teavm/wasm/decompile/Context.java new file mode 100644 index 000000000..973901b9f --- /dev/null +++ b/core/src/main/java/org/teavm/wasm/decompile/Context.java @@ -0,0 +1,43 @@ +/* + * Copyright 2016 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.wasm.decompile; + +import org.teavm.common.DominatorTree; +import org.teavm.common.Graph; +import org.teavm.common.LoopGraph; +import org.teavm.model.Program; +import org.teavm.model.util.VariableType; +import org.teavm.wasm.model.WasmLocal; + +public interface Context { + void push(Step step); + + void setLabel(int node, Label label); + + Label getLabel(int node); + + Graph getDomGraph(); + + LoopGraph getCfg(); + + Program getProgram(); + + DominatorTree getDomTree(); + + WasmLocal getLocal(int index); + + VariableType getLocalType(int index); +} diff --git a/core/src/main/java/org/teavm/wasm/decompile/ContextUtils.java b/core/src/main/java/org/teavm/wasm/decompile/ContextUtils.java new file mode 100644 index 000000000..0edf17df1 --- /dev/null +++ b/core/src/main/java/org/teavm/wasm/decompile/ContextUtils.java @@ -0,0 +1,39 @@ +/* + * Copyright 2016 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.wasm.decompile; + +import com.carrotsearch.hppc.IntObjectMap; +import com.carrotsearch.hppc.IntObjectOpenHashMap; + +public final class ContextUtils { + private ContextUtils() { + } + + public static void withLabels(Context context, IntObjectMap