develooper Front page | perl.cvs.parrot | Postings from January 2009

[svn:parrot] r35048 - in branches/bcanno: . compilers/ncigen compilers/ncigen/lib/Parrot/Test compilers/ncigen/src compilers/ncigen/t/NCIGENAST compilers/pirc/src docs/book languages/ecmascript/t/sanity_pt languages/lua/t/test languages/perl6/docs languag

From:
jonathan
Date:
January 6, 2009 08:33
Subject:
[svn:parrot] r35048 - in branches/bcanno: . compilers/ncigen compilers/ncigen/lib/Parrot/Test compilers/ncigen/src compilers/ncigen/t/NCIGENAST compilers/pirc/src docs/book languages/ecmascript/t/sanity_pt languages/lua/t/test languages/perl6/docs languag
Message ID:
20090106163250.63282CB9F9@x12.develooper.com
Author: jonathan
Date: Tue Jan  6 08:32:48 2009
New Revision: 35048

Removed:
   branches/bcanno/tools/dev/src-t.sh
Modified:
   branches/bcanno/   (props changed)
   branches/bcanno/MANIFEST
   branches/bcanno/compilers/ncigen/lib/Parrot/Test/NCIGENAST.pm   (props changed)
   branches/bcanno/compilers/ncigen/ncigen.pir   (props changed)
   branches/bcanno/compilers/ncigen/ncigen.pl   (props changed)
   branches/bcanno/compilers/ncigen/src/NCIGENAST.pir   (props changed)
   branches/bcanno/compilers/ncigen/t/NCIGENAST/   (props changed)
   branches/bcanno/compilers/pirc/src/bcgen.c
   branches/bcanno/compilers/pirc/src/bcgen.h
   branches/bcanno/compilers/pirc/src/main.c
   branches/bcanno/compilers/pirc/src/pircompunit.c
   branches/bcanno/compilers/pirc/src/pircompunit.h
   branches/bcanno/compilers/pirc/src/piremit.c
   branches/bcanno/compilers/pirc/src/pirpcc.c
   branches/bcanno/compilers/pirc/src/pirsymbol.c
   branches/bcanno/compilers/pirc/src/pirsymbol.h
   branches/bcanno/docs/book/ch03_pir_basics.pod
   branches/bcanno/docs/book/ch10_hlls.pod
   branches/bcanno/languages/ecmascript/t/sanity_pt/03-boolean.t   (props changed)
   branches/bcanno/languages/lua/t/test/bisect-output-win32.txt   (props changed)
   branches/bcanno/languages/perl6/docs/spectest-progress.csv
   branches/bcanno/languages/pipp/Test.php   (props changed)
   branches/bcanno/languages/pipp/docs/namespaces.pod   (props changed)
   branches/bcanno/languages/pipp/src/common/eval.pir   (props changed)
   branches/bcanno/languages/pipp/src/common/guts.pir   (props changed)
   branches/bcanno/languages/pipp/src/pmc/phpnull.pmc   (props changed)
   branches/bcanno/languages/pipp/t/in_php/array.t   (props changed)
   branches/bcanno/languages/pipp/t/php_qa_testsuite/   (props changed)
   branches/bcanno/languages/pipp/t/pmc/null.t   (props changed)
   branches/bcanno/tools/util/perlcritic-cage.conf   (props changed)

Log:
Sync bcanno branch up with trunk, in preparation with merge.

Modified: branches/bcanno/MANIFEST
==============================================================================
--- branches/bcanno/MANIFEST	(original)
+++ branches/bcanno/MANIFEST	Tue Jan  6 08:32:48 2009
@@ -1,7 +1,7 @@
 # ex: set ro:
 # $Id$
 #
-# generated by tools\dev\mk_manifest_and_skip.pl Tue Jan  6 11:22:13 2009 UT
+# generated by tools\dev\mk_manifest_and_skip.pl Tue Jan  6 13:01:40 2009 UT
 #
 # See tools/dev/install_files.pl for documentation on the
 # format of this file.
