use of cz.cuni.mff.d3s.trupple.language.runtime.exceptions.PascalRuntimeException in project TrufflePascal by Aspect26.
the class WithNode method executeVoid.
@Override
public void executeVoid(VirtualFrame frame) {
try {
for (FrameSlot recordSlot : this.recordSlots) {
RecordValue record = (RecordValue) frame.getObject(recordSlot);
frame = record.getFrame();
}
innerStatement.executeVoid(frame);
} catch (FrameSlotTypeException e) {
throw new PascalRuntimeException("Unexpected accessing of non record type");
}
}
use of cz.cuni.mff.d3s.trupple.language.runtime.exceptions.PascalRuntimeException in project TrufflePascal by Aspect26.
the class LexicalScope method registerBuiltinSubroutine.
public void registerBuiltinSubroutine(String identifier, SubroutineDescriptor descriptor) {
try {
this.localIdentifiers.addSubroutine(identifier, descriptor);
PascalLanguage.INSTANCE.findContext().updateSubroutine(this.name, identifier, descriptor.getRootNode());
} catch (LexicalException e) {
throw new PascalRuntimeException("Could not register builtin subroutine: " + identifier);
}
}
use of cz.cuni.mff.d3s.trupple.language.runtime.exceptions.PascalRuntimeException in project TrufflePascal by Aspect26.
the class StringBuiltinUnit method importTo.
@Override
public void importTo(UnitLexicalScope scope) {
super.importTo(scope);
try {
scope.registerType("pchar", new PointerDescriptor(PCharDesriptor.getInstance()));
} catch (LexicalException e) {
throw new PascalRuntimeException("Could not import string unit: " + e.getMessage());
}
scope.markAllIdentifiersPublic();
}
use of cz.cuni.mff.d3s.trupple.language.runtime.exceptions.PascalRuntimeException in project TrufflePascal by Aspect26.
the class ReadBuiltinNode method readChar.
private char readChar(FileValue file) throws IOException {
if (file == null) {
Pattern delimiterPattern = this.input.delimiter();
this.input.useDelimiter("");
char value = this.input.next().charAt(0);
this.input.useDelimiter(delimiterPattern);
return value;
} else {
try {
Object obj = file.read();
return (char) obj;
} catch (ClassCastException e) {
// TODO: custom exception?
throw new PascalRuntimeException("Object in a file is not a character");
}
}
}
use of cz.cuni.mff.d3s.trupple.language.runtime.exceptions.PascalRuntimeException in project TrufflePascal by Aspect26.
the class ReadBuiltinNode method readOneToReference.
private void readOneToReference(FileValue file, Reference reference) {
try {
switch(reference.getFrameSlot().getKind()) {
case Int:
int intValue = readInt(file);
this.setReferenceInt(reference, intValue);
break;
case Byte:
char charValue = readChar(file);
this.setReferenceChar(reference, charValue);
break;
case Double:
double doubleValue = readDouble(file);
this.setReferenceDouble(reference, doubleValue);
break;
case Long:
long longValue = readLong(file);
this.setReferenceLong(reference, longValue);
break;
case Object:
Object objectValue = readObject(file, reference);
this.setReferenceObject(reference, objectValue);
break;
default:
throw new PascalRuntimeException("Wrong value passed to read.");
}
} catch (IOException e) {
throw new CantReadInputException(e);
}
}
Aggregations