mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Add OutOfMemoryError. When catching exceptions that are not defined,
report errors at compile time.
This commit is contained in:
parent
8d2e012f79
commit
d2e20d7c9f
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2015 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.classlib.java.lang;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Alexey Andreev
|
||||||
|
*/
|
||||||
|
public class TOutOfMemoryError extends TVirtualMachineError {
|
||||||
|
private static final long serialVersionUID = -1891949851728458692L;
|
||||||
|
|
||||||
|
public TOutOfMemoryError() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TOutOfMemoryError(TString message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2015 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.classlib.java.lang;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Alexey Andreev
|
||||||
|
*/
|
||||||
|
public class TVirtualMachineError extends TError {
|
||||||
|
private static final long serialVersionUID = -4246822614122675559L;
|
||||||
|
|
||||||
|
public TVirtualMachineError() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TVirtualMachineError(TString message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
|
@ -61,15 +61,22 @@ public class MissingItemsProcessor {
|
||||||
for (int i = 0; i < program.basicBlockCount(); ++i) {
|
for (int i = 0; i < program.basicBlockCount(); ++i) {
|
||||||
BasicBlock block = program.basicBlockAt(i);
|
BasicBlock block = program.basicBlockAt(i);
|
||||||
instructionsToAdd.clear();
|
instructionsToAdd.clear();
|
||||||
|
boolean missing = false;
|
||||||
for (int j = 0; j < block.getInstructions().size(); ++j) {
|
for (int j = 0; j < block.getInstructions().size(); ++j) {
|
||||||
Instruction insn = block.getInstructions().get(j);
|
Instruction insn = block.getInstructions().get(j);
|
||||||
insn.acceptVisitor(instructionProcessor);
|
insn.acceptVisitor(instructionProcessor);
|
||||||
if (!instructionsToAdd.isEmpty()) {
|
if (!instructionsToAdd.isEmpty()) {
|
||||||
wasModified = true;
|
wasModified = true;
|
||||||
truncateBlock(block, j);
|
truncateBlock(block, j);
|
||||||
|
missing = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!missing) {
|
||||||
|
for (TryCatchBlock tryCatch : block.getTryCatchBlocks()) {
|
||||||
|
checkClass(null, tryCatch.getExceptionType());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (wasModified) {
|
if (wasModified) {
|
||||||
new UnreachableBasicBlockEliminator().optimize(program);
|
new UnreachableBasicBlockEliminator().optimize(program);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user