From 452696064e43c23f2a44edcded311f3d7b466d7e Mon Sep 17 00:00:00 2001 From: dos-reis Date: Sun, 16 Nov 2014 20:32:55 +0000 Subject: Check for LLVM framework --- src/rt/vm.cc | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/rt/vm.cc') 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 +#include +#include +#include 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(os)); + } + // -- Package Package::Package(InternedString s) : name(s) { } + void Package::format_on(std::ostream& os) const { + os << "#begin(), name->end(), + std::ostream_iterator(os)); + os << '"' << '>'; + } + Symbol* Package::make_symbol(InternedString s) { auto sym = const_cast(&*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(&*p); + } + + // -- FunctionBase + void FunctionBase::format_on(std::ostream& os) const { + os << "#format_on(os); + os << '>'; + } + Fixnum count_nodes(Pair p) { FixnumBits n = 1; -- cgit v1.2.3