[pure-lang-svn] SF.net SVN: pure-lang:[454] pure/trunk
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-08-09 10:44:16
|
Revision: 454 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=454&view=rev Author: agraef Date: 2008-08-09 10:44:26 +0000 (Sat, 09 Aug 2008) Log Message: ----------- Bugfixes in FMap code. Modified Paths: -------------- pure/trunk/interpreter.cc pure/trunk/interpreter.hh Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-08-08 08:53:33 UTC (rev 453) +++ pure/trunk/interpreter.cc 2008-08-09 10:44:26 UTC (rev 454) @@ -1955,6 +1955,20 @@ idx = 0; lastidx = -1; } +void FMap::first() +{ + idx = 0; lastidx = -1; + // reset child environments + set<Env*> e; + for (size_t i = 0, n = m.size(); i < n; i++) + for (EnvMap::iterator it = m[i]->begin(), end = m[i]->end(); + it != end; it++) + e.insert(it->second); + for (set<Env*>::iterator it = e.begin(), end = e.end(); + it != end; it++) + (*it)->fmap.first(); +} + void FMap::next() { assert(pred[idx] < 0); @@ -2000,7 +2014,7 @@ } } else if (++idx >= (int32_t)m.size()) { // the first child always immediately follows its parent - assert(idx == m.size()); + assert(idx == (int32_t)m.size()); m.resize(idx+1); pred.resize(idx+1); succ.resize(idx+1); pred[idx] = idx-1; succ[idx] = -1; m[idx] = new EnvMap(*m[idx-1]); @@ -2212,7 +2226,7 @@ assert(ei != envstk.end()); fenv = *ei++; } - assert(fenv->act_fmap().find(x.vtag()) != fenv->act_fmap().end()); + assert(fenv->fmap.act().find(x.vtag()) != fenv->fmap.act().end()); fenv = fenv->fmap.act()[x.vtag()]; if (!fenv->local) break; // fenv now points to the environment of the (local) function @@ -2369,13 +2383,12 @@ // build the maps for a global function definition assert(info.t == env_info::fun); // we need a separate submap for each rule - rulel::const_iterator r = info.rules->begin(); - while (r != info.rules->end()) { + rulel::const_iterator r = info.rules->begin(), end = info.rules->end(); + while (r != end) { build_map(r->rhs); if (!r->qual.is_null()) build_map(r->qual); - r++; fmap.next(); + if (++r != end) fmap.next(); } - fmap.first(); #if DEBUG>1 if (!local) print_map(std::cerr, this); #endif @@ -5137,11 +5150,11 @@ Env& f = act_env(); assert(s->tr.empty()); // we're in a final state here const rulev& rules = pm->r; - assert(f.fmap.size() == 1 || f.fmap.size() == rules.size()); + assert(f.fmap.root.size() == 1 || f.fmap.root.size() == rules.size()); const ruleml& rl = s->r; ruleml::const_iterator r = rl.begin(); assert(r != rl.end()); - assert(f.fmap_idx == 0); + assert(f.fmap.idx == 0); BasicBlock* rulebb = BasicBlock::Create(mklabel("rule.state", s->s, rl.front())); f.builder.CreateBr(rulebb); while (r != rl.end()) { Modified: pure/trunk/interpreter.hh =================================================================== --- pure/trunk/interpreter.hh 2008-08-08 08:53:33 UTC (rev 453) +++ pure/trunk/interpreter.hh 2008-08-09 10:44:26 UTC (rev 454) @@ -125,7 +125,7 @@ // clear void clear(); // set index to first, next and given root node - void first() { idx = 0; lastidx = -1; } + void first(); void next(); void select(size_t n); // set index to the parent or next child of the current node @@ -219,6 +219,7 @@ assert(local); parent = envstk.front(); } + fmap.first(); } // environment for a named closure with given definition info Env(int32_t _tag, const env_info& info, bool _b, bool _local = false) @@ -233,6 +234,7 @@ assert(local); parent = envstk.front(); } + fmap.first(); } // assignment -- this is only allowed if the lvalue is an uninitialized // environment for which no LLVM function has been created yet, or if it is This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |