From 8aecb35b55bd6cb77a9065562f206c8056bebb67 Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Tue, 8 May 2018 11:00:21 -0400 Subject: [PATCH] src/nit: remove unused primitive_types module The primitive_types module contained legacy native file IO methods which were unused in the current interpreter. Since it is not necessary anymore, we remove it. Signed-off-by: Lucas Bajolet --- src/interpreter/naive_interpreter.nit | 1 - src/interpreter/primitive_types.nit | 83 --------------------------------- 2 files changed, 84 deletions(-) delete mode 100644 src/interpreter/primitive_types.nit diff --git a/src/interpreter/naive_interpreter.nit b/src/interpreter/naive_interpreter.nit index ac7b970..89deea8 100644 --- a/src/interpreter/naive_interpreter.nit +++ b/src/interpreter/naive_interpreter.nit @@ -21,7 +21,6 @@ import literal import semantize private import parser::tables import mixin -import primitive_types private import model::serialize_model private import frontend::explain_assert_api diff --git a/src/interpreter/primitive_types.nit b/src/interpreter/primitive_types.nit deleted file mode 100644 index ba058c1..0000000 --- a/src/interpreter/primitive_types.nit +++ /dev/null @@ -1,83 +0,0 @@ -# This file is part of NIT ( http://www.nitlanguage.org ). -# -# This file is free software, which comes along with NIT. This software is -# distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; -# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. You can modify it is you want, provided this header -# is kept unaltered, and a notification of the changes is added. -# You are allowed to redistribute it and sell it, alone or is a part of -# another product. - -# Encapsulates all primitive data types of nit -# -# Ensures that the use in the interpreter is independant of the -# underlying implementation and that the services are semantically correct. -module primitive_types - -intrude import core::file -intrude import core::text::flat - -# Wrapper for `NativeFile` -class PrimitiveNativeFile - - var file: Stream - - init native_stdin do - init(sys.stdin) - end - - init native_stdout do - init(sys.stdout) - end - - init native_stderr do - init(sys.stderr) - end - - init io_open_read(path: String) do - init(new FileReader.open(path.to_s)) - end - - init io_open_write(path: String) do - init(new FileWriter.open(path.to_s)) - end - - fun address_is_null: Bool do - if file isa FileStream then return file.as(FileStream)._file.address_is_null - return false - end - - fun io_read(buf: CString, len: Int): Int do - if file isa FileStream then return file.as(FileStream)._file.io_read(buf, len) - var str = file.as(Reader).read(len) - str.to_cstring.copy_to(buf, str.length, 0, 0) - return str.length - end - - fun io_write(buf: CString, from, len: Int): Int do - if file isa FileStream then return file.as(FileStream)._file.io_write(buf, from, len) - file.as(Writer).write(buf.to_s_unsafe(len, copy=false).substring_from(from)) - return len - end - - fun io_close: Int do - if file isa FileStream then return file.as(FileStream)._file.io_close - file.close - return 0 - end - - fun fileno: Int do - if file isa FileStream then return file.as(FileStream)._file.fileno - return 0 - end - - fun flush: Int do - if file isa FileStream then return file.as(FileStream)._file.flush - return 0 - end - - fun set_buffering_type(size, mode: Int): Int do - if file isa FileStream then return file.as(FileStream)._file.set_buffering_type(size, mode) - return 0 - end -end -- 1.7.9.5