Thanks. Applied.

On Tue, 18 Sep 2001, Simon Cozens wrote:

> This enables typecasting between I and N registers, fixes up the
> error messages, and makes "var num" not require an assignment.
> 
> I note that some pseudo-ops don't work, and "mod" doesn't work
> as a pseudo op with a constant; nor does "pow" and similar functions
> work at all. :( Thinking about how to make these better...
> 
> Simon
> 
> ? factor.jako
> Index: jakoc
> ===================================================================
> RCS file: /home/perlcvs/parrot/little_languages/jakoc,v
> retrieving revision 1.5
> diff -d -u -r1.5 jakoc
> --- jakoc     2001/09/17 12:49:31     1.5
> +++ jakoc     2001/09/18 09:11:46
> @@ -339,7 +339,18 @@
>    if ($ident{$name}) {
>      if ($type eq '*') {
>        if ($ident{$value}) {
> -        printf "%-12s %-8s %s\n", '', 'set', "$ident{$name}{REG}, 
>$ident{$value}{REG}";
> +        if ($ident{$name}{TYPE} ne $ident{$value}{TYPE}) {
> +          if ($ident{$name}{TYPE} eq "N" and $ident{$value}{TYPE} eq "I") {
> +            printf "%-12s %-8s %s\n", '', 'iton', "$ident{$name}{REG}, 
>$ident{$value}{REG}";
> +          } elsif ($ident{$name}{TYPE} eq "I" and $ident{$value}{TYPE} eq "N") {
> +            printf "%-12s %-8s %s\n", '', 'ntoi', "$ident{$name}{REG}, 
>$ident{$value}{REG}";
> +          } else {
> +            printf(STDERR "jako: Cannot assign type '%s' to type '%s' on line 
>%d.\n", 
> +                    $ident{$value}{TYPE}, $ident{$name}{TYPE}, $line);
> +          }
> +        } else {
> +            printf "%-12s %-8s %s\n", '', 'set', "$ident{$name}{REG}, 
>$ident{$value}{REG}";
> +        }
>        } else {
>          printf(STDERR "jako: Assignment from undefined variable '%s' on line %d.\n",
>            $value, $line);
> @@ -402,7 +413,7 @@
>        printf "%-12s %-8s %s\n", '', $name, $arg;
>      }
>    } else {
> -    printf(STDERR "jako: Unrecognized function '$name' on line %d.\n", $name, 
>$line);
> +    printf(STDERR "jako: Unrecognized function '%s' on line %d.\n", $name, $line);
>    }
>  }
>  
> @@ -419,7 +430,7 @@
>      @args = map_args($dest, @args);
>      printf "%-12s %-8s %s\n", '', $name, join(", ", @args);
>    } else {
> -    printf(STDERR "jako: Unrecognized function '$name' on line %d.\n", $name, 
>$line);
> +    printf(STDERR "jako: Unrecognized function '%s' on line %d.\n", $name, $line);
>    }
>  }
>  
> @@ -675,7 +686,7 @@
>    #
>  
>    if ((m/^var\s+(i)nt(eger)?\s+([A-Za-z][A-Za-z0-9_]*)(\s*=\s*(\d+))?$/) ||
> -      (m/^var\s+(n)um(ber)?\s+([A-Za-z][A-Za-z0-9_]*)(\s*=\s*(\d+(\.\d+)))$/) ||
> +      (m/^var\s+(n)um(ber)?\s+([A-Za-z][A-Za-z0-9_]*)(\s*=\s*(\d+(\.\d+)))?$/) ||
>        
>(m/^var\s+(s)tr(ing)?\s+([A-Za-z][A-Za-z0-9_]*)(\s*=\s*(\"[^\\\"]*(?:\\.[^\\\"]*)*\"))?$/))
> { 
>      declare_var($3, uc($1));
>      assign_var($3, uc($1), $5) if defined $5;
> 
> -- 
> Reporter (to Mahatma Gandhi): Mr Gandhi, what do you think of Western
>       Civilization?
> Gandhi:       I think it would be a good idea.
> 
> 

Reply via email to