[pure-lang-svn] SF.net SVN: pure-lang:[683] pure/trunk
Status: Beta
Brought to you by:
agraef
|
From: <ag...@us...> - 2008-09-01 16:23:21
|
Revision: 683
http://pure-lang.svn.sourceforge.net/pure-lang/?rev=683&view=rev
Author: agraef
Date: 2008-09-01 16:23:30 +0000 (Mon, 01 Sep 2008)
Log Message:
-----------
Add thunkp predicate.
Modified Paths:
--------------
pure/trunk/lib/primitives.pure
pure/trunk/runtime.cc
pure/trunk/runtime.h
Modified: pure/trunk/lib/primitives.pure
===================================================================
--- pure/trunk/lib/primitives.pure 2008-09-01 16:09:44 UTC (rev 682)
+++ pure/trunk/lib/primitives.pure 2008-09-01 16:23:30 UTC (rev 683)
@@ -45,7 +45,8 @@
/* Predicates to check for function objects, global (unbound) variables,
function applications, proper lists, list nodes and tuples. */
-extern bool funp(expr*), bool lambdap(expr*), bool varp(expr*);
+extern bool funp(expr*), bool lambdap(expr*), bool thunkp(expr*);
+extern bool varp(expr*);
applp (_ _) = 1;
applp _ = 0 otherwise;
Modified: pure/trunk/runtime.cc
===================================================================
--- pure/trunk/runtime.cc 2008-09-01 16:09:44 UTC (rev 682)
+++ pure/trunk/runtime.cc 2008-09-01 16:23:30 UTC (rev 683)
@@ -2673,10 +2673,16 @@
extern "C"
bool lambdap(const pure_expr *x)
{
- return (x->tag == 0 && x->data.clos);
+ return (x->tag == 0 && x->data.clos && x->data.clos->n > 0);
}
extern "C"
+bool thunkp(const pure_expr *x)
+{
+ return (x->tag == 0 && x->data.clos && x->data.clos->n == 0);
+}
+
+extern "C"
bool varp(const pure_expr *x)
{
return (x->tag > 0 && !x->data.clos);
Modified: pure/trunk/runtime.h
===================================================================
--- pure/trunk/runtime.h 2008-09-01 16:09:44 UTC (rev 682)
+++ pure/trunk/runtime.h 2008-09-01 16:23:30 UTC (rev 683)
@@ -552,10 +552,11 @@
bool same(pure_expr *x, pure_expr *y);
/* Check whether an object is a named function (closure), an anonymous
- function (lambda), or a global variable, respectively. */
+ function (lambda or thunk), or a global variable, respectively. */
bool funp(const pure_expr *x);
bool lambdap(const pure_expr *x);
+bool thunkp(const pure_expr *x);
bool varp(const pure_expr *x);
/* Direct memory accesses. Use these with care. In particular, note that the
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|