[svn:parrot] r46870 - in branches/ops_pct: docs/pdds docs/pdds/draft examples/io include/parrot runtime/parrot/library src src/string t t/library

bacek at svn.parrot.org bacek at svn.parrot.org
Sat May 22 01:52:56 UTC 2010


Author: bacek
Date: Sat May 22 01:52:55 2010
New Revision: 46870
URL: https://trac.parrot.org/parrot/changeset/46870

Log:
Merge branch 'master' into ops_pct_local

Added:
   branches/ops_pct/examples/io/get.pir
   branches/ops_pct/examples/io/post.pir
Modified:
   branches/ops_pct/docs/pdds/draft/pdd31_hll.pod
   branches/ops_pct/docs/pdds/pdd13_bytecode.pod
   branches/ops_pct/include/parrot/compiler.h
   branches/ops_pct/include/parrot/hash.h
   branches/ops_pct/runtime/parrot/library/URI.pir
   branches/ops_pct/runtime/parrot/library/distutils.pir
   branches/ops_pct/src/hash.c
   branches/ops_pct/src/string/charset.c
   branches/ops_pct/t/harness.pir
   branches/ops_pct/t/library/uri.t

Modified: branches/ops_pct/docs/pdds/draft/pdd31_hll.pod
==============================================================================
--- branches/ops_pct/docs/pdds/draft/pdd31_hll.pod	Fri May 21 20:50:55 2010	(r46869)
+++ branches/ops_pct/docs/pdds/draft/pdd31_hll.pod	Sat May 22 01:52:55 2010	(r46870)
@@ -77,11 +77,11 @@
 
 =item C<eval>
 
-    $P0 = compiler.'eval'(source [, options :named :slurpy])
+    $P0 = compiler.'eval'(source [, args :slurpy] [, options :named :slurpy])
 
 Compile and evaluate (execute) the code given by C<source>
-according to C<options>.  The available options are generally
-the same as for the C<compile> method above; in particular,
+with C<args> and according to C<options>.  The available options 
+are generally the same as for the C<compile> method above; in particular,
 the C<outer_ctx> option can be used to specify the outer lexical
 context for the evaluated source.
 

Modified: branches/ops_pct/docs/pdds/pdd13_bytecode.pod
==============================================================================
--- branches/ops_pct/docs/pdds/pdd13_bytecode.pod	Fri May 21 20:50:55 2010	(r46869)
+++ branches/ops_pct/docs/pdds/pdd13_bytecode.pod	Sat May 22 01:52:55 2010	(r46870)
@@ -389,7 +389,9 @@
   | 5      | n      | String data with trailing zero padding as required.    |
   +--------+--------+--------------------------------------------------------+
 
-Note: The encoding field is not implemented yet and is set to 0.
+Note: The encoding and charset are currently packed together with the Flags,
+using an unique field of Length 1.
+
 
 =item * PMC Constants
 

