Search in sources :

Example 6 with PascalRuntimeException

use of cz.cuni.mff.d3s.trupple.language.runtime.exceptions.PascalRuntimeException in project TrufflePascal by Aspect26.

the class ProgramArgumentAssignmentNode method assignFile.

private void assignFile(VirtualFrame frame, String filePath) {
    try {
        FileValue file = (FileValue) frame.getObject(targetSlot);
        file.assignFilePath(filePath);
    } catch (FrameSlotTypeException e) {
        throw new PascalRuntimeException("Something went wrong");
    }
}
Also used : FileValue(cz.cuni.mff.d3s.trupple.language.runtime.customvalues.FileValue) FrameSlotTypeException(com.oracle.truffle.api.frame.FrameSlotTypeException) PascalRuntimeException(cz.cuni.mff.d3s.trupple.language.runtime.exceptions.PascalRuntimeException)

Example 7 with PascalRuntimeException

use of cz.cuni.mff.d3s.trupple.language.runtime.exceptions.PascalRuntimeException in project TrufflePascal by Aspect26.

the class ForNode method executeVoid.

@Override
public void executeVoid(VirtualFrame frame) {
    try {
        ControlInterface controlInterface = null;
        switch(controlSlot.getKind()) {
            case Int:
                controlInterface = this.createIntControlInterface(frame);
                break;
            case Long:
                controlInterface = this.createLongControlInterface(frame);
                break;
            case Byte:
                controlInterface = this.createCharControlInterface(frame);
                break;
            case Object:
                Object controlValue = frame.getObject(controlSlot);
                if (controlValue instanceof EnumValue) {
                    controlInterface = this.createEnumControlInterface(frame);
                    break;
                } else {
                    throw new PascalRuntimeException("Unsupported control variable type");
                }
        }
        this.execute(frame, controlInterface, ascending);
    } catch (FrameSlotTypeException | UnexpectedResultException e) {
        throw new PascalRuntimeException("Something went wrong.");
    }
}
Also used : FrameSlotTypeException(com.oracle.truffle.api.frame.FrameSlotTypeException) UnexpectedResultException(com.oracle.truffle.api.nodes.UnexpectedResultException) EnumValue(cz.cuni.mff.d3s.trupple.language.runtime.customvalues.EnumValue) PascalRuntimeException(cz.cuni.mff.d3s.trupple.language.runtime.exceptions.PascalRuntimeException)

Example 8 with PascalRuntimeException

use of cz.cuni.mff.d3s.trupple.language.runtime.exceptions.PascalRuntimeException in project TrufflePascal by Aspect26.

the class IdentifiersTableTP method addBuiltinFunctions.

@Override
protected void addBuiltinFunctions() {
    super.addBuiltinFunctions();
    try {
        this.registerNewIdentifier("random", new RandomSubroutineDescriptor());
        this.registerNewIdentifier("randomize", new RandomizeSubroutineDescriptor());
        this.registerNewIdentifier("assign", new AssignSubroutineDescriptor());
    } catch (LexicalException e) {
        throw new PascalRuntimeException("Could not initialize extension builtin functions: " + e.getMessage());
    }
}
Also used : LexicalException(cz.cuni.mff.d3s.trupple.parser.exceptions.LexicalException) AssignSubroutineDescriptor(cz.cuni.mff.d3s.trupple.parser.identifierstable.types.subroutine.builtin.AssignSubroutineDescriptor) RandomSubroutineDescriptor(cz.cuni.mff.d3s.trupple.parser.identifierstable.types.subroutine.builtin.RandomSubroutineDescriptor) PascalRuntimeException(cz.cuni.mff.d3s.trupple.language.runtime.exceptions.PascalRuntimeException) RandomizeSubroutineDescriptor(cz.cuni.mff.d3s.trupple.parser.identifierstable.types.subroutine.builtin.RandomizeSubroutineDescriptor)

Aggregations

PascalRuntimeException (cz.cuni.mff.d3s.trupple.language.runtime.exceptions.PascalRuntimeException)8 FrameSlotTypeException (com.oracle.truffle.api.frame.FrameSlotTypeException)3 LexicalException (cz.cuni.mff.d3s.trupple.parser.exceptions.LexicalException)3 FrameSlot (com.oracle.truffle.api.frame.FrameSlot)1 UnexpectedResultException (com.oracle.truffle.api.nodes.UnexpectedResultException)1 EnumValue (cz.cuni.mff.d3s.trupple.language.runtime.customvalues.EnumValue)1 FileValue (cz.cuni.mff.d3s.trupple.language.runtime.customvalues.FileValue)1 RecordValue (cz.cuni.mff.d3s.trupple.language.runtime.customvalues.RecordValue)1 CantReadInputException (cz.cuni.mff.d3s.trupple.language.runtime.exceptions.CantReadInputException)1 PointerDescriptor (cz.cuni.mff.d3s.trupple.parser.identifierstable.types.complex.PointerDescriptor)1 AssignSubroutineDescriptor (cz.cuni.mff.d3s.trupple.parser.identifierstable.types.subroutine.builtin.AssignSubroutineDescriptor)1 RandomSubroutineDescriptor (cz.cuni.mff.d3s.trupple.parser.identifierstable.types.subroutine.builtin.RandomSubroutineDescriptor)1 RandomizeSubroutineDescriptor (cz.cuni.mff.d3s.trupple.parser.identifierstable.types.subroutine.builtin.RandomizeSubroutineDescriptor)1 IOException (java.io.IOException)1 Pattern (java.util.regex.Pattern)1