Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mk_language_shell.pl generates broken PMC boilerplate #315

Open
parrot opened this issue Oct 8, 2010 · 6 comments
Open

mk_language_shell.pl generates broken PMC boilerplate #315

parrot opened this issue Oct 8, 2010 · 6 comments

Comments

@parrot
Copy link
Collaborator

parrot commented Oct 8, 2010

When one runs mk_language_shell.pl --with-pmc, the resulting boilerplate .pmc file doesn't even compile. There's a "property" variable that's used uninitialized, and a mysterious "shape" variable that's never defined. What's up with that?

Patch attached.

Originally http://trac.parrot.org/parrot/ticket/1819 by ellefu

@parrot
Copy link
Collaborator Author

parrot commented Oct 8, 2010

1372 byte attachment from ellefu
at http://trac.parrot.org/parrot/raw-attachment/ticket/1819/patch.txt

+++ tools/dev/mk_language_shell.in      (working copy)
@@ -656,12 +656,9 @@
 */

METHOD PMC* get() {

-        PMC\* property;
-        INTVAL array_t;
-        STRING\* property_name;
-        PMC\* property = VTABLE_getprop(INTERP, SELF, property_name);
- ```
     STRING* property_name = string_from_literal(INTERP, "property");
  •    property_name = string_from_literal(INTERP, "property");
    
  •    shape = VTABLE_getprop(INTERP, SELF, property_name);
     if (PMC_IS_NULL(property)) {
        /*
         \* No property has been set yet. This means that we are
    

    @@ -671,7 +668,7 @@
    * specify it?
    /
    /

  •        array_t = Parrot_pmc_get_type_str(INTERP,
    
  •        INTVAL array_t = Parrot_pmc_get_type_str(INTERP,
             string_from_literal(INTERP, "@lang@"));
         */
         property = Parrot_pmc_new(INTERP, VTABLE_type(INTERP, SELF));
    

    @@ -710,7 +707,7 @@
    old_property = VTABLE_getprop(INTERP, SELF, property_name);
    VTABLE_setprop(INTERP, SELF, property_name, new_property);

  •    /* how big are these property? */
    
  •    /\* how big are these properties? */
     old_size = size(INTERP, SELF, old_property);
     new_size = size(INTERP, SELF, new_property);
    

@parrot
Copy link
Collaborator Author

parrot commented Oct 8, 2010

Trac commenter: ellefu

    <p>

Patch for mk_language_shell.pl bug

@parrot
Copy link
Collaborator Author

parrot commented Oct 8, 2010

1584 byte attachment from ellefu
at http://trac.parrot.org/parrot/raw-attachment/ticket/1819/updated_patch.txt

```Index: tools/dev/mk_language_shell.in

--- tools/dev/mk_language_shell.in (revision 49475)
+++ tools/dev/mk_language_shell.in (working copy)
@@ -647,6 +647,8 @@
SUPER();
};

+/*
+
=item C<PMC* get()>

Returns a vector-like PMC.
@@ -656,12 +658,9 @@
*/

 METHOD PMC* get() {
  •    PMC\* property;
    
  •    INTVAL array_t;
    
  •    STRING\* property_name;
    
  •    PMC\* property = VTABLE_getprop(INTERP, SELF, property_name);
    
  •    STRING* property_name = string_from_literal(INTERP, "property");
    
  •    property_name = string_from_literal(INTERP, "property");
    
  •    shape = VTABLE_getprop(INTERP, SELF, property_name);
     if (PMC_IS_NULL(property)) {
        /*
         \* No property has been set yet. This means that we are
    

    @@ -671,7 +670,7 @@
    * specify it?
    /
    /

  •        array_t = Parrot_pmc_get_type_str(INTERP,
    
  •        INTVAL array_t = Parrot_pmc_get_type_str(INTERP,
             string_from_literal(INTERP, "@lang@"));
         */
         property = Parrot_pmc_new(INTERP, VTABLE_type(INTERP, SELF));
    

    @@ -710,7 +709,7 @@
    old_property = VTABLE_getprop(INTERP, SELF, property_name);
    VTABLE_setprop(INTERP, SELF, property_name, new_property);

  •    /* how big are these property? */
    
  •    /\* how big are these properties? */
     old_size = size(INTERP, SELF, old_property);
     new_size = size(INTERP, SELF, new_property);
    

@leto
Copy link
Member

leto commented Oct 8, 2010

I tried mk_language_shell --with-pmc with parrot 49387 and it compiled and passed tests.

Can you attach the output of "parrot_config revision" and the complete error message that you get when compiling?

@parrot
Copy link
Collaborator Author

parrot commented Oct 8, 2010

Trac commenter: ellefu

Aha! I see the problem. In SVN, there's a separate bug which is masking this bug -- a missing C open-comment after init(). I'll attach a new patch. It may be compiling on your system, but it's not working -- it's just ignoring everything in the .pmc file after init()! pmc2c's almost complete lack of error reporting is becoming quite troublesome.

If I add this patch to my working copy:

--- tools/dev/mk_language_shell.in      (revision 49475)
+++ tools/dev/mk_language_shell.in      (working copy)
@@ -647,6 +647,8 @@
     SUPER();
 };
+/*
+
 =item C<PMC\* get()>
 Returns a vector-like PMC.

...I get this output when I try to do parrot setup.pir build:

cc -c -o  src/pmc/yourmom.o [ten million gcc switches] src/pmc/yourmom.c
./src/pmc/yourmom.pmc: In function âParrot_YourMom_nci_getâ:
./src/pmc/yourmom.pmc:111: error: âshapeâ undeclared (first use in this function)
./src/pmc/yourmom.pmc:111: error: (Each undeclared identifier is reported only once
./src/pmc/yourmom.pmc:111: error: for each function it appears in.)
exit status: 256

...which is the bug my initial patch addressed. I'll update the attachment to contain both fixes. Thanks!

@cotto
Copy link
Contributor

cotto commented Oct 9, 2010

ellefu, I applied (but didn't commit) your patch (updated_patch.txt), and while it does fix some obvious problems, the generated PMC still doesn't build. You're welcome to get the PMC to build properly (and I'll be glad to apply such a patch).

If you're feeling more ambitious, I think it'd be helpful if new HLL developers had a more user-friendly PMC as a template. Looking at the generated PMC, it's not entirely clear what it is or what it's supposed to do. When a new developer comes along, it'd be better to present a PMC with common semantics (i.e. Integer, Hash, etc) so that the developer won't have to spend as much time figuring out what the PMC does before moving on to figuring out how it does it. That said, I'm sure any new developer will spend lots of time looking at Parrot's core PMCs and any dynpmcs available, so there's no need for the template PMC to be anything more than a good clear starting point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants