aboutsummaryrefslogtreecommitdiff
path: root/src/rt/vm.cc
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2014-11-16 20:32:55 +0000
committerdos-reis <gdr@axiomatics.org>2014-11-16 20:32:55 +0000
commit452696064e43c23f2a44edcded311f3d7b466d7e (patch)
tree375ea3690ca7ea469675313cae728a670dd26b09 /src/rt/vm.cc
parent564aff97f80abac84be64552f5238903cb126c33 (diff)
downloadopen-axiom-452696064e43c23f2a44edcded311f3d7b466d7e.tar.gz
Check for LLVM framework
Diffstat (limited to 'src/rt/vm.cc')
-rw-r--r--src/rt/vm.cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/rt/vm.cc b/src/rt/vm.cc
index 7f5cd5fc..4cedc030 100644
--- a/src/rt/vm.cc
+++ b/src/rt/vm.cc
@@ -33,6 +33,9 @@
// --% Author: Gabriel Dos Reis
#include <open-axiom/vm>
+#include <iterator>
+#include <algorithm>
+#include <ostream>
namespace OpenAxiom {
namespace VM {
@@ -46,6 +49,15 @@ namespace OpenAxiom {
p->symbol->value = p->value;
}
+ Environment::Binding*
+ Environment::lookup(InternedString name) {
+ for (auto& b : lexical) {
+ if (b.symbol->name == name)
+ return &b;
+ }
+ return nullptr;
+ }
+
// -- Dynamic
Dynamic::~Dynamic() { }
@@ -59,11 +71,24 @@ namespace OpenAxiom {
attributes()
{ }
+ void Symbol::format_on(std::ostream& os) const {
+ // FIXME: handle escapes.
+ std::copy(name->begin(), name->end(),
+ std::ostream_iterator<char>(os));
+ }
+
// -- Package
Package::Package(InternedString s)
: name(s)
{ }
+ void Package::format_on(std::ostream& os) const {
+ os << "#<PACKAGE \"";
+ std::copy(name->begin(), name->end(),
+ std::ostream_iterator<char>(os));
+ os << '"' << '>';
+ }
+
Symbol*
Package::make_symbol(InternedString s) {
auto sym = const_cast<Symbol*>(&*symbols.insert(Symbol(s)).first);
@@ -71,6 +96,19 @@ namespace OpenAxiom {
return sym;
}
+ Symbol*
+ Package::find_symbol(InternedString s) {
+ auto p = symbols.find(Symbol(s));
+ return p == symbols.end() ? nullptr : const_cast<Symbol*>(&*p);
+ }
+
+ // -- FunctionBase
+ void FunctionBase::format_on(std::ostream& os) const {
+ os << "#<FUNCTION ";
+ name->format_on(os);
+ os << '>';
+ }
+
Fixnum
count_nodes(Pair p) {
FixnumBits n = 1;