[pure-lang-svn] SF.net SVN: pure-lang:[672] pure/trunk
Status: Beta
Brought to you by:
agraef
|
From: <ag...@us...> - 2008-08-31 00:15:55
|
Revision: 672
http://pure-lang.svn.sourceforge.net/pure-lang/?rev=672&view=rev
Author: agraef
Date: 2008-08-31 00:16:06 +0000 (Sun, 31 Aug 2008)
Log Message:
-----------
Add expression pointer operations.
Modified Paths:
--------------
pure/trunk/runtime.cc
pure/trunk/runtime.h
Modified: pure/trunk/runtime.cc
===================================================================
--- pure/trunk/runtime.cc 2008-08-30 21:31:04 UTC (rev 671)
+++ pure/trunk/runtime.cc 2008-08-31 00:16:06 UTC (rev 672)
@@ -447,6 +447,17 @@
}
extern "C"
+pure_expr *pure_expr_pointer(void)
+{
+ pure_expr **p = (pure_expr**)malloc(sizeof(pure_expr*));
+ if (p) {
+ *p = 0;
+ return pure_pointer(p);
+ } else
+ return 0;
+}
+
+extern "C"
pure_expr *pure_string_dup(const char *s)
{
if (!s) return pure_pointer(0);
Modified: pure/trunk/runtime.h
===================================================================
--- pure/trunk/runtime.h 2008-08-30 21:31:04 UTC (rev 671)
+++ pure/trunk/runtime.h 2008-08-31 00:16:06 UTC (rev 672)
@@ -97,6 +97,12 @@
pure_expr *pure_double(double d);
pure_expr *pure_pointer(void *p);
+/* Expression pointers. The following routine returns a Pure pointer object
+ suitably allocated to hold a Pure expression (pure_expr*). The pointer is
+ initialized to hold a null expression. */
+
+pure_expr *pure_expr_pointer(void);
+
/* String constructors. There are four variations of these, depending on
whether the original string is already in utf-8 (_string routines) or in
the system encoding (_cstring), and whether the string should be copied
@@ -546,7 +552,9 @@
bool lambdap(const pure_expr *x);
bool varp(const pure_expr *x);
-/* Direct memory accesses. */
+/* Direct memory accesses. Use these with care. In particular, note that the
+ pointer_put_expr() routine doesn't do any reference counting by itself, so
+ you'll have to use the memory management routines above to do that. */
int32_t pointer_get_byte(void *ptr);
int32_t pointer_get_int(void *ptr);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|