From d078426e1caa620c246117803f6a0114157db928 Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Tue, 4 Mar 2014 13:20:18 -0500 Subject: [PATCH] stdlib/strings: Moved Buffer to FlatBuffer, Buffer is now abstract. Signed-off-by: Lucas Bajolet --- .../languages/bench_typetest_fts_nesting.nit | 8 +- lib/opts.nit | 2 +- lib/standard/exec.nit | 2 +- lib/standard/file.nit | 2 +- lib/standard/stream.nit | 14 ++-- lib/standard/string.nit | 87 ++++++++++++-------- src/dbgcli.nit | 2 +- src/debugger.nit | 10 +-- src/global_compiler.nit | 4 +- src/location.nit | 2 +- src/metrics/generate_hierarchies.nit | 4 +- src/metrics/model_hyperdoc.nit | 2 +- src/model/model.nit | 2 +- src/naive_interpreter.nit | 10 +-- src/network_debugger.nit | 6 +- src/nitdoc.nit | 24 +++--- src/nitx.nit | 22 ++--- src/separate_compiler.nit | 12 +-- tests/bench_string_append.nit | 2 +- tests/example_objet.nit | 6 +- tests/example_procedural_string.nit | 2 +- tests/example_string.nit | 2 +- tests/shootout_nsieve.nit | 2 +- tests/string_trim.nit | 12 +-- tests/test_string_is_numeric.nit | 2 +- tests/test_string_long.nit | 4 +- 26 files changed, 132 insertions(+), 115 deletions(-) diff --git a/benchmarks/languages/bench_typetest_fts_nesting.nit b/benchmarks/languages/bench_typetest_fts_nesting.nit index 8cb2df0..732dab3 100644 --- a/benchmarks/languages/bench_typetest_fts_nesting.nit +++ b/benchmarks/languages/bench_typetest_fts_nesting.nit @@ -7,7 +7,7 @@ class TypeTestFtsNestingGenerator fun clanit(i: Int): String do - var s = new Buffer + var s = new FlatBuffer s.append("{classes.first}[" * i) s.append("Root") s.append("]" * i) @@ -29,7 +29,7 @@ class TypeTestFtsNestingGenerator fun clajava(i: Int): String do - var s = new Buffer + var s = new FlatBuffer s.append("{classes.first}<" * i) s.append("Root") s.append(">" * i) @@ -81,7 +81,7 @@ class TypeTestFtsNestingGenerator fun clacpp(i: Int): String do - var s = new Buffer + var s = new FlatBuffer s.append("{classes.first}<" * i) s.append("Root") s.append("*>" * i) @@ -103,7 +103,7 @@ class TypeTestFtsNestingGenerator fun clae(i: Int): String do - var s = new Buffer + var s = new FlatBuffer s.append("{classes.first}[" * i) s.append("ROOT") s.append("]" * i) diff --git a/lib/opts.nit b/lib/opts.nit index ec3c006..14e28fa 100644 --- a/lib/opts.nit +++ b/lib/opts.nit @@ -68,7 +68,7 @@ abstract class Option # A pretty print for this help fun pretty(off: Int): String do - var text = new Buffer.from(" ") + var text = new FlatBuffer.from(" ") text.append(_names.join(", ")) text.append(" ") var rest = off - text.length diff --git a/lib/standard/exec.nit b/lib/standard/exec.nit index 78424ff..166cef4 100644 --- a/lib/standard/exec.nit +++ b/lib/standard/exec.nit @@ -59,7 +59,7 @@ class Process # Internal code to handle execution protected init execute(command: String, arguments: nullable Array[String], pipeflags: Int) do - var args = new Buffer + var args = new FlatBuffer var l = 1 # Number of elements in args args.append(command) if arguments != null then diff --git a/lib/standard/file.nit b/lib/standard/file.nit index 57a4f9f..4a9a722 100644 --- a/lib/standard/file.nit +++ b/lib/standard/file.nit @@ -340,7 +340,7 @@ redef class String fun mkdir do var dirs = self.split_with("/") - var path = new Buffer + var path = new FlatBuffer if dirs.is_empty then return if dirs[0].is_empty then # it was a starting / diff --git a/lib/standard/stream.nit b/lib/standard/stream.nit index 745064a..d26d95f 100644 --- a/lib/standard/stream.nit +++ b/lib/standard/stream.nit @@ -37,7 +37,7 @@ interface IStream # Read at most i bytes fun read(i: Int): String do - var s = new Buffer.with_capacity(i) + var s = new FlatBuffer.with_capacity(i) while i > 0 and not eof do var c = read_char if c >= 0 then @@ -52,7 +52,7 @@ interface IStream fun read_line: String do assert not eof - var s = new Buffer + var s = new FlatBuffer append_line_to(s) return s.to_s end @@ -60,7 +60,7 @@ interface IStream # Read all the stream until the eof. fun read_all: String do - var s = new Buffer + var s = new FlatBuffer while not eof do var c = read_char if c >= 0 then s.add(c.ascii) @@ -117,7 +117,7 @@ abstract class BufferedIStream redef fun read(i) do - var s = new Buffer.with_capacity(i) + var s = new FlatBuffer.with_capacity(i) var j = _buffer_pos var k = _buffer.length while i > 0 do @@ -139,7 +139,7 @@ abstract class BufferedIStream redef fun read_all do - var s = new Buffer + var s = new FlatBuffer while not eof do var j = _buffer_pos var k = _buffer.length @@ -192,7 +192,7 @@ abstract class BufferedIStream redef fun eof do return _buffer_pos >= _buffer.length and end_reached # The buffer - var _buffer: nullable Buffer = null + var _buffer: nullable FlatBuffer = null # The current position in the buffer var _buffer_pos: Int = 0 @@ -206,7 +206,7 @@ abstract class BufferedIStream # Allocate a `_buffer` for a given `capacity`. protected fun prepare_buffer(capacity: Int) do - _buffer = new Buffer.with_capacity(capacity) + _buffer = new FlatBuffer.with_capacity(capacity) _buffer_pos = 0 # need to read end end diff --git a/lib/standard/string.nit b/lib/standard/string.nit index cc24265..e4c9fe4 100644 --- a/lib/standard/string.nit +++ b/lib/standard/string.nit @@ -267,7 +267,7 @@ abstract class Text # assert "Hello World!".to_upper == "HELLO WORLD!" fun to_upper: String do - var s = new Buffer.with_capacity(length) + var s = new FlatBuffer.with_capacity(length) for i in self.chars do s.add(i.to_upper) return s.to_s end @@ -277,7 +277,7 @@ abstract class Text # assert "Hello World!".to_lower == "hello world!" fun to_lower : String do - var s = new Buffer.with_capacity(length) + var s = new FlatBuffer.with_capacity(length) for i in self.chars do s.add(i.to_lower) return s.to_s end @@ -308,7 +308,7 @@ abstract class Text # Mangle a string to be a unique string only made of alphanumeric characters fun to_cmangle: String do - var res = new Buffer + var res = new FlatBuffer var underscore = false for c in self.chars do if (c >= 'a' and c <= 'z') or (c >='A' and c <= 'Z') then @@ -342,7 +342,7 @@ abstract class Text # assert "\n\"'\\".escape_to_c == "\\n\\\"\\'\\\\" fun escape_to_c: String do - var b = new Buffer + var b = new FlatBuffer for c in self.chars do if c == '\n' then b.append("\\n") @@ -369,7 +369,7 @@ abstract class Text # assert "ab|\{\}".escape_more_to_c("|\{\}") == "ab\\|\\\{\\\}" fun escape_more_to_c(chars: String): String do - var b = new Buffer + var b = new FlatBuffer for c in escape_to_c do if chars.chars.has(c) then b.add('\\') @@ -394,7 +394,7 @@ abstract class Text # assert u[0].ascii == 10 # (the ASCII value of the "new line" character) fun unescape_nit: String do - var res = new Buffer.with_capacity(self.length) + var res = new FlatBuffer.with_capacity(self.length) var was_slash = false for c in self do if not was_slash then @@ -869,22 +869,45 @@ private class FlatStringCharView end +abstract class Buffer + super Text + + # Modifies the char contained at pos `index` + # + # DEPRECATED : Use self.chars.[]= instead + fun []=(index: Int, item: Char) is abstract + + # Adds a char `c` at the end of self + # + # DEPRECATED : Use self.chars.add instead + fun add(c: Char) is abstract + + # Clears the buffer + fun clear is abstract + + # Enlarges the subsequent array containing the chars of self + fun enlarge(cap: Int) is abstract + + # Adds the content of string `s` at the end of self + fun append(s: String) is abstract + + redef fun chars: BufferCharView is abstract +end + # Mutable strings of characters. -class Buffer +class FlatBuffer super AbstractString super Comparable super StringCapable + super Buffer redef type OTHER: String - redef var chars: BufferCharView = new FlatBufferCharView(self) + redef var chars: FlatBufferCharView = new FlatBufferCharView(self) var capacity: Int - # Modifies the char contained at pos `index` - # - # DEPRECATED : Use self.chars.[]= instead - fun []=(index: Int, item: Char) + redef fun []=(index, item) do if index == length then add(item) @@ -894,21 +917,16 @@ class Buffer items[index] = item end - # Adds a char `c` at the end of self - # - # DEPRECATED : Use self.chars.add instead - fun add(c: Char) + redef fun add(c) do if capacity <= length then enlarge(length + 5) items[length] = c length += 1 end - # Clears the buffer - fun clear do length = 0 + redef fun clear do length = 0 - # Enlarges the subsequent array containing the chars of self - fun enlarge(cap: Int) + redef fun enlarge(cap) do var c = capacity if cap <= c then return @@ -978,8 +996,7 @@ class Buffer length = 0 end - # Adds the content of string `s` at the end of self - fun append(s: String) + redef fun append(s) do var sl = s.length if capacity < length + sl then enlarge(length + sl) @@ -989,7 +1006,7 @@ class Buffer redef fun ==(o) do - if not o isa Buffer then return false + if not o isa FlatBuffer then return false var l = length if o.length != l then return false var i = 0 @@ -1019,7 +1036,7 @@ class Buffer if from < 0 then from = 0 if count > length then count = length if from < count then - var r = new Buffer.with_capacity(count - from) + var r = new FlatBuffer.with_capacity(count - from) while from < count do r.chars.push(items[from]) from += 1 @@ -1034,13 +1051,13 @@ end private class FlatBufferReverseIterator super IndexedIterator[Char] - var target: Buffer + var target: FlatBuffer var target_items: NativeString var curr_pos: Int - init with_pos(tgt: Buffer, pos: Int) + init with_pos(tgt: FlatBuffer, pos: Int) do target = tgt target_items = tgt.items @@ -1061,7 +1078,7 @@ private class FlatBufferCharView super BufferCharView super StringCapable - redef type SELFTYPE: Buffer + redef type SELFTYPE: FlatBuffer redef fun [](index) do return target.items[index] @@ -1106,13 +1123,13 @@ end private class FlatBufferIterator super IndexedIterator[Char] - var target: Buffer + var target: FlatBuffer var target_items: NativeString var curr_pos: Int - init with_pos(tgt: Buffer, pos: Int) + init with_pos(tgt: FlatBuffer, pos: Int) do target = tgt target_items = tgt.items @@ -1222,7 +1239,7 @@ redef class Int fun to_base(base: Int, signed: Bool): String do var l = digit_count(base) - var s = new Buffer.from(" " * l) + var s = new FlatBuffer.from(" " * l) fill_buffer(s, base, signed) return s.to_s end @@ -1297,7 +1314,7 @@ redef class Char # assert 'x'.to_s == "x" redef fun to_s do - var s = new Buffer.with_capacity(1) + var s = new FlatBuffer.with_capacity(1) s.chars[0] = self return s.to_s end @@ -1331,7 +1348,7 @@ redef class Collection[E] # Concatenate elements. redef fun to_s do - var s = new Buffer + var s = new FlatBuffer for e in self do if e != null then s.append(e.to_s) return s.to_s end @@ -1344,7 +1361,7 @@ redef class Collection[E] do if is_empty then return "" - var s = new Buffer # Result + var s = new FlatBuffer # Result # Concat first item var i = iterator @@ -1367,7 +1384,7 @@ redef class Array[E] # Fast implementation redef fun to_s do - var s = new Buffer + var s = new FlatBuffer var i = 0 var l = length while i < l do @@ -1392,7 +1409,7 @@ redef class Map[K,V] do if is_empty then return "" - var s = new Buffer # Result + var s = new FlatBuffer # Result # Concat first item var i = iterator diff --git a/src/dbgcli.nit b/src/dbgcli.nit index 6dafabf..c80e8c3 100755 --- a/src/dbgcli.nit +++ b/src/dbgcli.nit @@ -90,7 +90,7 @@ class DebugClient fun read_command: String do - var buff = new Buffer + var buff = new FlatBuffer while debugger_connection.ready_to_read(40) do buff.append(debugger_connection.read) return buff.to_s end diff --git a/src/debugger.nit b/src/debugger.nit index 02276be..65725a8 100644 --- a/src/debugger.nit +++ b/src/debugger.nit @@ -480,7 +480,7 @@ class Debugger else if command == "nit" then printn "$~> " command = gets - var nit_buf = new Buffer + var nit_buf = new FlatBuffer while not command == ":q" do nit_buf.append(command) nit_buf.append("\n") @@ -821,7 +821,7 @@ class Debugger fun get_identifiers_in_current_instruction(instruction: AbstractString): Array[String] do var result_array = new Array[String] - var instruction_buffer = new Buffer + var instruction_buffer = new FlatBuffer var trigger_char_escape = false var trigger_string_escape = false @@ -868,7 +868,7 @@ class Debugger # fun get_function_arguments(function: AbstractString): String do - var buf = new Buffer + var buf = new FlatBuffer var trigger_copy = false for i in function.chars do @@ -904,7 +904,7 @@ class Debugger fun get_real_variable_name(name: String): String do var explode_string = name.split_with(".") - var final_string = new Buffer + var final_string = new FlatBuffer for i in explode_string do var alias_resolved = get_variable_name_by_alias(i) if alias_resolved != null then @@ -1152,7 +1152,7 @@ class Debugger # Returns an array containing their content fun remove_braces(braces: String): nullable Array[String] do - var buffer = new Buffer + var buffer = new FlatBuffer var result_array = new Array[String] diff --git a/src/global_compiler.nit b/src/global_compiler.nit index 89f8a1f..9549107 100644 --- a/src/global_compiler.nit +++ b/src/global_compiler.nit @@ -904,8 +904,8 @@ private class CustomizedRuntimeFunction var frame = new Frame(v, mmethoddef, recv, arguments) v.frame = frame - var sig = new Buffer - var comment = new Buffer + var sig = new FlatBuffer + var comment = new FlatBuffer var ret = mmethoddef.msignature.return_mtype if ret != null then ret = v.resolve_for(ret, selfvar) diff --git a/src/location.nit b/src/location.nit index 753acea..2737580 100644 --- a/src/location.nit +++ b/src/location.nit @@ -193,7 +193,7 @@ class Location lmid = "" lend = "" end - var indent = new Buffer + var indent = new FlatBuffer for j in [line_start..line_start+l.column_start-1[ do if string.chars[j] == '\t' then indent.add '\t' diff --git a/src/metrics/generate_hierarchies.nit b/src/metrics/generate_hierarchies.nit index 448bada..182856b 100644 --- a/src/metrics/generate_hierarchies.nit +++ b/src/metrics/generate_hierarchies.nit @@ -59,7 +59,7 @@ end # Create a dot file representing the class hierarchy of a model. fun generate_class_hierarchy(toolcontext: ToolContext, mmodule: MModule) do - var buf = new Buffer + var buf = new FlatBuffer buf.append("digraph \{\n") buf.append("node [shape=box];\n") buf.append("rankdir=BT;\n") @@ -80,7 +80,7 @@ end # For a simple user of the model, the classdef hierarchy is not really usefull, it is more an internal thing. fun generate_classdef_hierarchy(toolcontext: ToolContext, model: Model) do - var buf = new Buffer + var buf = new FlatBuffer buf.append("digraph \{\n") buf.append("node [shape=box];\n") buf.append("rankdir=BT;\n") diff --git a/src/metrics/model_hyperdoc.nit b/src/metrics/model_hyperdoc.nit index fea58da..bb51f4b 100644 --- a/src/metrics/model_hyperdoc.nit +++ b/src/metrics/model_hyperdoc.nit @@ -39,7 +39,7 @@ end # The generated file contains the description of each entity of the model fun generate_model_hyperdoc(toolcontext: ToolContext, model: Model) do - var buf = new Buffer + var buf = new FlatBuffer buf.append("\n\n") buf.append("

Model

\n") diff --git a/src/model/model.nit b/src/model/model.nit index ad1c325..6102df5 100644 --- a/src/model/model.nit +++ b/src/model/model.nit @@ -1412,7 +1412,7 @@ class MSignature redef fun to_s do - var b = new Buffer + var b = new FlatBuffer if not mparameters.is_empty then b.append("(") for i in [0..mparameters.length[ do diff --git a/src/naive_interpreter.nit b/src/naive_interpreter.nit index 4b1030a..f7b97ba 100644 --- a/src/naive_interpreter.nit +++ b/src/naive_interpreter.nit @@ -249,7 +249,7 @@ private class NaiveInterpreter # Return a new native string initialized with `txt` fun native_string_instance(txt: String): Instance do - var val = new Buffer.from(txt) + var val = new FlatBuffer.from(txt) val.add('\0') var ic = self.mainmodule.get_primitive_class("NativeString") return new PrimitiveInstance[Buffer](ic.mclass_type, val) @@ -264,7 +264,7 @@ private class NaiveInterpreter # Return a stack stace. One line per function fun stack_trace: String do - var b = new Buffer + var b = new FlatBuffer b.append(",---- Stack trace -- - - -\n") for f in frames do b.append("| {f.mpropdef} ({f.current_node.location})\n") @@ -767,7 +767,7 @@ redef class AInternMethPropdef return null else if pname == "copy_to" then # sig= copy_to(dest: NativeString, length: Int, from: Int, to: Int) - var destval = args[1].val.as(Buffer) + var destval = args[1].val.as(FlatBuffer) var lenval = args[2].to_i var fromval = args[3].to_i var toval = args[4].to_i @@ -783,7 +783,7 @@ redef class AInternMethPropdef if toval + lenval >= destval.length then debug("Illegal access on {destval} for element {toval}+{lenval}/{destval.length}") end - recvval.copy(fromval, lenval, destval, toval) + recvval.as(FlatBuffer).copy(fromval, lenval, destval, toval) return null else if pname == "atoi" then return v.int_instance(recvval.to_i) @@ -875,7 +875,7 @@ redef class AExternMethPropdef else if pname == "io_read" then var str = recvval.as(IStream).read(args[2].to_i) var a1 = args[1].val.as(Buffer) - new Buffer.from(str).copy(0, str.length, a1, 0) + new FlatBuffer.from(str).copy(0, str.length, a1.as(FlatBuffer), 0) return v.int_instance(str.length) else if pname == "io_close" then recvval.as(IOS).close diff --git a/src/network_debugger.nit b/src/network_debugger.nit index cac7dd5..7fc38aa 100755 --- a/src/network_debugger.nit +++ b/src/network_debugger.nit @@ -152,7 +152,7 @@ redef class Stdin var connection: nullable Socket = null # Used to store data that has been read from the connection - var buf: Buffer = new Buffer + var buf: Buffer = new FlatBuffer var buf_pos: Int = 0 # Checks if data is available for reading @@ -165,7 +165,7 @@ redef class Stdin # Blocking if the buffer is empty redef fun read_all do - var loc_buf = new Buffer + var loc_buf = new FlatBuffer if connection.ready_to_read(0) then buf.append(connection.read) for i in [buf_pos .. buf.length-1] do loc_buf.add(buf.chars[i]) buf.clear @@ -193,7 +193,7 @@ redef class Stdin # If the buffer is empty, the read_line call is blocking redef fun read_line do - var line_buf = new Buffer + var line_buf = new FlatBuffer if connection.ready_to_read(0) then buf.append(connection.read) var has_found_eol: Bool = false loop diff --git a/src/nitdoc.nit b/src/nitdoc.nit index 4a5e68e..591ecc6 100644 --- a/src/nitdoc.nit +++ b/src/nitdoc.nit @@ -440,7 +440,7 @@ class NitdocOverview end end # build graph - var op = new Buffer + var op = new FlatBuffer op.append("digraph dep \{ rankdir=BT; node[shape=none,margin=0,width=0,height=0,fontsize=10]; edge[dir=none,color=gray]; ranksep=0.2; nodesep=0.1;\n") for mmodule in poset do op.append("\"{mmodule.name}\"[URL=\"{mmodule.url}\"];\n") @@ -711,7 +711,7 @@ class NitdocModule end end # build graph - var op = new Buffer + var op = new FlatBuffer var name = "dep_{mmodule.name}" op.append("digraph {name} \{ rankdir=BT; node[shape=none,margin=0,width=0,height=0,fontsize=10]; edge[dir=none,color=gray]; ranksep=0.2; nodesep=0.1;\n") for mmodule in poset do @@ -1095,7 +1095,7 @@ class NitdocClass end cla.add_all(pe.greaters) - var op = new Buffer + var op = new FlatBuffer var name = "dep_{mclass.name}" op.append("digraph {name} \{ rankdir=BT; node[shape=none,margin=0,width=0,height=0,fontsize=10]; edge[dir=none,color=gray]; ranksep=0.2; nodesep=0.1;\n") for c in cla do @@ -1136,7 +1136,7 @@ redef class MModule # module_owner_name.html private fun url: String do if url_cache == null then - var res = new Buffer + var res = new FlatBuffer res.append("module_") var mowner = public_owner if mowner != null then @@ -1153,7 +1153,7 @@ redef class MModule # MOD_owner_name private fun anchor: String do if anchor_cache == null then - var res = new Buffer + var res = new FlatBuffer res.append("MOD_") var mowner = public_owner if mowner != null then @@ -1170,7 +1170,7 @@ redef class MModule # html_name private fun html_link(page: NitdocPage) do if html_link_cache == null then - var res = new Buffer + var res = new FlatBuffer if page.ctx.mbuilder.mmodule2nmodule.has_key(self) then res.append("{html_name}") else @@ -1282,7 +1282,7 @@ redef class MClass # html_name(signature) private fun html_link(page: NitdocPage) do if html_link_cache == null then - var res = new Buffer + var res = new FlatBuffer res.append("html_name private fun html_short_link(page: NitdocPage) do if html_short_link_cache == null then - var res = new Buffer + var res = new FlatBuffer res.append("html_name private fun html_link_anchor(page: NitdocPage) do if html_link_anchor_cache == null then - var res = new Buffer + var res = new FlatBuffer res.append("html_name private fun html_link(page: NitdocPage) do if html_link_cache == null then - var res = new Buffer + var res = new FlatBuffer if page.ctx.mbuilder.mpropdef2npropdef.has_key(self) then var nprop = page.ctx.mbuilder.mpropdef2npropdef[self] res.append("{mproperty.html_name}") @@ -1745,7 +1745,7 @@ redef class MSignature end private fun untyped_signature(page: NitdocPage): String do - var res = new Buffer + var res = new FlatBuffer if not mparameters.is_empty then res.append("(") for i in [0..mparameters.length[ do @@ -1785,7 +1785,7 @@ redef class ADoc end private fun full_comment: String do - var res = new Buffer + var res = new FlatBuffer for t in n_comment do var text = t.text text = text.substring_from(1) diff --git a/src/nitx.nit b/src/nitx.nit index 9db4abd..456a5eb 100644 --- a/src/nitx.nit +++ b/src/nitx.nit @@ -354,7 +354,7 @@ private class PagerMatchesRenderer end private class Pager - var content = new Buffer + var content = new FlatBuffer var indent = 0 fun add(text: String) do add_indent @@ -464,7 +464,7 @@ redef class MClass # return the generic signature of the class # [E, F] private fun signature: String do - var res = new Buffer + var res = new FlatBuffer if arity > 0 then res.append("[") for i in [0..intro.parameter_names.length[ do @@ -480,7 +480,7 @@ redef class MClass # class name is displayed with colors depending on visibility # abstract interface Foo[E] private fun prototype: String do - var res = new Buffer + var res = new FlatBuffer res.append("{kind} ") if visibility.to_s == "public" then res.append("{name}{signature}".bold.green) if visibility.to_s == "private" then res.append("{name}{signature}".bold.red) @@ -576,7 +576,7 @@ redef class MClassDef end fun to_console: String do - var res = new Buffer + var res = new FlatBuffer if not is_intro then res.append("redef ") res.append(mclass.prototype) return res.to_s @@ -708,7 +708,7 @@ end redef class MMethodDef redef fun to_console do - var res = new Buffer + var res = new FlatBuffer if not is_intro then res.append("redef ") if not mproperty.is_init then res.append("fun ") res.append(mproperty.to_console.bold) @@ -723,7 +723,7 @@ end redef class MVirtualTypeDef redef fun to_console do - var res = new Buffer + var res = new FlatBuffer res.append("type ") res.append(mproperty.to_console.bold) res.append(": {bound.to_console}") @@ -733,7 +733,7 @@ end redef class MAttributeDef redef fun to_console do - var res = new Buffer + var res = new FlatBuffer res.append("var ") res.append(mproperty.to_console.bold) res.append(": {static_mtype.to_console}") @@ -743,7 +743,7 @@ end redef class MSignature redef fun to_console do - var res = new Buffer + var res = new FlatBuffer if not mparameters.is_empty then res.append("(") for i in [0..mparameters.length[ do @@ -761,7 +761,7 @@ end redef class MParameter fun to_console: String do - var res = new Buffer + var res = new FlatBuffer res.append("{name}: {mtype.to_console}") if is_vararg then res.append("...") return res.to_s @@ -778,7 +778,7 @@ end redef class MGenericType redef fun to_console do - var res = new Buffer + var res = new FlatBuffer res.append("{mclass.name}[") for i in [0..arguments.length[ do res.append(arguments[i].to_console) @@ -861,7 +861,7 @@ redef class String private fun escape: String do - var b = new Buffer + var b = new FlatBuffer for c in self.chars do if c == '\n' then b.append("\\n") diff --git a/src/separate_compiler.nit b/src/separate_compiler.nit index 09545e4..0857b04 100644 --- a/src/separate_compiler.nit +++ b/src/separate_compiler.nit @@ -1009,8 +1009,8 @@ class SeparateCompilerVisitor res = self.new_var(ret) end - var s = new Buffer - var ss = new Buffer + var s = new FlatBuffer + var ss = new FlatBuffer var recv = arguments.first s.append("val*") @@ -1682,8 +1682,8 @@ class SeparateRuntimeFunction var msignature = mmethoddef.msignature.resolve_for(mmethoddef.mclassdef.bound_mtype, mmethoddef.mclassdef.bound_mtype, mmethoddef.mclassdef.mmodule, true) - var sig = new Buffer - var comment = new Buffer + var sig = new FlatBuffer + var comment = new FlatBuffer var ret = msignature.return_mtype if ret != null then sig.append("{ret.ctype} ") @@ -1755,8 +1755,8 @@ class VirtualRuntimeFunction var frame = new Frame(v, mmethoddef, recv, arguments) v.frame = frame - var sig = new Buffer - var comment = new Buffer + var sig = new FlatBuffer + var comment = new FlatBuffer # Because the function is virtual, the signature must match the one of the original class var intromclassdef = self.mmethoddef.mproperty.intro.mclassdef diff --git a/tests/bench_string_append.nit b/tests/bench_string_append.nit index 6a2d643..0784887 100644 --- a/tests/bench_string_append.nit +++ b/tests/bench_string_append.nit @@ -22,7 +22,7 @@ end var s = "*" var i = 0 while i < n do - var s2 = new Buffer.from("Je dis «") + var s2 = new FlatBuffer.from("Je dis «") s2.append(s) s2.append("» et redis «") s2.append(s) diff --git a/tests/example_objet.nit b/tests/example_objet.nit index 1bcc313..a0f69d6 100644 --- a/tests/example_objet.nit +++ b/tests/example_objet.nit @@ -101,7 +101,7 @@ private do # Les variables sont déclarées par "var", leur portée va de leur # déclaration jusqu'au "end" correspondant - var s = new Buffer # Là où on calcule le résultat + var s = new FlatBuffer # Là où on calcule le résultat # Les chaînes littérales sont déclarées avec des guillemets s.append("*** Entrepôt ") # On initialise "s" # puis on concatène des chaînes à "s" @@ -218,7 +218,7 @@ private # Si une expression est passée comme valeur initiale d'une # variable, le type statique de la variable est implicitement # celui de l'expression. - var s = new Buffer + var s = new FlatBuffer s.append("* Rayon : ") # Ici, le type statique de s est implicitement String @@ -245,7 +245,7 @@ private redef fun to_s: String do - var s = new Buffer + var s = new FlatBuffer s.append(to_s_head) # Les boucles en NIT sont des structures puissantes, toutefois # la manipulation des itérateurs peut être facilité par la diff --git a/tests/example_procedural_string.nit b/tests/example_procedural_string.nit index a78d01f..c00d979 100644 --- a/tests/example_procedural_string.nit +++ b/tests/example_procedural_string.nit @@ -18,7 +18,7 @@ fun first_word(s: String): String do - var result = new Buffer + var result = new FlatBuffer var i = 0 while i < s.length and s.chars[i] != ' ' do result.add(s.chars[i]) diff --git a/tests/example_string.nit b/tests/example_string.nit index 006efff..f066eac 100644 --- a/tests/example_string.nit +++ b/tests/example_string.nit @@ -27,7 +27,7 @@ printn("The value of a is: ", a, ".\n") # Second way: Build a string and display it. # Pro: Eiffel way (rigourous). # Con: Eiffel way (heavy). -var s = new Buffer.from("The value of a is: ") +var s = new FlatBuffer.from("The value of a is: ") s.append(a.to_s) s.append(".\n") printn(s) diff --git a/tests/shootout_nsieve.nit b/tests/shootout_nsieve.nit index b0ecf41..acc2856 100644 --- a/tests/shootout_nsieve.nit +++ b/tests/shootout_nsieve.nit @@ -17,7 +17,7 @@ fun nsieve(n: Int): Int do var count = 0 - var array = new Buffer.with_capacity(n) + var array = new FlatBuffer.with_capacity(n) for i in [0..n[ do array.chars[i] = 'o' end diff --git a/tests/string_trim.nit b/tests/string_trim.nit index 09bd541..387c8b1 100644 --- a/tests/string_trim.nit +++ b/tests/string_trim.nit @@ -4,7 +4,7 @@ var trimtest = " \t nono nono \n \t" var subtrim = trimtest.substring(2,15) -var buffertrimtest = new Buffer.from(trimtest) +var buffertrimtest = new FlatBuffer.from(trimtest) print "resulttrim = {buffertrimtest.trim}" @@ -14,7 +14,7 @@ print "thirdtrim = {subtrim.trim}" var emptytrim = " \t " -var bufferemptytest = new Buffer.from(emptytrim) +var bufferemptytest = new FlatBuffer.from(emptytrim) print "emptytrim = {emptytrim.trim}" @@ -22,7 +22,7 @@ print "bufferemptytrim = {bufferemptytest.trim}" var onelettertrim = " \n d \n\t " -var oneletterbuftest = new Buffer.from(onelettertrim) +var oneletterbuftest = new FlatBuffer.from(onelettertrim) print "onelettertrim = {onelettertrim.trim}" @@ -30,7 +30,7 @@ print "oneletterbuftest = {oneletterbuftest.trim}" var twolettertrim = " \n hg \n\t " -var twoletterbuftest = new Buffer.from(twolettertrim) +var twoletterbuftest = new FlatBuffer.from(twolettertrim) print "twolettertrim = {twolettertrim.trim}" @@ -38,7 +38,7 @@ print "twoletterbuftest = {twoletterbuftest.trim}" var firstlettertrim = "d " -var firstlettertrimbuf = new Buffer.from(firstlettertrim) +var firstlettertrimbuf = new FlatBuffer.from(firstlettertrim) print "firstlettertrimtest = {firstlettertrim.trim}" @@ -46,7 +46,7 @@ print "firstlettertrimbuftest = {firstlettertrimbuf.trim}" var lastlettertrim = " d" -var lastlettertrimbuf = new Buffer.from(lastlettertrim) +var lastlettertrimbuf = new FlatBuffer.from(lastlettertrim) print "lastlettertrimtest = {lastlettertrim.trim}" diff --git a/tests/test_string_is_numeric.nit b/tests/test_string_is_numeric.nit index aa02268..fcf7ea2 100644 --- a/tests/test_string_is_numeric.nit +++ b/tests/test_string_is_numeric.nit @@ -52,7 +52,7 @@ print "585,210.52".is_numeric #False print "21,52,210.52".is_numeric -var buf = new Buffer +var buf = new FlatBuffer buf.append("45.3") diff --git a/tests/test_string_long.nit b/tests/test_string_long.nit index 1b59ba8..04655ba 100644 --- a/tests/test_string_long.nit +++ b/tests/test_string_long.nit @@ -16,8 +16,8 @@ var s = "Bonjour !\n" -var r = new Buffer.with_capacity(50) -var r2 = new Buffer +var r = new FlatBuffer.with_capacity(50) +var r2 = new FlatBuffer var i = 0 while i < 5000 do -- 1.7.9.5