Search in sources :

Example 1 with FileValue

use of cz.cuni.mff.d3s.trupple.language.runtime.customvalues.FileValue in project TrufflePascal by Aspect26.

the class ReadBuiltinNode method read.

@Specialization
public void read(Object[] arguments) {
    this.input = PascalLanguage.INSTANCE.findContext().getInput();
    if (arguments.length == 0) {
        readOne();
    }
    FileValue file = tryGetFileValue((Reference) arguments[0]);
    if (file != null) {
        read(file, Arrays.copyOfRange(arguments, 1, arguments.length));
    } else {
        read(null, arguments);
    }
}
Also used : FileValue(cz.cuni.mff.d3s.trupple.language.runtime.customvalues.FileValue) Specialization(com.oracle.truffle.api.dsl.Specialization)

Example 2 with FileValue

use of cz.cuni.mff.d3s.trupple.language.runtime.customvalues.FileValue in project TrufflePascal by Aspect26.

the class FileProgramArgumentAssignmentNode method executeVoid.

@Override
public void executeVoid(VirtualFrame frame) {
    try {
        FileValue file = (FileValue) frame.getObject(frameSlot);
        file.assignFilePath((String) frame.getArguments()[index]);
    } 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 3 with FileValue

use of cz.cuni.mff.d3s.trupple.language.runtime.customvalues.FileValue in project TrufflePascal by Aspect26.

the class WriteBuiltinNode method write.

@Specialization
public void write(Object[] values) {
    if (values.length > 0 && values[0] instanceof FileValue) {
        FileValue file = (FileValue) values[0];
        Object[] arguments = Arrays.copyOfRange(values, 1, values.length);
        file.write(arguments);
    } else {
        doWrite(values);
    }
}
Also used : FileValue(cz.cuni.mff.d3s.trupple.language.runtime.customvalues.FileValue) Specialization(com.oracle.truffle.api.dsl.Specialization)

Example 4 with FileValue

use of cz.cuni.mff.d3s.trupple.language.runtime.customvalues.FileValue in project TrufflePascal by Aspect26.

the class WritelnBuiltinNode method writeln.

@Specialization
public void writeln(Object... values) {
    if (values.length > 0 && values[0] instanceof FileValue) {
        FileValue file = (FileValue) values[0];
        Object[] arguments = Arrays.copyOfRange(values, 1, values.length);
        file.writeln(arguments);
    } else {
        doWriteln(values);
    }
}
Also used : FileValue(cz.cuni.mff.d3s.trupple.language.runtime.customvalues.FileValue) Specialization(com.oracle.truffle.api.dsl.Specialization)

Example 5 with FileValue

use of cz.cuni.mff.d3s.trupple.language.runtime.customvalues.FileValue 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)

Aggregations

FileValue (cz.cuni.mff.d3s.trupple.language.runtime.customvalues.FileValue)5 Specialization (com.oracle.truffle.api.dsl.Specialization)3 FrameSlotTypeException (com.oracle.truffle.api.frame.FrameSlotTypeException)2 PascalRuntimeException (cz.cuni.mff.d3s.trupple.language.runtime.exceptions.PascalRuntimeException)2