@@ -3789,7 +3789,6 @@
 tools/dev/pmctree.pl                                        [devel]
 tools/dev/reconfigure.pl                                    [devel]
 tools/dev/search-ops.pl                                     [devel]
-tools/dev/src-t.sh                                          [devel]
 tools/dev/svnclobber.pl                                     [devel]
 tools/dev/symlink.pl                                        [devel]
 tools/dev/testyamd                                          [devel]

Modified: branches/bcanno/compilers/pirc/src/bcgen.c
==============================================================================
--- branches/bcanno/compilers/pirc/src/bcgen.c	(original)
+++ branches/bcanno/compilers/pirc/src/bcgen.c	Tue Jan  6 08:32:48 2009
@@ -401,6 +401,7 @@
 
 #endif
 
+
 /*
 
 =item C<void

Modified: branches/bcanno/compilers/pirc/src/bcgen.h
==============================================================================
--- branches/bcanno/compilers/pirc/src/bcgen.h	(original)
+++ branches/bcanno/compilers/pirc/src/bcgen.h	Tue Jan  6 08:32:48 2009
@@ -49,8 +49,8 @@
  * sub.
  */
 typedef struct lexical {
-    char const     *name;
-    int            *color;
+    char const     *name;     /* name of this lexical */
+    int            *color;    /* register assigned to the lexical */
     struct lexical *next;
 
 } lexical;
@@ -82,6 +82,11 @@
 
 void create_codesegment(bytecode * const bc, int codesize);
 
+void create_annotations_segment(bytecode * const bc, char const * const name);
+
+void add_annotation(bytecode * const bc, opcode_t offset, opcode_t key,
+                                         opcode_t type, opcode_t value);
+
 /* call this to write the PBC file */
 void write_pbc_file(bytecode * const bc, char const * const filename) ;
 

