summaryrefslogtreecommitdiff
path: root/src/expr
diff options
context:
space:
mode:
Diffstat (limited to 'src/expr')
-rw-r--r--src/expr/declaration_scope.cpp36
-rw-r--r--src/expr/declaration_scope.h14
2 files changed, 36 insertions, 14 deletions
diff --git a/src/expr/declaration_scope.cpp b/src/expr/declaration_scope.cpp
index 22187ad06..6038fadab 100644
--- a/src/expr/declaration_scope.cpp
+++ b/src/expr/declaration_scope.cpp
@@ -49,17 +49,25 @@ DeclarationScope::~DeclarationScope() {
delete d_context;
}
-void DeclarationScope::bind(const std::string& name, Expr obj) throw(AssertionException) {
+void DeclarationScope::bind(const std::string& name, Expr obj,
+ bool levelZero) throw(AssertionException) {
CheckArgument(!obj.isNull(), obj, "cannot bind to a null Expr");
ExprManagerScope ems(obj);
- d_exprMap->insert(name, obj);
+ if(levelZero) d_exprMap->insertAtContextLevelZero(name, obj);
+ else d_exprMap->insert(name, obj);
}
-void DeclarationScope::bindDefinedFunction(const std::string& name, Expr obj) throw(AssertionException) {
+void DeclarationScope::bindDefinedFunction(const std::string& name, Expr obj,
+ bool levelZero) throw(AssertionException) {
CheckArgument(!obj.isNull(), obj, "cannot bind to a null Expr");
ExprManagerScope ems(obj);
- d_exprMap->insert(name, obj);
- d_functions->insert(obj);
+ if(levelZero){
+ d_exprMap->insertAtContextLevelZero(name, obj);
+ d_functions->insertAtContextLevelZero(obj);
+ } else {
+ d_exprMap->insert(name, obj);
+ d_functions->insert(obj);
+ }
}
bool DeclarationScope::isBound(const std::string& name) const throw() {
@@ -80,13 +88,19 @@ Expr DeclarationScope::lookup(const std::string& name) const throw(AssertionExce
return (*d_exprMap->find(name)).second;
}
-void DeclarationScope::bindType(const std::string& name, Type t) throw() {
- d_typeMap->insert(name, make_pair(vector<Type>(), t));
+void DeclarationScope::bindType(const std::string& name, Type t,
+ bool levelZero) throw() {
+ if(levelZero){
+ d_typeMap->insertAtContextLevelZero(name, make_pair(vector<Type>(), t));
+ }else{
+ d_typeMap->insert(name, make_pair(vector<Type>(), t));
+ }
}
void DeclarationScope::bindType(const std::string& name,
const std::vector<Type>& params,
- Type t) throw() {
+ Type t,
+ bool levelZero) throw() {
if(Debug.isOn("sort")) {
Debug("sort") << "bindType(" << name << ", [";
if(params.size() > 0) {
@@ -96,7 +110,11 @@ void DeclarationScope::bindType(const std::string& name,
}
Debug("sort") << "], " << t << ")" << endl;
}
- d_typeMap->insert(name, make_pair(params, t));
+ if(levelZero){
+ d_typeMap->insertAtContextLevelZero(name, make_pair(params, t));
+ } else {
+ d_typeMap->insert(name, make_pair(params, t));
+ }
}
bool DeclarationScope::isBoundType(const std::string& name) const throw() {
diff --git a/src/expr/declaration_scope.h b/src/expr/declaration_scope.h
index 27533cca8..8695d9287 100644
--- a/src/expr/declaration_scope.h
+++ b/src/expr/declaration_scope.h
@@ -72,12 +72,14 @@ public:
* <code>name</code> is already bound to an expression in the current
* level, then the binding is replaced. If <code>name</code> is bound
* in a previous level, then the binding is "covered" by this one
- * until the current scope is popped.
+ * until the current scope is popped. If levelZero is true the name
+ * shouldn't be already bound.
*
* @param name an identifier
* @param obj the expression to bind to <code>name</code>
+ * @param levelZero set if the binding must be done at level 0
*/
- void bind(const std::string& name, Expr obj) throw(AssertionException);
+ void bind(const std::string& name, Expr obj, bool levelZero = false) throw(AssertionException);
/**
* Bind a function body to a name in the current scope. If
@@ -89,8 +91,9 @@ public:
*
* @param name an identifier
* @param obj the expression to bind to <code>name</code>
+ * @param levelZero set if the binding must be done at level 0
*/
- void bindDefinedFunction(const std::string& name, Expr obj) throw(AssertionException);
+ void bindDefinedFunction(const std::string& name, Expr obj, bool levelZero = false) throw(AssertionException);
/**
* Bind a type to a name in the current scope. If <code>name</code>
@@ -101,8 +104,9 @@ public:
*
* @param name an identifier
* @param t the type to bind to <code>name</code>
+ * @param levelZero set if the binding must be done at level 0
*/
- void bindType(const std::string& name, Type t) throw();
+ void bindType(const std::string& name, Type t, bool levelZero = false) throw();
/**
* Bind a type to a name in the current scope. If <code>name</code>
@@ -117,7 +121,7 @@ public:
*/
void bindType(const std::string& name,
const std::vector<Type>& params,
- Type t) throw();
+ Type t, bool levelZero = false) throw();
/**
* Check whether a name is bound to an expression with either bind()
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback