LRE
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
List overview
Download
Projects
September 2005
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
projects@lrde.epita.fr
8 participants
56 discussions
Start a n
N
ew thread
[LrdeTools] 225: Some last changes before the release.
by Nicolas Pouillard
https://svn.lrde.epita.fr/svn/lrdetools/trunk
Index: ChangeLog from Nicolas Pouillard <ertai(a)lrde.epita.fr> Some last changes before the release. * vcs/lib/vcs/mail.rb: Use --confirm instead of --ask. * vcs/lib/vcs/message.rb: Publish the collaboa url if COLLABOA is defined. * vcs/lib/vcs/changelog.rb: Title and subject are not Yaml anymore. * vcs/lib/vcs/vcs.rb: Update packaging. * vcs/lib/vcs/tools.rb: Remove. * vcs/lib/vcs/svn.rb: Remove a require. * vcs/lib/vcs/mycommit.rb, vcs/lib/vcs/conflict.rb, vcs/lib/vcs/news.rb: Use highline instead of ask. * vcs/bin/vcs: Change the version. Make --mk-alias support bash. * vcs/SPEC.yml: Update dependencies and ttk options. * vcs/test/vcs-check.yml: New. The main test suite. * vcs/test/options-suite.yml: New. A simple test suite for options. SPEC.yml | 5 ++++- bin/vcs | 8 ++++---- lib/vcs/changelog.rb | 9 ++++++--- lib/vcs/conflict.rb | 4 ++-- lib/vcs/edit.rb | 1 + lib/vcs/mail.rb | 2 +- lib/vcs/message.rb | 8 ++++++++ lib/vcs/mycommit.rb | 8 ++++---- lib/vcs/news.rb | 4 ++-- lib/vcs/svn.rb | 1 - lib/vcs/tools.rb | 22 ---------------------- lib/vcs/vcs.rb | 6 +++++- test/options-suite.yml | 38 ++++++++++++++++++++++++++++++++++++++ test/vcs-check.yml | 8 ++++++++ 14 files changed, 83 insertions(+), 41 deletions(-) Index: vcs/lib/vcs/tools.rb --- vcs/lib/vcs/tools.rb (revision 224) +++ vcs/lib/vcs/tools.rb (working copy) @@ -1,22 +0,0 @@ -# Author:: Nicolas Pouillard <ertai(a)lrde.epita.fr>. -# Copyright:: Copyright (c) 2004 LRDE. All rights reserved. -# License:: GNU General Public License (GPL). - -# $LastChangedBy: ertai $ -# $Id: header 98 2004-09-29 12:07:43Z ertai $ - -require 'yaml' -module YAML - - def self.chop_header ( io ) - aStr = io.gets - raise Exception, "First line is not valid: `#{aLine}'" unless aStr =~ /^---/ - io.each do |aLine| - break if aLine =~ /^---/ - aStr += aLine - end - YAML::load(aStr) - end - -end # module YAML - Index: vcs/bin/vcs --- vcs/bin/vcs (revision 224) +++ vcs/bin/vcs (working copy) @@ -16,7 +16,7 @@ require 'optparse' require 'set' -VCS_VERSION = '0.2.148' +VCS_VERSION = '0.3.0' VCS_PATH = Pathname.new(__FILE__).expand_path VCS_DIR, VCS = VCS_PATH.split LIB = VCS_DIR + '..' + 'lib' @@ -79,13 +79,13 @@ exit end - opts.on('--mk-alias', 'Use this command like that `vcs --mk-alias`') do + opts.on('--mk-alias', 'Put the result of this command in your .zshrc or .bashrc') do ALL_VCS_NAMES.each do |n| n = n.to_s.downcase if VCS_PATH.executable? - puts "alias #{n}=#{VCS_PATH}-#{n}" + puts "alias #{n}=#{VCS_PATH}-#{n} ;" else - puts "alias #{n}=vcs-#{n}" + puts "alias #{n}=vcs-#{n} ;" end end exit Index: vcs/lib/vcs/news.rb --- vcs/lib/vcs/news.rb (revision 224) +++ vcs/lib/vcs/news.rb (working copy) @@ -70,9 +70,9 @@ server, port = opt[:server].split(/:/) port ||= 119 LOG.info('news') { "Nntp Server: #{server}:#{port}" } - if ask("Post a news, with this subject: #{opt[:subject]}\n" + + unless @h.agree("Post a news, with this subject: #{opt[:subject]}\n" + " to #{opt[:groups].join(', ')}\n from #{opt[:from]}\n" + - 'Are you sure?', :y) == :n + 'Are you sure? (y/n)', true) LOG.error('news') { 'Aborting' } exit end Index: vcs/lib/vcs/mail.rb --- vcs/lib/vcs/mail.rb (revision 224) +++ vcs/lib/vcs/mail.rb (working copy) @@ -10,7 +10,7 @@ MAIL = Sendmail::MAIL_FILE MAILER = Sendmail.new - DEFAULT_OPTIONS = %w[ --ask --sign --mime ] + DEFAULT_OPTIONS = %w[ --confirm --sign --mime ] # # Mail. Index: vcs/SPEC.yml --- vcs/SPEC.yml (revision 224) +++ vcs/SPEC.yml (working copy) @@ -32,4 +32,7 @@ executables: [ vcs, vcs-svn, vcs-cvs, vcs-prcs ] dependencies: - ruby_ex: ~> 0.1.3 + ruby_ex: [~> 0.2.0, 6087/ruby_ex-0.2.0.tar.gz] + +root_test_suite: test/vcs-check.yml +ttk_version: ~> 0.3.0 Index: vcs/test/vcs-check.yml --- vcs/test/vcs-check.yml (revision 0) +++ vcs/test/vcs-check.yml (revision 0) @@ -0,0 +1,8 @@ +--- + +Run all test suites: !S::Iterate + over: !pathlist <<pwd>>/(*)-suite.yml + iter: [it_file, it_name] + test: + Run the <<it_name>> suite: !S::Import + import: <<it_file>> Index: vcs/lib/vcs/changelog.rb --- vcs/lib/vcs/changelog.rb (revision 224) +++ vcs/lib/vcs/changelog.rb (working copy) @@ -64,10 +64,13 @@ raise MustBeFilled, cl if cl.read =~ /\A---/ require 'erb' ls = [] - YAML.each_document(cl.read) { |x| (ls.size == 2)? break : ls << x } - header, input = ls + YAML.each_document("--- |\n" + cl.read) { |x| (ls.size == 2)? break : ls << x } + title_subject, input = ls + header = { 'title' => title_subject[/^title: (.*)$/, 1], + 'subject' => title_subject[/^subject: (.*)$/, 1] } rev = revision.read.to_i + 1 header.merge!('rev' => rev, 'revision' => rev) + raise "no title: reopen #{ADD_CL}" if header['title'].nil? header['title'].sub!(/\.$/, '') b = getBinding(header) header = ERB.new(header.to_yaml, $SAFE, '<-%->', '$erbout_').result(b) @@ -83,7 +86,7 @@ f.puts " |--- | ########## Fill this file correctly and remove this line ########## | --- |title: -|subject: '#{@@subject_format}.' +|subject: #{@@subject_format}. | |--- | ###################### Your ChangeLog entrie ###################### | --- |#{head} Index: vcs/lib/vcs/edit.rb --- vcs/lib/vcs/edit.rb (revision 224) +++ vcs/lib/vcs/edit.rb (working copy) @@ -8,6 +8,7 @@ class Vcs def edit! ( *files ) + # stringify cmd = EDITOR + files.flatten.map { |x| x.to_s } > [STDOUT, STDERR] cmd.run(@runner) end Index: vcs/lib/vcs/conflict.rb --- vcs/lib/vcs/conflict.rb (revision 224) +++ vcs/lib/vcs/conflict.rb (working copy) @@ -12,8 +12,8 @@ def resolve_conflicts! conflicts = mk_conflicts_list - question = "Resolve these conflicts: \n - #{conflicts.join("\n - ")}\n" - if ask(question, :n, STDIN, STDOUT, STDERR) == :y + question = "Resolve these conflicts?: \n - #{conflicts.join("\n - ")}\n(y/n)" + if @h.agree question, true return resolved(conflicts) end end Index: vcs/lib/vcs/svn.rb --- vcs/lib/vcs/svn.rb (revision 224) +++ vcs/lib/vcs/svn.rb (working copy) @@ -6,7 +6,6 @@ # $Id: header 98 2004-09-29 12:07:43Z ertai $ require 'vcs/vcs' -require 'vcs/tools' CL = Pathname.new('ChangeLog') ADD_CL = Pathname.new(',ChangeLog') Index: vcs/lib/vcs/mycommit.rb --- vcs/lib/vcs/mycommit.rb (revision 224) +++ vcs/lib/vcs/mycommit.rb (working copy) @@ -6,7 +6,6 @@ # $Id: header 98 2004-09-29 12:07:43Z ertai $ require 'vcs/vcs' -require 'ask' class Vcs @@ -32,7 +31,7 @@ edit! @@message - if ask('Committing, are you sure?', :y) == :n + unless @h.agree 'Committing, are you sure? (y/n)', true commit_failed end @@ -45,10 +44,11 @@ # FIXME simplify cl_entry contents - if commit!('--message', cl_entry, *(opts + args)) + begin + commit!('--message', cl_entry, *(opts + args)) ADD_CL.rename(COMMITED) TMP_CL.delete if TMP_CL.exist? - else + rescue commit_failed end Index: vcs/lib/vcs/vcs.rb --- vcs/lib/vcs/vcs.rb (revision 224) +++ vcs/lib/vcs/vcs.rb (working copy) @@ -7,7 +7,9 @@ require 'rubygems' require_gem 'ruby_ex' -require 'commands' +require 'ruby_ex' +Commands.import! +Yaml::ChopHeader.import! # The abstract class for a Vcs wrapper. # Conventions: @@ -52,6 +54,7 @@ end def new_command_data + @__instance.status = nil @__instance end @@ -61,6 +64,7 @@ @cmd = aCmd.to_cmd @handlers = Set.new @runner = Commands::Runners::System.new + @h = HighLine.new self.cmd_data_factory = VcsCmdDataFactory.new(:output => STDOUT, :error => STDERR) @runner.subscribe_hook(:failure) do |data| Index: vcs/test/options-suite.yml --- vcs/test/options-suite.yml (revision 0) +++ vcs/test/options-suite.yml (revision 0) @@ -0,0 +1,38 @@ +--- + +Check vcs basic options: !S::Suite + + # What have these test in common + attributes: !S::Cmd # All of them follow the Cmd strategy + command: <<pwd>>/../bin/vcs # They test the same command + exit : 0 # They expect 0 as exit status + error : "" # By default we don't want anything on stderr + + contents: + + - Check the version option: + args: --version # Give --version as arguement + output: !re | # Output will be compared to this regexp + Vcs version: \d+.\d+.\d+ + + - Check the help option: + args: --help + output: "" # Output must be empty + error: | # Stderr output will be compared to this string + Usage: vcs [options] <file>* + + -c, --vcs TYPE Set your vcs + -l, --vcs-list List all vcs + --mk-alias Put the result of this command in your .zshrc or .bashrc + -C, --[no-]check Check your vcs configuration + -d, --debug LEVEL Set debug level + -h, --help Show this message + --version Show version + + + Report bugs to <ertai(a)lrde.epita.fr>. + + - Check the mk-alias option: + args: --mk-alias + # Output will be compared to this regexp + output: !re \A(^alias \w+=.* ;$)+ Index: vcs/lib/vcs/message.rb --- vcs/lib/vcs/message.rb (revision 224) +++ vcs/lib/vcs/message.rb (working copy) @@ -43,6 +43,14 @@ TempPath.new('message') do |tmp| tmp.open('w') do |f| with(f).url! + if defined? COLLABOA + f.puts + f.puts 'You can also view this changeset here:' + f.puts + next_rev = rev.output.read.to_i + next_rev += 1 unless ',commited'.to_path.exist? + f.puts "http://#{COLLABOA}/repository/changesets/#{next_rev}" + end f.puts f.puts 'Index: ChangeLog' f.print cl_entry.sub(/^\d+-\d+-\d+/, 'from')
19 years, 3 months
1
0
0
0
Open now and verify your email at eBay
by aw-confirm@ebay.com
19 years, 3 months
1
0
0
0
[nolimips: 191] Detect several definitions of the same label in a section
by Noe
I have a problem with error propagation...
https://svn.lrde.epita.fr/svn/nolimips/trunk
ChangeLog | 19 +++++++++++++ src/inst/Makefile.am | 2 - src/inst/data_section.cc | 4 +- src/inst/data_section.hh | 2 - src/inst/program_builder.hh.gen.py | 14 ++++++++- src/inst/section.cc | 44 +++++++++++++++++++++++++++++++ src/inst/section.hh | 12 +++----- src/inst/text_section.cc | 4 +- src/inst/text_section.hh | 2 - tests/solve/Makefile.am | 4 ++ tests/solve/data-label-already-defined.s | 12 ++++++++ tests/solve/text-label-already-defined.s | 7 ++++ 12 files changed, 109 insertions(+), 17 deletions(-) Index: ChangeLog from Benoît Perrot <benoit(a)lrde.epita.fr> Detect several definitions of the same label in a section. * src/inst/section.hh (register_label): Return false when label is already known in the section, true otherwise. Move implementation to... * src/inst/section.cc, src/inst/Makefile.am: This new file. * src/inst/data_section.hh, src/inst/data_section.cc, * src/inst/text_section.hh, src/inst/text_section.cc (define_label): Propagate status of register_label. * src/inst/program_builder.hh.gen.py: Generate an error when a label is defined more than once. * tests/solve/data-label-already-defined.s, * tests/solve/text-label-already-defined.s, * tests/solve/Makefile.am: Test it. 2005-09-03 Benoît Perrot <benoit(a)lrde.epita.fr> Index: src/inst/data_section.cc --- src/inst/data_section.cc (revision 190) +++ src/inst/data_section.cc (revision 191) @@ -30,13 +30,13 @@ // -------------------------------------------------------------------------- - void + bool DataSection::define_label(const misc::unique_string &id) { Label *label = new inst::Label(id, size()); labels_.push_back(label); - Section::register_label(label); + return Section::register_label(label); } // -------------------------------------------------------------------------- Index: src/inst/section.cc --- src/inst/section.cc (revision 0) +++ src/inst/section.cc (revision 191) @@ -0,0 +1,44 @@ +// +// This file is part of Nolimips, a MIPS simulator with unlimited registers +// Copyright (C) 2005 Benoit Perrot <benoit(a)lrde.epita.fr> +// +// Nolimips is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// Nolimips 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. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +#include "inst/section.hh" + +namespace inst +{ + + Section::~Section() + { +// for (label_set_type::iterator +// it = sorted_labels_.begin(); it != sorted_labels_.end(); ++it) +// delete *it; + } + + bool + Section::register_label(Label *label) + { + label_set_type::const_iterator it(sorted_labels_.find(label)); + if (it == sorted_labels_.end() + || *(*it) < *label) + { + it = sorted_labels_.insert(it, label); + return true; + } + return false; + } + +} // namespace inst Index: src/inst/data_section.hh --- src/inst/data_section.hh (revision 190) +++ src/inst/data_section.hh (revision 191) @@ -49,7 +49,7 @@ } public: - void define_label(const misc::unique_string &id); + bool define_label(const misc::unique_string &id); public: void add_space(unsigned space_size) Index: src/inst/text_section.cc --- src/inst/text_section.cc (revision 190) +++ src/inst/text_section.cc (revision 191) @@ -36,14 +36,14 @@ // -------------------------------------------------------------------------- - void + bool TextSection::define_label(const misc::unique_string &id) { TextLabel *label = new TextLabel(id, sentry_); label->set_offset((insts_.size() - 1) * 4); labels_.push_back(label); - Section::register_label(label); + return Section::register_label(label); } // -------------------------------------------------------------------------- Index: src/inst/section.hh --- src/inst/section.hh (revision 190) +++ src/inst/section.hh (revision 191) @@ -40,15 +40,13 @@ Section(const std::string &name): name_(name) {} - virtual ~Section() - {} + virtual ~Section(); protected: - void register_label(Label *label) - { - // FIXME: check that this label has not already been added. - sorted_labels_.insert(label); - } + /** Return false if the label already exists in this section, true + otherwise */ + bool register_label(Label *label); + public: bool has_label(const misc::unique_string &label) const { Index: src/inst/text_section.hh --- src/inst/text_section.hh (revision 190) +++ src/inst/text_section.hh (revision 191) @@ -60,7 +60,7 @@ } public: - void define_label(const misc::unique_string &id); + bool define_label(const misc::unique_string &id); public: void add_inst(inst::Inst* inst) Index: src/inst/Makefile.am --- src/inst/Makefile.am (revision 190) +++ src/inst/Makefile.am (revision 191) @@ -58,7 +58,7 @@ program.hh \ label.hh label.cc \ text_label.hh \ - section.hh \ + section.hh section.cc \ text_section.hh text_section.cc \ data_section.hh data_section.cc \ program.hh \ Index: src/inst/program_builder.hh.gen.py --- src/inst/program_builder.hh.gen.py (revision 190) +++ src/inst/program_builder.hh.gen.py (revision 191) @@ -87,12 +87,22 @@ public: void define_inst_label(const misc::unique_string &id) { - program_->text_section ().define_label(id); + if (!program_->text_section ().define_label(id)) + { + std::cerr << \"Instruction label already defined in this section.\" + << std::endl; + exit_set(exit_solve); + } } void define_data_label(const misc::unique_string &id) { - program_->data_section ().define_label(id); + if (!program_->data_section ().define_label(id)) + { + std::cerr << \"Data label already defined in this section.\" + << std::endl; + exit_set(exit_solve); + } } public: Index: tests/solve/data-label-already-defined.s --- tests/solve/data-label-already-defined.s (revision 0) +++ tests/solve/data-label-already-defined.s (revision 191) @@ -0,0 +1,12 @@ + .data +foo: + .asciiz "bar" +foo: + .asciiz "baz" + + + .text +main: + li $a0, 0 + li $v0, 10 + syscall Index: tests/solve/Makefile.am --- tests/solve/Makefile.am (revision 190) +++ tests/solve/Makefile.am (revision 191) @@ -1,7 +1,9 @@ ### Sources ASM_FILES = \ undefined-labels.s \ - unlimited-regs.s + unlimited-regs.s \ + data-label-already-defined.s \ + text-label-already-defined.s dist_noinst_DATA = $(ASM_FILES) Index: tests/solve/text-label-already-defined.s --- tests/solve/text-label-already-defined.s (revision 0) +++ tests/solve/text-label-already-defined.s (revision 191) @@ -0,0 +1,7 @@ + .text +main: + li $a0, 0 +foo: + li $v0, 10 +foo: + syscall
19 years, 3 months
1
0
0
0
[nolimips: 190] Play with unique_string
by Noe
https://svn.lrde.epita.fr/svn/nolimips/trunk
ChangeLog | 14 +++++++++++++- src/misc/unique_string.cc | 16 ++++++---------- src/misc/unique_string.hh | 39 +++++++++++++++++++-------------------- src/parse/asm-scan.ll.gen.py | 5 ++--- 4 files changed, 40 insertions(+), 34 deletions(-) Index: ChangeLog from Benoît Perrot <benoit(a)lrde.epita.fr> * src/misc/unique_string.hh, src/misc/unique_string.cc: Introduce a constructor from a const char*. Factor string insertion in pool. Suggested by Akim Demaille: Use a set of strings instead of a set of pointers as internal pool. Compose an iterator instead of a pointer. * src/parse/asm-scan.ll.gen.py: Suggested by Akim Demaille: Don't be affraid to side-affect yytext. hence make unique_string compose a pointer-to-string instead of a Index: src/misc/unique_string.cc --- src/misc/unique_string.cc (revision 189) +++ src/misc/unique_string.cc (revision 190) @@ -25,17 +25,13 @@ unique_string::string_to_unique_type unique_string::pool_; - unique_string::unique_string(const std::string &str) + unique_string::string_to_unique_type::const_iterator + unique_string::insert_in_pool(const std::string &str) { - unique_string::string_to_unique_type::iterator it = pool_.find(&str); - if (it == pool_.end() || (*it)->compare(str)) - { - std::string *s = new std::string(str); - it = pool_.insert(it, s); - } - - str_ = *it; - assertion(str_); + string_to_unique_type::const_iterator it(pool_.find(str)); + if (it == pool_.end() || it->compare(str)) + it = pool_.insert(it, str); + return it; } } // namespace misc Index: src/misc/unique_string.hh --- src/misc/unique_string.hh (revision 189) +++ src/misc/unique_string.hh (revision 190) @@ -35,34 +35,30 @@ class unique_string { private: - struct string_ptr_less: - public std::binary_function<const std::string*, const std::string*, bool> - { - bool operator()(const std::string* s1, const std::string* s2) const - { - return *s1 < *s2; - } - }; - - typedef std::set<const std::string*, - string_ptr_less> string_to_unique_type; + typedef std::set<std::string> string_to_unique_type; public: - unique_string(const std::string &str); + unique_string(const std::string &str): + it_(insert_in_pool(str)) + {} + + unique_string(const char *str): + it_(insert_in_pool(std::string(str))) + {} // Accessors public: const std::string &get() const { - return *str_; + return *it_; } operator const std::string &() const { - return *str_; + return *it_; } const std::string & operator* () const { - return *str_; + return *it_; } static unsigned pool_size() @@ -74,25 +70,28 @@ public: bool operator==(const unique_string &rhs) const { - return str_ == rhs.str_; + return it_ == rhs.it_; } bool operator!=(const unique_string &rhs) const { - return str_ != rhs.str_; + return it_ != rhs.it_; } bool operator<(const unique_string &rhs) const { - if (str_ == rhs.str_) + if (it_ == rhs.it_) return false; - return *str_ < *(rhs.str_); + return *it_ < *rhs.it_; } private: + static string_to_unique_type::const_iterator insert_in_pool(const std::string &str); + + private: static string_to_unique_type pool_; private: - const std::string *str_; + const string_to_unique_type::const_iterator it_; }; inline std::ostream & Index: src/parse/asm-scan.ll.gen.py --- src/parse/asm-scan.ll.gen.py (revision 189) +++ src/parse/asm-scan.ll.gen.py (revision 190) @@ -149,9 +149,8 @@ return LABEL; } {id}\":\" { - std::string label(yytext); - label.resize(yyleng - 1); - yylval->id = new misc::unique_string(label); + yytext[yyleng - 1] = 0; // Remove last character (side-effects on yytext are allowed) + yylval->id = new misc::unique_string(yytext); return LABEL_DEF; }
19 years, 3 months
1
0
0
0
[nolimips: 188] Simplify unique_string construction
by Noe
https://svn.lrde.epita.fr/svn/nolimips/trunk
ChangeLog | 14 ++++++++++++++ src/inst/label.hh | 6 +++--- src/inst/label_exp.hh | 2 +- src/inst/section.hh | 4 ++-- src/misc/test-unique_string.cc | 6 +++--- src/misc/unique_string.cc | 13 +++++++------ src/misc/unique_string.hh | 29 +++++++++++++---------------- src/parse/asm-parse.yy.gen.py | 5 ++++- src/parse/asm-scan.ll.gen.py | 6 +++--- src/shell/shell.cc | 3 +-- src/vm/virtual_machine.cc | 2 +- 11 files changed, 52 insertions(+), 38 deletions(-) Index: ChangeLog from Benoît Perrot <benoit(a)lrde.epita.fr> Simplify unique_string construction. * src/misc/unique_string.hh, src/misc/unique_string.cc (create): Remove. Move its implementation to unique_string's constructor, hence make unique_string aggregate a pointer-to-string instead of a reference. * src/misc/test-unique_string.cc, src/vm/virtual_machine.cc, * src/shell/shell.cc, src/parse/asm-parse.yy.gen.py, * src/parse/asm-scan.ll.gen.py, src/inst/label_exp.hh, * src/inst/section.hh, src/inst/label.hh: Adjust. Index: src/vm/virtual_machine.cc --- src/vm/virtual_machine.cc (revision 187) +++ src/vm/virtual_machine.cc (revision 188) @@ -35,7 +35,7 @@ { reset(); - const misc::unique_string &main = misc::unique_string::create("main"); + misc::unique_string main("main"); if (! program.text_section ().has_label(main)) { std::cerr << "No `main' label in assembly file." << std::endl; Index: src/misc/unique_string.cc --- src/misc/unique_string.cc (revision 187) +++ src/misc/unique_string.cc (revision 188) @@ -18,23 +18,24 @@ // #include "misc/unique_string.hh" +#include "misc/contract.hh" namespace misc { unique_string::string_to_unique_type unique_string::pool_; - const unique_string & - unique_string::create(const std::string &str) + unique_string::unique_string(const std::string &str) { unique_string::string_to_unique_type::iterator it = pool_.find(&str); - if (it == pool_.end() || it->first->compare(str)) + if (it == pool_.end() || (*it)->compare(str)) { std::string *s = new std::string(str); - it = pool_.insert(it, unique_string::string_to_unique_type:: - value_type(s, unique_string(*s))); + it = pool_.insert(it, s); } - return it->second; + + str_ = *it; + assertion(str_); } } // namespace misc Index: src/misc/unique_string.hh --- src/misc/unique_string.hh (revision 187) +++ src/misc/unique_string.hh (revision 188) @@ -26,7 +26,7 @@ the implementation is quite different. */ #include <string> -#include <map> +#include <set> #include <iostream> namespace misc @@ -44,32 +44,28 @@ } }; - typedef std::map<const std::string*, unique_string, + typedef std::set<const std::string*, string_ptr_less> string_to_unique_type; - private: - unique_string(const std::string &str): - str_(str) - {} public: - static const unique_string &create(const std::string &str); + unique_string(const std::string &str); // Accessors public: const std::string &get() const { - return str_; + return *str_; } operator const std::string &() const { - return str_; + return *str_; } const std::string & operator* () const { - return str_; + return *str_; } - static unsigned pool_size() + static unsigned pool_size() const { return pool_.size(); } @@ -78,24 +74,25 @@ public: bool operator==(const unique_string &rhs) const { - return &str_ == &rhs.str_; + return str_ == rhs.str_; } bool operator!=(const unique_string &rhs) const { - return &str_ != &rhs.str_; + return str_ != rhs.str_; } bool operator<(const unique_string &rhs) const { - if (&str_ == &rhs.str_) + if (str_ == rhs.str_) return false; - return str_ < rhs.str_; + + return *str_ < *(rhs.str_); } private: static string_to_unique_type pool_; private: - const std::string &str_; + const std::string *str_; }; inline std::ostream & Index: src/misc/test-unique_string.cc --- src/misc/test-unique_string.cc (revision 187) +++ src/misc/test-unique_string.cc (revision 188) @@ -22,9 +22,9 @@ int main() { - const misc::unique_string &foo0 = misc::unique_string::create("foo"); - const misc::unique_string &foo1 = misc::unique_string::create("foo"); - const misc::unique_string &bar = misc::unique_string::create("bar"); + misc::unique_string foo0("foo"); + misc::unique_string foo1("foo"); + misc::unique_string bar("bar"); assertion(misc::unique_string::pool_size() == 2); assertion(*foo0 == "foo"); Index: src/shell/shell.cc --- src/shell/shell.cc (revision 187) +++ src/shell/shell.cc (revision 188) @@ -470,8 +470,7 @@ std::cerr << "No program loaded." << std::endl; else { - const misc::unique_string &label = - misc::unique_string::create(*cmd.get_args().begin()); + misc::unique_string label(*cmd.get_args().begin()); if (!program_->text_section().has_label(label)) std::cerr << "Label " << label Index: src/parse/asm-parse.yy.gen.py --- src/parse/asm-parse.yy.gen.py (revision 187) +++ src/parse/asm-parse.yy.gen.py (revision 188) @@ -75,7 +75,7 @@ { int i; std::string *s; - const misc::unique_string *id; + misc::unique_string *id; inst::Label *label; inst::Register *reg; inst::Exp *exp; @@ -92,6 +92,9 @@ %destructor { delete $$; } \"string\" +%destructor { delete $$; } \"label\" +%destructor { delete $$; } \"label definition\" + %printer { debug_stream () << *$$; } \"string\" \"register\" %printer { debug_stream () << $$; } \"integer\" Index: src/parse/asm-scan.ll.gen.py --- src/parse/asm-scan.ll.gen.py (revision 187) +++ src/parse/asm-scan.ll.gen.py (revision 188) @@ -145,13 +145,13 @@ {id} { - yylval->id = &misc::unique_string::create(yytext); + yylval->id = new misc::unique_string(yytext); return LABEL; } {id}\":\" { - std::string label = yytext; + std::string label(yytext); label.resize(yyleng - 1); - yylval->id = &misc::unique_string::create(label); + yylval->id = new misc::unique_string(label); return LABEL_DEF; } Index: src/inst/label_exp.hh --- src/inst/label_exp.hh (revision 187) +++ src/inst/label_exp.hh (revision 188) @@ -49,7 +49,7 @@ virtual void print(std::ostream& ostr) const; protected: - const misc::unique_string &name_; + const misc::unique_string name_; }; } // namespace inst Index: src/inst/section.hh --- src/inst/section.hh (revision 187) +++ src/inst/section.hh (revision 188) @@ -38,7 +38,7 @@ public: /// Construct an abstract section `\a name' Section(const std::string &name): - name_(misc::unique_string::create(name)) + name_(name) {} virtual ~Section() {} @@ -70,7 +70,7 @@ virtual void print(std::ostream& ostr) const = 0; protected: - const misc::unique_string &name_; + const misc::unique_string name_; label_set_type sorted_labels_; }; Index: src/inst/label.hh --- src/inst/label.hh (revision 187) +++ src/inst/label.hh (revision 188) @@ -45,11 +45,11 @@ protected: Label(const std::string &s): - ustr_(misc::unique_string::create(s)) + ustr_(s) {} public: Label(const std::string &s, int offset): - ustr_(misc::unique_string::create(s)), offset_(offset) + ustr_(s), offset_(offset) { lock(); } @@ -81,7 +81,7 @@ } protected: - const misc::unique_string &ustr_; + const misc::unique_string ustr_; int offset_; };
19 years, 3 months
2
2
0
0
[nolimips: 189] Ooooooopps
by Noe
Revert stupid last minute change. I really should alias svncommit to "make check && svn commit"
https://svn.lrde.epita.fr/svn/nolimips/trunk
ChangeLog | 7 +++++++ src/misc/unique_string.hh | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) Index: ChangeLog from Benoît Perrot <benoit(a)lrde.epita.fr> Shame on me. * src/misc/unique_string.hh: Fix error: static member function cannot have const qualifier. 2005-09-01 Benoît Perrot <benoit(a)lrde.epita.fr> Index: src/misc/unique_string.hh --- src/misc/unique_string.hh (revision 188) +++ src/misc/unique_string.hh (revision 189) @@ -65,7 +65,7 @@ return *str_; } - static unsigned pool_size() const + static unsigned pool_size() { return pool_.size(); }
19 years, 3 months
1
0
0
0
← Newer
1
2
3
4
5
6
Older →
Jump to page:
1
2
3
4
5
6
Results per page:
10
25
50
100
200