Added: branches/ops_pct/examples/io/get.pir
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ branches/ops_pct/examples/io/get.pir	Sat May 22 01:52:55 2010	(r46870)
@@ -0,0 +1,41 @@
+# Copyright (C) 2010, Parrot Foundation.
+# $Id$
+
+=head1 NAME
+
+examples/io/get.pir - LWP client
+
+=head1 SYNOPSIS
+
+    % ./parrot examples/io/get.pir http://www.parrot.org/ > parrot_home.html
+
+=head1 DESCRIPTION
+
+LWP client, grabs an URL.
+
+Supported protocols : file, http
+
+The HTTP redirection is supported (for example http://fperrad.googlepages.com/home).
+
+=cut
+
+.sub 'main' :main
+    .param pmc args
+    load_bytecode 'LWP.pir'
+    $S0 = shift args
+    .local string url
+    url = shift args
+    .local pmc ua, response
+    ua = new ['LWP';'UserAgent']
+    ua.'env_proxy'()
+    ua.'show_progress'(1)
+    response = ua.'get'(url, 'close' :named('Connection'))
+    $S0 = response.'content'()
+    say $S0
+.end
+
+# Local Variables:
+#   mode: pir
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:

Added: branches/ops_pct/examples/io/post.pir
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ branches/ops_pct/examples/io/post.pir	Sat May 22 01:52:55 2010	(r46870)
@@ -0,0 +1,51 @@
+#!parrot
+# Copyright (C) 2010, Parrot Foundation.
+# $Id$
+
+.include 'iglobals.pasm'
+
+.sub 'send_archive_to_smolder' :main
+    .local pmc config
+    $P0 = getinterp
+    config = $P0[.IGLOBALS_CONFIG_HASH]
+    .local pmc contents
+    contents = new 'ResizablePMCArray' # by couple
+    push contents, 'architecture'
+    $S0 = config['cpuarch']
+    push contents, $S0
+    push contents, 'platform'
+    $S0 = config['osname']
+    push contents, $S0
+    push contents, 'revision'
+    $S0 = config['revision']
+    push contents, $S0
+    push contents, 'username'
+    push contents, 'parrot-autobot'
+    push contents, 'password'
+    push contents, 'squ at wk'
+    push contents, 'comments'
+    push contents, "EXPERIMENTAL LWP.pir"
+    push contents, 'report_file'
+    $P0 = new 'FixedStringArray'
+    set $P0, 1
+    $P0[0] = 'parrot_test_run.tar.gz'
+    push contents, $P0
+    load_bytecode 'LWP.pir'
+    .const string url = 'http://smolder.plusthree.com/app/projects/process_add_report/8'
+    .local pmc ua, response
+    ua = new ['LWP';'UserAgent']
+    ua.'env_proxy'()
+    ua.'show_progress'(1)
+    response = ua.'post'(url, contents :flat, 'form-data' :named('Content-Type'), 'close' :named('Connection'))
+    $I0 = response.'code'()
+    unless $I0 == 302 goto L1
+    $S0 = response.'content'()
+    say $S0
+  L1:
+.end
+
+# Local Variables:
+#   mode: pir
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:

Modified: branches/ops_pct/include/parrot/compiler.h
==============================================================================
--- branches/ops_pct/include/parrot/compiler.h	Fri May 21 20:50:55 2010	(r46869)
+++ branches/ops_pct/include/parrot/compiler.h	Sat May 22 01:52:55 2010	(r46870)
@@ -136,11 +136,35 @@
 #define PARROT_IGNORABLE_RESULT
 #define PARROT_WARN_UNUSED_RESULT   __attribute__warn_unused_result__
 
+#define PARROT_PURE_FUNCTION        __attribute__pure__  __attribute__warn_unused_result__
 /* Pure functions have no side-effects, and depend only on parms or globals. e.g. strlen() */
-#define PARROT_PURE_FUNCTION                __attribute__pure__  __attribute__warn_unused_result__
-
-/* Const functions are pure functions, and do not examine targets of pointers. e.g. sqrt() */
-#define PARROT_CONST_FUNCTION               __attribute__const__ __attribute__warn_unused_result__
+/* "Many functions have no effects except the return value and their
+    return value depends only on the parameters and/or global
+    variables. Such a function can be subject to common subexpression
+    elimination and loop optimization just as an arithmetic operator
+    would be. For example, "PARROT_PURE_FUNCTION int square(int x)"
+    says that the hypothetical function square is safe to call fewer
+    times than the program says.
+
+    Some of common examples of pure functions are strlen or
+    memcmp. Interesting non-pure functions are functions with infinite
+    loops or those depending on volatile memory or other system resource,
+    that may change between two consecutive calls (such as feof in a
+    multithreading environment)." -- http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
+*/
+
+#define PARROT_CONST_FUNCTION       __attribute__const__ __attribute__warn_unused_result__
+/* Const functions are pure functions, and also do not examine targets of pointer args or globals. e.g. sqrt() */
+/* "Many functions do not examine any values except their arguments,
+    and have no effects except the return value. Basically this is just
+    slightly more strict class than the pure attribute below, since
+    function is not allowed to read global memory. Note that a function
+    that has pointer arguments and examines the data pointed to must
+    not be declared const. Likewise, a function that calls a non-const
+    function usually must not be const. It does not make sense for a
+    const function to return void."
+        -- http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
+*/
 
 #define PARROT_DOES_NOT_RETURN              /*@noreturn@*/ __attribute__noreturn__
 #define PARROT_DOES_NOT_RETURN_WHEN_FALSE   /*@noreturnwhenfalse@*/

Modified: branches/ops_pct/include/parrot/hash.h
==============================================================================
--- branches/ops_pct/include/parrot/hash.h	Fri May 21 20:50:55 2010	(r46869)
+++ branches/ops_pct/include/parrot/hash.h	Sat May 22 01:52:55 2010	(r46870)
@@ -315,13 +315,13 @@
         __attribute__nonnull__(2);
 
 PARROT_WARN_UNUSED_RESULT
-PARROT_PURE_FUNCTION
+PARROT_CONST_FUNCTION
 int int_compare(SHIM_INTERP,
     ARGIN_NULLOK(const void *a),
     ARGIN_NULLOK(const void *b));
 
 PARROT_WARN_UNUSED_RESULT
-PARROT_PURE_FUNCTION
+PARROT_CONST_FUNCTION
 size_t key_hash_int(SHIM_INTERP,
     ARGIN_NULLOK(const void *value),
     size_t seed);

Modified: branches/ops_pct/runtime/parrot/library/URI.pir
==============================================================================
--- branches/ops_pct/runtime/parrot/library/URI.pir	Fri May 21 20:50:55 2010	(r46869)
+++ branches/ops_pct/runtime/parrot/library/URI.pir	Sat May 22 01:52:55 2010	(r46870)
@@ -300,20 +300,25 @@
 
 .sub 'host' :method
     $S0 = self.'authority'()
+    $I0 = index $S0, '@'
+    if $I0 < 0 goto L1
+    inc $I0
+    $S0 = substr $S0, $I0
+  L1:
     .local int pos, lastpos
     lastpos = length $S0
     pos = 0
-  L1:
+  L2:
     pos = index $S0, ':', pos
-    if pos < 0 goto L2
+    if pos < 0 goto L3
     $I1 = pos
     inc pos
     $I0 = is_cclass .CCLASS_NUMERIC, $S0, pos
-    unless $I0 goto L1
+    unless $I0 goto L2
     $I0 = find_not_cclass .CCLASS_NUMERIC, $S0, pos, lastpos
-    unless $I0 == lastpos goto L1
+    unless $I0 == lastpos goto L2
     $S0 = substr $S0, 0, $I1
-  L2:
+  L3:
     .return ($S0)
 .end
 

Modified: branches/ops_pct/runtime/parrot/library/distutils.pir
==============================================================================
--- branches/ops_pct/runtime/parrot/library/distutils.pir	Fri May 21 20:50:55 2010	(r46869)
+++ branches/ops_pct/runtime/parrot/library/distutils.pir	Sat May 22 01:52:55 2010	(r46870)
@@ -2155,6 +2155,7 @@
     load_bytecode 'LWP.pir'
     .local pmc ua, response
     ua = new ['LWP';'UserAgent']
+    ua.'env_proxy'()
     ua.'show_progress'(1)
     $S0 = kv['smolder_url']
     response = ua.'post'($S0, contents :flat, 'form-data' :named('Content-Type'), 'close' :named('Connection'))

Modified: branches/ops_pct/src/hash.c
==============================================================================
--- branches/ops_pct/src/hash.c	Fri May 21 20:50:55 2010	(r46869)
+++ branches/ops_pct/src/hash.c	Sat May 22 01:52:55 2010	(r46870)
@@ -375,7 +375,7 @@
 */
 
 PARROT_WARN_UNUSED_RESULT
-PARROT_PURE_FUNCTION
+PARROT_CONST_FUNCTION
 size_t
 key_hash_int(SHIM_INTERP, ARGIN_NULLOK(const void *value), size_t seed)
 {
@@ -396,7 +396,7 @@
 */
 
 PARROT_WARN_UNUSED_RESULT
-PARROT_PURE_FUNCTION
+PARROT_CONST_FUNCTION
 int
 int_compare(SHIM_INTERP, ARGIN_NULLOK(const void *a), ARGIN_NULLOK(const void *b))
 {
@@ -1121,8 +1121,7 @@
 */
 
 void
-parrot_chash_destroy_values(PARROT_INTERP, ARGMOD(Hash *hash),
-    NOTNULL(value_free func))
+parrot_chash_destroy_values(PARROT_INTERP, ARGMOD(Hash *hash), NOTNULL(value_free func))
 {
     ASSERT_ARGS(parrot_chash_destroy_values)
     UINTVAL i;

Modified: branches/ops_pct/src/string/charset.c
==============================================================================
--- branches/ops_pct/src/string/charset.c	Fri May 21 20:50:55 2010	(r46869)
+++ branches/ops_pct/src/string/charset.c	Sat May 22 01:52:55 2010	(r46870)
@@ -149,6 +149,7 @@
 */
 
 PARROT_EXPORT
+PARROT_PURE_FUNCTION
 PARROT_CAN_RETURN_NULL
 PARROT_WARN_UNUSED_RESULT
 const CHARSET *
@@ -227,6 +228,7 @@
 */
 
 PARROT_EXPORT
+PARROT_PURE_FUNCTION
 PARROT_WARN_UNUSED_RESULT
 INTVAL
 Parrot_charset_number_of_str(SHIM_INTERP, ARGIN(const STRING *src))
@@ -254,6 +256,7 @@
 */
 
 PARROT_EXPORT
+PARROT_PURE_FUNCTION
 PARROT_CAN_RETURN_NULL
 PARROT_WARN_UNUSED_RESULT
 STRING *
@@ -277,6 +280,7 @@
 */
 
 PARROT_EXPORT
+PARROT_PURE_FUNCTION
 PARROT_CAN_RETURN_NULL
 PARROT_WARN_UNUSED_RESULT
 const CHARSET *
@@ -301,6 +305,7 @@
 */
 
 PARROT_EXPORT
+PARROT_PURE_FUNCTION
 PARROT_CAN_RETURN_NULL
 PARROT_WARN_UNUSED_RESULT
 const char *
@@ -539,6 +544,7 @@
 */
 
 PARROT_EXPORT
+PARROT_PURE_FUNCTION
 PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
 const CHARSET *
@@ -560,6 +566,7 @@
 */
 
 PARROT_EXPORT
+PARROT_PURE_FUNCTION
 PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
 charset_converter_t
@@ -572,7 +579,7 @@
 
     for (i = 0; i < n; ++i) {
         if (lhs == all_charsets->set[i].charset) {
-            One_charset * const left = all_charsets->set + i;
+            const One_charset * const left = all_charsets->set + i;
             const int nc = left->n_converters;
             int j;
 

Modified: branches/ops_pct/t/harness.pir
==============================================================================
--- branches/ops_pct/t/harness.pir	Fri May 21 20:50:55 2010	(r46869)
+++ branches/ops_pct/t/harness.pir	Sat May 22 01:52:55 2010	(r46870)
@@ -365,6 +365,7 @@
     .const string url = 'http://smolder.plusthree.com/app/projects/process_add_report/8'
     .local pmc ua, response
     ua = new ['LWP';'UserAgent']
+    ua.'env_proxy'()
     ua.'show_progress'(1)
     response = ua.'post'(url, contents :flat, 'form-data' :named('Content-Type'), 'close' :named('Connection'))
     $I0 = response.'code'()

Modified: branches/ops_pct/t/library/uri.t
==============================================================================
--- branches/ops_pct/t/library/uri.t	Fri May 21 20:50:55 2010	(r46869)
+++ branches/ops_pct/t/library/uri.t	Sat May 22 01:52:55 2010	(r46870)
@@ -170,7 +170,7 @@
     $S0 = $P0.'userinfo'()
     is($S0, 'user:passwd', 'userinfo')
     $S0 = $P0.'host'()
-    is($S0, 'user:passwd at proxy.net', 'host')
+    is($S0, 'proxy.net', 'host')
     $S0 = $P0.'port'()
     is($S0, '8000', 'port')
 .end


More information about the parrot-commits mailing list