|
|
@ -4,6 +4,8 @@
|
|
|
|
#include <cassert>
|
|
|
|
#include <cassert>
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <algorithm>
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
#include <ostream>
|
|
|
|
|
|
|
|
#include <iterator>
|
|
|
|
|
|
|
|
|
|
|
|
namespace Compiler
|
|
|
|
namespace Compiler
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -52,6 +54,21 @@ namespace Compiler
|
|
|
|
return ' ';
|
|
|
|
return ' ';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Locals::write (std::ostream& localFile) const
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
localFile
|
|
|
|
|
|
|
|
<< get ('s').size() << ' '
|
|
|
|
|
|
|
|
<< get ('l').size() << ' '
|
|
|
|
|
|
|
|
<< get ('f').size() << std::endl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::copy (get ('s').begin(), get ('s').end(),
|
|
|
|
|
|
|
|
std::ostream_iterator<std::string> (localFile, " "));
|
|
|
|
|
|
|
|
std::copy (get ('l').begin(), get ('l').end(),
|
|
|
|
|
|
|
|
std::ostream_iterator<std::string> (localFile, " "));
|
|
|
|
|
|
|
|
std::copy (get ('f').begin(), get ('f').end(),
|
|
|
|
|
|
|
|
std::ostream_iterator<std::string> (localFile, " "));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Locals::declare (char type, const std::string& name)
|
|
|
|
void Locals::declare (char type, const std::string& name)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
get (type).push_back (name);
|
|
|
|
get (type).push_back (name);
|
|
|
|