Modified: branches/bcanno/compilers/pirc/src/main.c
==============================================================================
--- branches/bcanno/compilers/pirc/src/main.c	(original)
+++ branches/bcanno/compilers/pirc/src/main.c	Tue Jan  6 08:32:48 2009
@@ -310,7 +310,7 @@
         return 0;
     }
     else {
-        hdocoutfile = _tempnam(NULL, "hdoc");
+        hdocoutfile = "hdoctemp";
         file = open_file(hdocoutfile, "w");
         process_heredocs(interp, argv[0], file);
         fclose(file);

Modified: branches/bcanno/compilers/pirc/src/pircompunit.c
==============================================================================
--- branches/bcanno/compilers/pirc/src/pircompunit.c	(original)
+++ branches/bcanno/compilers/pirc/src/pircompunit.c	Tue Jan  6 08:32:48 2009
@@ -848,6 +848,7 @@
      *
      * jumping to L1 is equivalent to jumping to L2 or L3; so when calculating
      * branch offsets, all three labels must yield the same offset.
+     */
 
     /* store the labelname and its offset */
     store_local_label(lexer, labelname, instr->offset);
@@ -1308,7 +1309,7 @@
 PARROT_CANNOT_RETURN_NULL
 constdecl *
 new_named_const(lexer_state * const lexer, value_type type, char const * const name, ...) {
-    constdecl *c = pir_mem_allocate(lexer, sizeof (constdecl));
+    constdecl *c = (constdecl *)pir_mem_allocate(lexer, sizeof (constdecl));
     va_list arg_ptr;
     va_start(arg_ptr, name);
 
@@ -2416,6 +2417,7 @@
      */
     if (CURRENT_INSTRUCTION(lexer)) {
         switch (CURRENT_INSTRUCTION(lexer)->opcode) {
+            case PARROT_OP_tailcall_p:
             case PARROT_OP_end:
             case PARROT_OP_returncc:
             case PARROT_OP_yield:
@@ -2483,9 +2485,7 @@
 =item C<void
 annotate(lexer_state * const lexer, char const * const key, constant * const value)>
 
-Add a new annotation with key C<key> and value C<value>. This function assumes
-that there's an instruction in place, as it will store a pointer to the current
-instruction.
+Add a new annotation with key C<key> and value C<value>.
 
 =cut
 
@@ -2499,7 +2499,7 @@
     ++lexer->num_annotations; /* keep track of number of annotations */
 
 
-    ann->offset = CURRENT_INSTRUCTION(lexer)->offset;
+    ann->offset = lexer->codesize;
 
     /* store the annotation in a list, managed by the lexer
      * the list is circular linked, so that the order of annotations is preserved.

Modified: branches/bcanno/compilers/pirc/src/pircompunit.h
==============================================================================
--- branches/bcanno/compilers/pirc/src/pircompunit.h	(original)
+++ branches/bcanno/compilers/pirc/src/pircompunit.h	Tue Jan  6 08:32:48 2009
@@ -412,6 +412,7 @@
 expression *expr_from_key(struct lexer_state * const lexer, key * const k);
 expression *expr_from_string(struct lexer_state * const lexer, char const * const sval);
 expression *expr_from_int(struct lexer_state * const lexer, int ival);
+expression *expr_from_num(struct lexer_state * const lexer, double nval);
 
 /* functions for argument node creation and storing */
 argument *new_argument(struct lexer_state * const lexer, expression * const expr);

Modified: branches/bcanno/compilers/pirc/src/piremit.c
==============================================================================
--- branches/bcanno/compilers/pirc/src/piremit.c	(original)
+++ branches/bcanno/compilers/pirc/src/piremit.c	Tue Jan  6 08:32:48 2009
@@ -161,6 +161,7 @@
             panic(lexer, "Unknown type detected in print_constant()");
             break;
     }
+
 }
 
 /*
@@ -906,8 +907,8 @@
     if (lexer->annotations == NULL)
         return;
 
-#if 0
 
+#if 0
     /* create an annotations segment, which is not created by default. */
     create_annotations_segment(lexer->bc, lexer->filename);
 
@@ -917,13 +918,30 @@
     /* iterate over annotations and store them */
     do {
 
-        /* add the key */
-        opcode_t key  = ....
+        opcode_t key, value;
+
+
+        switch (iter->value->type) {
+            case INT_VAL:
+                value = iter->value->val.ival;
+                break;
+            case NUM_VAL:
+                value = add_num_const(lexer->bc, iter->value->val.nval);
+                break;
+            case STRING_VAL:
+                value = add_string_const(lexer->bc, iter->value->val.sval, "ascii");
+                break;
+            case USTRING_VAL:
+                value = add_string_const(lexer->bc, iter->value->val.ustr->contents,
+                                                    iter->value->val.ustr->charset);
+                break;
+            default:
+                panic(lexer, "unknown annotation constant type");
+                break;
+        }
 
-        opcode_t type = ...
-        opcode_t offset = iter->offset;
 
-        add_annotation(lexer->bc, offset, key, type, value);
+        add_annotation(lexer->bc, iter->offset, key, iter->value->type, value);
 
         iter = iter->next;
     }
@@ -932,6 +950,8 @@
 #endif
 }
 
+
+
 /*
 
 =item C<void

Modified: branches/bcanno/compilers/pirc/src/pirpcc.c
==============================================================================
--- branches/bcanno/compilers/pirc/src/pirpcc.c	(original)
+++ branches/bcanno/compilers/pirc/src/pirpcc.c	Tue Jan  6 08:32:48 2009
@@ -23,6 +23,7 @@
 #include "pircompunit.h"
 #include "pircompiler.h"
 #include "pirerr.h"
+#include "pirsymbol.h"
 
 #include "parrot/oplib/ops.h"
 
@@ -84,8 +85,10 @@
             SET_FLAG(flag, arg->value->expr.t->info->type);
             break;
         case EXPR_CONSTANT:
-            /* copy the type of the constant */
-            SET_FLAG(flag, arg->value->expr.c->type);
+            /* copy the type of the constant; note that constants store a value_type,
+             * not a pir_type, so convert here.
+             */
+            SET_FLAG(flag, valuetype_pirtype_clut[arg->value->expr.c->type]);
             /* set the flag indicating the argument is a constant literal, not a register. */
             SET_FLAG(flag, PARROT_ARG_CONSTANT);
             break;
@@ -122,6 +125,7 @@
 */
 static target *
 generate_unique_pir_reg(lexer_state * const lexer, pir_type type) {
+    fprintf(stderr, "unique reg of type %d: %d\n", type, lexer->pir_reg_generator - 1);
     return new_reg(lexer, type, --lexer->pir_reg_generator);
 }
 
@@ -389,6 +393,75 @@
 
 /*
 
+=item C<static target *
+get_invoked_sub(lexer_state * const lexer, target * const sub)>
+
+Return a C<target> node that represents the sub to invoke.
+If C<sub> is a register, that is returned. If it's a declared C<.local>,
+then a target node representing that symbol is returned. If it's
+just the name of a .sub, then there's 2 possibilities: either the
+sub was already parsed, in which case it's stored as a global_label,
+or the sub was not parsed yet, in which case a runtime resolving
+instruction is emitted.
+
+=cut
+
+*/
+static target *
+get_invoked_sub(lexer_state * const lexer, target * const sub) {
+    target       *subreg = NULL;
+    symbol       *sym    = NULL;
+    global_label *glob   = NULL;
+
+    /* if the target is a register, invoke that. */
+    if (TEST_FLAG(sub->flags, TARGET_FLAG_IS_REG))
+        return sub;
+
+
+    /* find the global label in the current file, or find it during runtime */
+    sym  = find_symbol(lexer, sub->info->id.name);
+
+    /* if the invoked object was declared as a .local, return that */
+    if (sym)
+        return target_from_symbol(lexer, sym);
+
+    /* it was not a .local, so check whether it's a declared .sub */
+    glob   = find_global_label(lexer, sub->info->id.name);
+    subreg = generate_unique_pir_reg(lexer, PMC_TYPE);
+
+    if (glob) {
+        new_sub_instr(lexer, PARROT_OP_set_p_pc, "set_p_pc", 0);
+        add_operands(lexer, "%T%i", subreg, glob->const_table_index);
+        return subreg;
+    }
+
+    /* find it during runtime (hopefully, otherwise exception) */
+    new_sub_instr(lexer, PARROT_OP_find_sub_not_null_p_sc, "find_sub_not_null_p_sc", 0);
+
+    add_operands(lexer, "%T%s", subreg, sub->info->id.name);
+
+    /* save the current instruction in a list; entries in this list will be
+     * fixed up, if possible, after the parsing phase.
+     *
+     * Instead of the instruction
+     *
+     *   set_p_pc
+     *
+     * that is generated when the global label C<glob> was found (see above),
+     * another instructions is generated. After the parse, we'll re-try
+     * to find the global label that is referenced. For now, just generate
+     * this instruction to do the resolving of the label during runtime:
+     *
+     *   find_sub_not_null_p_sc
+     */
+    save_global_reference(lexer, CURRENT_INSTRUCTION(lexer), sub->info->id.name);
+
+    return subreg;
+
+}
+
+/*
+
 =item C<static void
 convert_pcc_call(lexer_state * const lexer, invocation * const inv)>
 
@@ -413,60 +486,52 @@
 */
 static void
 convert_pcc_call(lexer_state * const lexer, invocation * const inv) {
+    target *sub;
+
     new_sub_instr(lexer, PARROT_OP_set_args_pc, "set_args_pc", inv->num_arguments);
     arguments_to_operands(lexer, inv->arguments, inv->num_arguments);
 
+    new_sub_instr(lexer, PARROT_OP_get_results_pc, "get_results_pc", inv->num_results);
+    targets_to_operands(lexer, inv->results, inv->num_results);
 
-    /* if the target is a register, invoke that. */
-    if (TEST_FLAG(inv->sub->flags, TARGET_FLAG_IS_REG)) {
-        target *sub = new_reg(lexer, PMC_TYPE, inv->sub->info->color);
+    sub = get_invoked_sub(lexer, inv->sub);
 
-        if (inv->retcc) { /* return continuation present? */
-            new_sub_instr(lexer, PARROT_OP_invoke_p_p, "invoke_p_p", 0);
-            add_operands(lexer, "%T%T", inv->sub, inv->retcc);
-        }
-        else {
-            new_sub_instr(lexer, PARROT_OP_invokecc_p, "invokecc_p", 0);
-            add_operands(lexer, "%T", sub);
-        }
+    if (inv->retcc) { /* return continuation present? */
+        new_sub_instr(lexer, PARROT_OP_invoke_p_p, "invoke_p_p", 0);
+        add_operands(lexer, "%T%T", sub, inv->retcc);
+    }
+    else {
+        new_sub_instr(lexer, PARROT_OP_invokecc_p, "invokecc_p", 0);
+        add_operands(lexer, "%T", sub);
     }
-    else { /* find the global label in the current file, or find it during runtime */
-        target *sub        = generate_unique_pir_reg(lexer, PMC_TYPE);
-        global_label *glob = find_global_label(lexer, inv->sub->info->id.name);
-
-        if (glob) {
-            new_sub_instr(lexer, PARROT_OP_set_p_pc, "set_p_pc", 0);
-            add_operands(lexer, "%T%i", sub, glob->const_table_index);
-        }
-        else { /* find it during runtime (hopefully, otherwise exception) */
-            new_sub_instr(lexer, PARROT_OP_find_sub_not_null_p_sc, "find_sub_not_null_p_sc", 0);
 
-            add_operands(lexer, "%T%s", sub, inv->sub->info->id.name);
+}
 
-            /* save the current instruction in a list; entries in this list will be
-             * fixed up, if possible, after the parsing phase.
-             *
-             * Instead of the instruction
-             *
-             *   set_p_pc
-             *
-             * that is generated when the global label C<glob> was found (see above),
-             * another instructions is generated. After the parse, we'll re-try
-             * to find the global label that is referenced. For now, just generate
-             * this instruction to do the resolving of the label during runtime:
-             *
-             *   find_sub_not_null_p_sc
-             */
-            save_global_reference(lexer, CURRENT_INSTRUCTION(lexer), inv->sub->info->id.name);
-        }
+/*
 
-        new_sub_instr(lexer, PARROT_OP_get_results_pc, "get_results_pc", inv->num_results);
-        targets_to_operands(lexer, inv->results, inv->num_results);
+=item C<static void
+convert_pcc_tailcall(lexer_state * const lexer, invocation * const inv)>
 
-        new_sub_instr(lexer, PARROT_OP_invokecc_p, "invokecc_p", 0);
-        add_operands(lexer, "%T", sub);
+Generate instructions for a tailcall using the Parrot Calling Conventions (PCC).
+The sequence of instructions is:
 
-    }
+ set_args_pc
+ tailcall_pc
+
+=cut
+
+*/
+static void
+convert_pcc_tailcall(lexer_state * const lexer, invocation * const inv) {
+    target *sub;
+
+    new_sub_instr(lexer, PARROT_OP_set_args_pc, "set_args_pc", inv->num_arguments);
+    arguments_to_operands(lexer, inv->arguments, inv->num_arguments);
+
+    sub = get_invoked_sub(lexer, inv->sub);
+
+    new_sub_instr(lexer, PARROT_OP_tailcall_p, "tailcall_p", 0);
+    add_operands(lexer, "%T", sub);
 }
 
 /*
@@ -533,30 +598,7 @@
     new_sub_instr(lexer, PARROT_OP_yield, "yield", 0);
 }
 
-/*
 
-=item C<static void
-convert_pcc_tailcall(lexer_state * const lexer, invocation * const inv)>
-
-Generate instructions for a tailcall using the Parrot Calling Conventions (PCC).
-The sequence of instructions is:
-
- set_args_pc
- tailcall_pc
-
-=cut
-
-*/
-static void
-convert_pcc_tailcall(lexer_state * const lexer, invocation * const inv) {
-    new_sub_instr(lexer, PARROT_OP_set_args_pc, "set_args_pc", inv->num_arguments);
-    arguments_to_operands(lexer, inv->arguments, inv->num_arguments);
-
-    /* XXX this needs an argument; possibly refactor PCC_CALL code, so we can re-use
-     * the code to get the sub to invoke.
-     */
-    new_sub_instr(lexer, PARROT_OP_tailcall_p, "tailcall_p", 0);
-}
 
 /*
 

Modified: branches/bcanno/compilers/pirc/src/pirsymbol.c
==============================================================================
--- branches/bcanno/compilers/pirc/src/pirsymbol.c	(original)
+++ branches/bcanno/compilers/pirc/src/pirsymbol.c	Tue Jan  6 08:32:48 2009
@@ -49,7 +49,7 @@
 */
 
 
-#define NO_REG_ALLOCATED    -1
+
 
 /* Conversion Look-Up Table (CLUT) for pir_type and value_type enums.
  *
@@ -68,7 +68,7 @@
  * When input is STRING_TYPE you'll only get STRING_VAL,
  * never USTRING_VAL (indicating unicode string).
  */
-static const int valuetype_pirtype_clut[10] = {
+const int valuetype_pirtype_clut[10] = {
     INT_VAL,      /* INT_TYPE -> INT_VAL */
     STRING_VAL,   /* STRING_TYPE -> STRING_VAL */
     PMC_VAL,      /* PMC_TYPE -> PMC_VAL */
@@ -95,6 +95,7 @@
 static int
 next_register(NOTNULL(lexer_state * const lexer), pir_type type) {
     CURRENT_SUB(lexer)->info.regs_used[type]++; /* count number of registers used */
+    /* fprintf(stderr, "vanilla reg: %d of type %d\n", lexer->curregister[type], type); */
     return lexer->curregister[type]++;
 }
 
@@ -112,6 +113,9 @@
 void
 assign_vanilla_register(NOTNULL(lexer_state * const lexer), symbol * const sym) {
     sym->info.color    = next_register(lexer, sym->info.type);
+    /* fprintf(stderr, "assigning vanilla reg %d to symbol %s\n", sym->info.color,
+                    sym->info.id.name);
+    */
 
     if (TEST_FLAG(lexer->flags, LEXER_FLAG_REGALLOC)) {
         sym->info.interval = new_live_interval(lexer->lsr, lexer->stmt_counter, sym->info.type);
@@ -257,7 +261,7 @@
             bucket_symbol(b) = iter;
             store_bucket(table, b, hash);
             iter->info.type  = type;
-            fprintf(stderr, "declare_local(): [%s]\n", iter->info.id.name);
+            /* fprintf(stderr, "declare_local(): [%s]\n", iter->info.id.name); */
         }
 
         iter = iter->next;
@@ -333,9 +337,10 @@
 
         if (STREQ(sym->info.id.name, name)) {
 
-            if (sym->info.color == NO_REG_ALLOCATED)  /* no PASM register assigned yet */
+            if (sym->info.color == NO_REG_ALLOCATED) { /* no PASM register assigned yet */
                 /* get a new reg from vanilla reg. allocator */
                 assign_vanilla_register(lexer, sym);
+            }
             else  /* update end point of interval */
                 if (TEST_FLAG(lexer->flags, LEXER_FLAG_REGALLOC)) {
                     sym->info.interval->endpoint = lexer->stmt_counter;
@@ -535,7 +540,9 @@
          * a new PASM register through the vanilla reg. allocator and
          * store the register as "used".
          */
-        return use_register(lexer, type, regno, next_register(lexer, type));
+        int nextreg = next_register(lexer, type);
+        fprintf(stderr, "mapping reg %d to %d\n", regno, nextreg);
+        return use_register(lexer, type, regno, nextreg);
     }
 }
 

Modified: branches/bcanno/compilers/pirc/src/pirsymbol.h
==============================================================================
--- branches/bcanno/compilers/pirc/src/pirsymbol.h	(original)
+++ branches/bcanno/compilers/pirc/src/pirsymbol.h	Tue Jan  6 08:32:48 2009
@@ -18,6 +18,8 @@
 #include "pircompunit.h"
 #include "pirregalloc.h"
 
+#define NO_REG_ALLOCATED    -1
+
 /* core info of all symbols and PIR registers ($I42, etc.). */
 typedef struct syminfo {
     int            color;
@@ -70,6 +72,9 @@
 } local_label;
 
 
+/* lookup table to convert value_type and pir_type values into one another. */
+extern const int valuetype_pirtype_clut[10];
+
 
 /* symbol constructor */
 symbol *new_symbol(struct lexer_state * const lexer, char const * const name, pir_type type);

Modified: branches/bcanno/docs/book/ch03_pir_basics.pod
==============================================================================
--- branches/bcanno/docs/book/ch03_pir_basics.pod	(original)
+++ branches/bcanno/docs/book/ch03_pir_basics.pod	Tue Jan  6 08:32:48 2009
@@ -153,6 +153,47 @@
 
   End_Token
 
+=head3 Strings: Encodings and Charsets
+
+Strings are complicated. It used to be that all that was needed was to
+support the ASCII charset, which only contained a handful of common
+symbols and English characters. Now we need to worry about character
+encodings and charsets in order to make sense out of all the string data
+in the world.
+
+Parrot has a very flexible system for handling and manipulating strings.
+Every string is associated with an encoding and a character set (charset).
+The default for Parrot is 8-bit ASCII, which is simple to use and is almost
+universally supported. However, support is built in to have other formats as
+well.
+
+String constants, like the ones we've seen above, can have an optional
+prefix specifying the encoding and the charset to be used by the string.
+Parrot will maintain these values internally, and will automatically convert
+strings when necessary to preserve the information. String prefixes are
+specified as C<encoding:charset:> at the front of the string. Here are some
+examples:
+
+  $S0 = utf8:unicode:"Hello UTF8 Unicode World!"
+  $S1 = utf16:unicode:"Hello UTF16 Unicode World!"
+  $S2 = ascii:"This is 8-bit ASCII"
+  $S3 = binary:"This is treated as raw unformatted binary"
+
+The C<binary:> encoding treats the string as a buffer of raw unformatted
+binary data. It isn't really a "string" per se because binary data isn't
+treated as if it contains any readable characters. These kinds of strings
+are useful for library routines that return large amounts of binary data
+that doesn't easily fit into any other primitive data type.
+
+When two types of strings are combined together in some way, such as through
+concatenation, they must both use the same character set an encoding.
+Parrot will automatically upgrade one or both of the strings to use the next
+highest compatible format, if they aren't equal. ASCII strings will
+automatically upgrade to UTF-8 strings if needed, and UTF-8 will upgrade
+to UTF-16. Handling and maintaining these data and conversions all happens
+automatically inside Parrot, and you the programmer don't need to worry
+about the details.
+
 =head2 Named Variables
 
 Z<CHP-3-SECT-2.3>

Modified: branches/bcanno/docs/book/ch10_hlls.pod
==============================================================================
--- branches/bcanno/docs/book/ch10_hlls.pod	(original)
+++ branches/bcanno/docs/book/ch10_hlls.pod	Tue Jan  6 08:32:48 2009
@@ -2,7 +2,7 @@
 
 =head1 HLLs and Interoperation
 
-Z<CHP-9>
+Z<CHP-10>
 
 =head2 Parrot HLL Environment
 
@@ -56,6 +56,78 @@
 
 =head3 Compiler Objects
 
+The C<compreg> opcode has two forms that are used with HLL compilers. The
+first form stores an object as a compiler object to be retrieved later, and
+the second form retrieves a stored compiler object for a given language.
+The exact type of compiler object stored with C<compreg> can vary for each
+different language implementation, although most of the languages using PCT
+will have a common form. If a compiler object is in register C<$P0>, it can
+be stored using the following C<compreg> syntax:
+
+  compreg 'MyCompiler', $P0
+
+There are two built-in compiler objects: One for PIR and one for PASM. These
+two don't need to be stored first, they can simply be retrieved and used.
+The PIR and PASM compiler objects are Sub PMCs that take a single string
+argument and return an array PMC containing a list of all the compiled
+subroutines from the string. Other compiler objects might be different
+entirely, and may need to be used in different ways. A common convention is
+for a compiler to be an object with a C<compile> method. This is done with
+PCT-based compilers and for languages who use a stateful compiler.
+
+Compiler objects allow programs in Parrot to compile arbitrary code strings
+at runtime and execute them. This ability, to dynamically compile
+code that is represented in a string variable at runtime, is of fundamental
+importance to many modern dynamic languages.  Here's an example using
+the PIR compiler:
+
+  $P0 = compreg 'PIR'      # Get the compiler object
+  $P1 = $P0(code)          # Compile the string variable "code"
+
+The returned value from invoking the compiler object is an array of PMCs
+that contains the various executable subroutines from the compiled source.
+Here's a more verbose example of this:
+
+  $P0 = compreg 'PIR'
+  $S0 = << "END_OF_CODE"
+
+    .sub 'hello'
+       say 'hello world!'
+    .end
+  
+    .sub 'goodbye'
+       say 'goodbye world!'
+    .end
+
+  END_OF_CODE
+
+  $P1 = $P0($S0)
+  $P2 = $P1[0]      # The sub "hello"
+  $P3 = $P1[0]      # The sub "goodbye"
+
+  $P2()             # "hello world!"
+  $P3()             # "goodbye world!"
+
+Here's an example of a Read-Eval-Print-Loop (REPL) in PIR:
+
+  $P0 = getstdin
+  $P1 = compreg 'PIR'
+  
+  loop_top:
+    $S0 = readline $P0
+    $S0 = ".sub '' :anon\n" . $S0
+    $S0 = $S0 . "\n.end\n"
+    $P2 = $P1($S0)
+    $P2()
+  
+    goto loop_top
+
+The exact list of HLL packages installed on your system may vary. Some
+language compiler packages will exist as part of the Parrot source code
+repository, but many will be developed and maintained separately. In any
+case, these compilers will typically need to be loaded into your program
+first, before a compiler object for them can be retrieved and used.
+
 =head2 HLL Namespaces
 
 Let's take a closer look at namespaces then we have in previous chapters.

Modified: branches/bcanno/languages/perl6/docs/spectest-progress.csv
==============================================================================
--- branches/bcanno/languages/perl6/docs/spectest-progress.csv	(original)
+++ branches/bcanno/languages/perl6/docs/spectest-progress.csv	Tue Jan  6 08:32:48 2009
@@ -228,3 +228,4 @@
 "2009-01-03 00:00",34854,5911,0,323,1378,7612,10783,264
 "2009-01-04 00:00",34911,5911,0,323,1378,7612,10786,264
 "2009-01-05 00:00",34959,5914,0,323,1378,7615,10786,265
+"2009-01-06 00:00",35013,6170,0,338,1414,7922,11248,279



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About