diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-16 06:00:12 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-16 06:00:12 +0000 |
commit | ec5f59dac8d5eca3504ec5fe205dcb7d8fd382a6 (patch) | |
tree | 41edf192475639ca342a84efc3e1d94bf0a65672 /cpp/sca/kernel/value.hpp | |
parent | 24842067f999efb5e62f1dd3cde017df1381c0a3 (diff) |
Fixed support for nested elements and lists. Improved failure/error reporting monad. Minor code cleanup.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@880598 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/sca/kernel/value.hpp')
-rw-r--r-- | cpp/sca/kernel/value.hpp | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/cpp/sca/kernel/value.hpp b/cpp/sca/kernel/value.hpp index 618bd7b622..d602b30623 100644 --- a/cpp/sca/kernel/value.hpp +++ b/cpp/sca/kernel/value.hpp @@ -362,7 +362,9 @@ private: }; - +/** + * Write a value to a stream. + */ std::ostream& operator<<(std::ostream& out, const value& v) { switch(v.type) { case value::List: @@ -399,46 +401,86 @@ std::ostream& operator<<(std::ostream& out, const value& v) { } } +/** + * Returns the type of a value. + */ const value::ValueType type(const value& v) { return v.type; } +/** + * Returns true if a value is nil. + */ const bool isNil(const value& value) { return value.type == value::Undefined; } +/** + * Returns true if a value is a lambda. + */ +const bool isLambda(const value& value) { + return value.type == value::Lambda; +} + +/** + * Returns true if a value is a string. + */ const bool isString(const value& value) { return value.type == value::String; } +/** + * Returns true if a value is a symbol. + */ const bool isSymbol(const value& value) { return value.type == value::Symbol; } +/** + * Returns true if a value is a list. + */ const bool isList(const value& value) { return value.type == value::List; } +/** + * Returns true if a value is a number. + */ const bool isNumber(const value& value) { return value.type == value::Number; } +/** + * Returns true if a value is a boolean. + */ const bool isBool(const value& value) { return value.type == value::Bool; } +/** + * Returns true if a value is a character. + */ const bool isChar(const value& value) { return value.type == value::Char; } +/** + * Returns true if a value is a pointer. + */ const bool isPtr(const value& value) { return value.type == value::Ptr; } +/** + * Returns true if a value is a pooled pointer. + */ const bool isPoolPtr(const value& value) { return value.type == value::PoolPtr; } +/** + * Returns true if a value is a tagged list. + */ const bool isTaggedList(const value& exp, value tag) { if(isList(exp) && !isNil((list<value>)exp)) return car((list<value>)exp) == tag; |