Permalink
Browse files

[Cardinal] Closer to support for classes, blocking on .HLL bug

git-svn-id: https://svn.parrot.org/parrot/trunk/languages/cardinal@14823 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
1 parent 0b75fe9 commit 362250e793a6e0ca1c4b09c5d20462fbeeb2141f @tewk tewk committed Oct 2, 2006
View
20 Parrot_gen/Test.pm
@@ -0,0 +1,20 @@
+#!/usr/bin/perl
+
+use strict;
+use lib qw(t . lib ../lib ../../lib ../../../lib);
+use Parrot::Test tests => 1;
+
+our $counter = 1;
+
+sub language_output_is
+{
+ my ($lang_name, $code, $out, $description) = @_;
+ $0 =~ s/\.t//;
+ open my $OUT, ">$0_$counter.rb";
+ print $OUT "$code\n";
+ close $OUT;
+ $counter++;
+ "ok";
+}
+
+1;
View
21 cardinal.pir
@@ -16,6 +16,7 @@ bytecode (actually to PIR, at first). For more on the ideas behind the
compiler, see:
=cut
+#.HLL 'Ruby', ''
.HLL 'Ruby', 'ruby_group'
.include 'errors.pasm'
.include 'library/dumper.pir'
@@ -38,7 +39,10 @@ compiler, see:
load_bytecode 'languages/cardinal/src/PGE2AST.pir'
load_bytecode 'languages/cardinal/src/AST2OST.pir'
load_bytecode 'languages/cardinal/src/OST2PIR.pir'
+
+ #needed to run compiled tests
load_bytecode 'languages/cardinal/src/builtins_gen.pir'
+ load_bytecode 'languages/cardinal/runtime/cardinallib.pbc'
.local pmc _dumper
.local pmc getopts
@@ -279,11 +283,7 @@ compiler, see:
unless execute_debug goto execute_only
print "\n\nExecution Result:\n"
execute_only:
- .local pmc pir_compiler
- .local pmc pir_compiled
- pir_compiler = compreg "PIR"
- pir_compiled = pir_compiler(pir)
- pir_compiled()
+ cardinal_exec(pir)
end
err_match_fail:
@@ -308,6 +308,17 @@ compiler, see:
exit 0
.end
+#.HLL 'Ruby', 'ruby_group'
+.sub cardinal_exec
+ .param pmc code
+ .local pmc pir_compiler
+ .local pmc pir_compiled
+ pir_compiler = compreg "PIR"
+ pir_compiled = pir_compiler(code)
+ pir_compiled()
+.end
+#.HLL 'Ruby', ''
+
# Read in the source from a file
.sub _get_source
.param string filename
View
17 config/makefiles/root.in
@@ -19,7 +19,7 @@ PARROT_DYNEXT = @build_dir@/runtime/parrot/dynext
PMCDIR = src/pmc
# the default target
-all: cardinal.pbc $(PMCDIR)/ruby_group$(LOAD_EXT)
+all: gen_tests cardinal.pbc $(PMCDIR)/ruby_group$(LOAD_EXT)
PMCS = \
rubyclass \
@@ -66,7 +66,10 @@ GEN_PBC = \
src/PAST.pbc \
src/POST.pbc
-cardinal.pbc: cardinal.pir $(GEN_PIR) $(GEN_PBC)
+RUNTIME_COMPONENTS = \
+ runtime/parts/rubyclass.pir
+
+cardinal.pbc: cardinal.pir runtime/cardinallib.pbc $(GEN_PIR) $(GEN_PBC)
$(PARROT) -o cardinal.pbc --output-pbc cardinal.pir
src/PAST.pbc: src/PAST.pir
@@ -111,6 +114,11 @@ $(PMCDIR)/ruby_group$(LOAD_EXT): $(PARROT) $(PMC_SOURCES)
src/builtins_gen.pir: $(BUILTINS_PIR)
$(CAT) $(BUILTINS_PIR) >src/builtins_gen.pir
+runtime/runtime.pir: $(RUNTIME_COMPONENTS) tools/gen_runtime.pl
+ $(PERL) tools/gen_runtime.pl > runtime/runtime.pir
+
+runtime/cardinallib.pbc: $(PARROT) runtime/cardinallib.pir runtime/runtime.pir $(CLASSES)
+ $(PARROT) --output=runtime/cardinallib.pbc runtime/cardinallib.pir
# This is a listing of all targets, that are meant to be called by users
help:
@@ -132,6 +140,11 @@ help:
@echo " help: Print this help message."
@echo ""
+gen_tests:
+ @mv Parrot_gen Parrot
+ -@t/harness > /dev/null 2>&1
+ @mv Parrot Parrot_gen
+
test: all
$(PERL) -Isrc -I../../src t/harness
View
2 runtime/cardinallib.pir
@@ -0,0 +1,2 @@
+.HLL 'Ruby', 'ruby_group'
+.include 'languages/cardinal/runtime/runtime.pir'
View
21 runtime/parts/rubyclass.pir
@@ -0,0 +1,21 @@
+.HLL 'Ruby', 'ruby_group'
+
+.namespace [ 'RubyClass' ]
+
+.sub 'allocate' :method
+.end
+
+.sub 'inherited' :method
+.end
+
+.sub 'superclass' :method
+.end
+
+.sub 'to_yaml' :method
+.end
+
+.sub 'new' :method
+ .param pmc args :slurpy
+ $P0 = new 'RubyObject'
+ .return ($P0)
+.end
View
91 src/ASTGrammar.tg
@@ -351,18 +351,25 @@ transform result (Cardinal::Grammar::assignment) :language('PIR') {
child2 = tree.get('result', $P0, 'Cardinal::Grammar::expression')
goto build_assignment
- try_command:
+ try_command:
$I0 = defined node['command_call']
- unless $I0 goto try_primary
+ unless $I0 goto try_method_call
$P0 = node['command_call']
child = tree.get('result', $P0, 'Cardinal::Grammar::command_call')
goto single_item
+
+ try_method_call:
+ $I0 = defined node['method_call']
+ unless $I0 goto try_atom
+ $P0 = node['method_call']
+ child = tree.get('result', $P0, 'Cardinal::Grammar::method_call')
+ goto single_item
- try_primary:
- $I0 = defined node['primary']
+ try_atom:
+ $I0 = defined node['atom']
unless $I0 goto err_no_tree
- $P0 = node['primary']
- child = tree.get('result', $P0, 'Cardinal::Grammar::primary')
+ $P0 = node['atom']
+ child = tree.get('result', $P0, 'Cardinal::Grammar::atom')
goto single_item
@@ -408,6 +415,35 @@ transform result (Cardinal::Grammar::command_call) :language('PIR') {
end
}
+transform result (Cardinal::Grammar::method_call) :language('PIR') {
+ .local pmc child
+ .local pmc child2
+
+ $I0 = defined node['atom']
+ unless $I0 goto err_no_tree
+ $P0 = node['atom']
+ $S0 = node['atom']
+ #child = tree.get('result', $P0, 'Cardinal::Grammar::atom')
+ child = new 'Cardinal::PAST::Var'
+ child.'init'('node'=>node, 'name'=> $S0, 'scope'=>'exists')
+
+ $I0 = defined node['operation2']
+ unless $I0 goto err_no_tree
+ $P0 = node['operation2']
+ child2 = tree.get('result', $P0, 'Cardinal::Grammar::operation2')
+
+ .local pmc result
+ result = new 'Cardinal::PAST::MethodCall'
+ result.'init'('node'=>node, 'name'=>child2)
+ result.'add_child'(child)
+ result.'add_child'(child2)
+ .return (result)
+
+ err_no_tree:
+ print "The method_call node doesn't contain a match.\n"
+ end
+}
+
transform result (Cardinal::Grammar::command) :language('PIR') {
.local pmc name
.local pmc result
@@ -574,6 +610,34 @@ transform result (Cardinal::Grammar::operation) :language('PIR') {
end
}
+transform result (Cardinal::Grammar::operation2) :language('PIR') {
+.local pmc name
+
+ $I0 = defined node['IDENTIFIER']
+ unless $I0 goto test_constant
+ $P0 = node['IDENTIFIER']
+ name = tree.get('result', $P0, 'Cardinal::Grammar::IDENTIFIER')
+ .return (name)
+
+ test_constant:
+ $I0 = defined node['CONSTANT']
+ unless $I0 goto test_op
+ $P0 = node['CONSTANT']
+ name = tree.get('result', $P0, 'Cardinal::Grammar::CONSTANT')
+ .return (name)
+
+ test_op:
+ $I0 = defined node['op']
+ unless $I0 goto err_no_name
+ $P0 = node['op']
+ name = tree.get('result', $P0, 'Cardinal::Grammar::op')
+ .return (name)
+
+ err_no_name:
+ print "The PGE operation2 node doesn't contain a 'IDENTIFIER', 'CONSTANT', or a 'op' match.\n"
+ end
+}
+
transform result (Cardinal::Grammar::IDENTIFIER) :language('PIR') {
.local pmc result
@@ -603,17 +667,16 @@ transform result (Cardinal::Grammar::CONSTANT) :language('PIR') {
end
}
-transform result (Cardinal::Grammar::primary) :language('PIR') {
- .local pmc child
- $I0 = defined node['atom']
- unless $I0 goto err_no_tree
- $P0 = node['atom']
- child = tree.get('result', $P0, 'Cardinal::Grammar::atom')
+transform result (Cardinal::Grammar::op) :language('PIR') {
+ $S0 = node
- .return (child)
+ .local pmc result
+ result = new 'Cardinal::PAST::Val'
+ result.'init'('node'=>node, 'name'=>$S0, 'valtype'=>'op')
+ .return (result)
err_no_tree:
- print "The primary node doesn't contain a 'atom' match.\n"
+ print "The op node doesn't contain an 'op' match.\n"
end
}
View
74 src/OSTGrammar.tg
@@ -41,9 +41,11 @@ transform root (ROOT) :language('PIR') {
self.'past_scope_stack'($P0)
#hll statement
+ .local pmc dumper
+ dumper = new 'Cardinal::POST::Raw'
+ dumper.'init'('node'=>node, 'raw'=>".include 'library/dumper.pir'")
.local pmc hll
hll = new 'Cardinal::POST::Raw'
- #hll.'init'('node'=>node, 'raw'=>".HLL 'Ruby', ''")
hll.'init'('node'=>node, 'raw'=>".HLL 'Ruby', 'ruby_group'")
#__onload
@@ -94,11 +96,14 @@ transform root (ROOT) :language('PIR') {
call_op = new 'Cardinal::POST::Call'
call_op.'init'('node'=>node, 'name'=>$S0)
- .local pmc builtins
- builtins = new 'Cardinal::POST::Op'
- builtins.'init'("'languages/cardinal/src/builtins_gen.pir'", 'node'=>node, 'name'=>'load_bytecode')
main.'add_child'(BEGIN_blocks)
- main.'add_child'(builtins)
+ .local pmc includes
+ includes = new 'Cardinal::POST::Op'
+ includes.'init'("'languages/cardinal/src/builtins_gen.pir'", 'node'=>node, 'name'=>'load_bytecode')
+ main.'add_child'(includes)
+ includes = new 'Cardinal::POST::Op'
+ includes.'init'("'languages/cardinal/runtime/cardinallib.pbc'", 'node'=>node, 'name'=>'load_bytecode')
+ main.'add_child'(includes)
main.'add_child'(call_op)
main.'add_child'(END_blocks)
@@ -111,6 +116,7 @@ transform root (ROOT) :language('PIR') {
namespaces = self.'push_namespace'()
#build up top level ops
+ #ops.'add_child'(dumper)
ops.'add_child'(hll)
ops.'add_child'(main)
ops.'add_child'(load)
@@ -260,18 +266,22 @@ transform post (Cardinal::PAST::Class) :language('PIR') {
self.'post_scope_stack'(post)
self.'past_scope_stack'(node)
- .local pmc op
- .local pmc op1
- .local pmc op1_value
- op1 = new 'Cardinal::POST::Op'
- op1_value = op1.'value'()
- op1.'init'(op1_value, "'RubyClass'", 'node'=>node, 'name'=>'getclass')
- post.'add_child'(op1)
- op = new 'Cardinal::POST::Op'
+ #register new class in parent namespace
+ .local pmc getclass_op
+ .local pmc subclass_op
+ .local pmc set_hll_global_op
+ getclass_op = new 'Cardinal::POST::Op'
+ getclass_op.'init'(getclass_op, "'RubyClass'", 'node'=>node, 'name'=>'getclass')
+ post.'add_child'(getclass_op)
$S0 = concat "'", class_name
$S0 .= "'"
- op.'init'(op1, $S0, 'node'=>node, 'name'=>'subclass')
- post.'add_child'(op)
+ subclass_op = new 'Cardinal::POST::Op'
+ subclass_op.'init'(subclass_op, getclass_op, $S0, 'node'=>node, 'name'=>'subclass')
+ post.'add_child'(subclass_op)
+
+ set_hll_global_op = new 'Cardinal::POST::Op'
+ set_hll_global_op.'init'($S0, subclass_op, 'node'=>node, 'name'=>'set_hll_global')
+ post.'add_child'(set_hll_global_op)
.local pmc iter
iter = node.'child_iter'()
@@ -855,6 +865,40 @@ transform post (Cardinal::PAST::FunctionCall) :language('PIR') {
.return (post)
}
+transform post (Cardinal::PAST::MethodCall) :language('PIR') {
+ .local pmc obj
+ .local pmc opost
+ .local pmc ops
+ .local pmc post
+ .local pmc call
+
+
+ ops = new 'Cardinal::POST::Ops'
+ ops.'init'('node'=>node)
+
+ obj = node[0]
+ opost = tree.'get'('post', obj)
+ ops.'add_child'(opost)
+
+ $P0 = node[1]
+ $S1 = $P0
+
+ $S0 = ops.'value'()
+ $S0 .= ' = '
+ $S2 = opost.'value'()
+ $S0 .= $S2
+ $S0 .= '.'
+ $S0 .= "'"
+ $S0 .= $S1
+ $S0 .= "'"
+ $S0 .= '()'
+
+ call = new 'Cardinal::POST::Op'
+ call.'init'('node'=>node, 'name'=>$S0)
+ ops.'add_child'(call)
+ .return (ops)
+}
+
=head1 LICENSE
Copyright (C) 2006, The Perl Foundation.
View
1 src/PAST.pir
@@ -36,6 +36,7 @@ needed for Ruby 1.9. The currently defined ast nodes:
$P0 = subclass base, 'Cardinal::PAST::Stmts'
$P0 = subclass base, 'Cardinal::PAST::Sub'
$P0 = subclass base, 'Cardinal::PAST::FunctionCall'
+ $P0 = subclass base, 'Cardinal::PAST::MethodCall'
$P0 = subclass base, 'Cardinal::PAST::WhileUntil'
$P0 = subclass base, 'Cardinal::PAST::For'
View
136 src/cardinal_rules.pg
@@ -23,16 +23,41 @@ rule body_statement { <compound_statement> <rescue_clause>? <else_clause>? <ensu
rule compound_statement { <?terminators>? [ <statement> <?terminators> ]* <statement>? <?terminators>? }
rule statement {
- |$<ALIAS>:=<'alias'> [ <function_item> <function_item>
- | <GLOBAL_VARIABLE> [ <GLOBAL_VARIABLE> | <back_reference> ] ]
- |$<UNDEF>:=<'undef'> <undef_list>
- |$<BEGIN>:=<'BEGIN'> \{ <compound_statement> \}
- |$<END>:=<'END'> \{ <compound_statement> \}
- |<lang_statements>
- |<expression> [$<MODIFIER>:=[<'if'>|<'unless'>|<'while'>|<'until'>] <expression>
+ | $<ALIAS>:=<'alias'> [ | <function_item> <function_item>
+ | <GLOBAL_VARIABLE> [ <GLOBAL_VARIABLE> | <back_reference> ] ]
+ | $<UNDEF>:=<'undef'> <undef_list>
+ | $<BEGIN>:=<'BEGIN'> \{ <compound_statement> \}
+ | $<END>:=<'END'> \{ <compound_statement> \}
+ | <lang_statements>
+ | <expression> [$<MODIFIER>:=[<'if'>|<'unless'>|<'while'>|<'until'>] <expression>
|$<rescue>:=<'rescue'> <statement>]?
}
+rule lang_statements {
+ | $<return>:=<'return'>
+ | $<break>:=<'break'>
+ | $<next>:=<'next'>
+ | $<redo>:=<'redo'>
+ | $<retry>:=<'retry'>
+ | $<yield>:=<'yield'> [\( <call_args>? <rparen>]? #\)
+ | $<defined>:=<'defined'> <newline>? \( <expression> <rparen> #\)
+# |<operation> <brace_block> # put this in method call
+# |<method_call> <brace_block>?
+ | $<lambda>:=<'->'> <lambda>
+ | $<begin>:=<'begin'> <body_statement> <'end'>
+ | <if_clause>
+ | $<unless>:=<'unless'> <expression> <then_clause> <compound_statement> <else_clause>? <'end'>
+ | $<while_until>:=<'while'> <expression> <'do'>? <compound_statement> <'end'>
+ | $<while_until>:=<'until'> <expression> <'do'>? <compound_statement> <'end'>
+ | $<case>:=<'case'> <?terminators>? <expression> <?terminator>? [<WHEN> <expression> <then_clause> <compound_statement>]+ <else_clause>? <'end'>
+ | $<for>:=<'for'> <for_variable> <'in'> <expression> <compound_statement> <'end'>
+ | $<class>:=<'class'> <class_path> <superclass> <'do'>? <body_statement> <'end'>
+ | $<class2>:=<'class'> <'<<'> <expression> <term> <body_statement> <'end'>
+ | $<module>:=<'module'> <class_path> <body_statement> <'end'>
+ | $<def>:=<'def'> [<singleton> [<'.'>|<'::'>]]? <function_name> <function_prototype_arg_list> <body_statement> <'end'>
+}
+
+
## We enter the operator precedance expression parser HERE
rule expression { <operator_precedence_parser> }
@@ -57,7 +82,8 @@ rule assignment {
| \:\: <CONSTANT> <ASSIGN_OP> <expression>
| [\!]? <command_call>
- | <primary>
+ | <method_call> <brace_block>?
+ | <atom>
}
token ASSIGN_OP {
@@ -77,20 +103,24 @@ token ASSIGN_OP {
| <'**='>
}
+ #<operation> [<paren_args> <brace_block>?|<brace_block>]
rule method_call {
- <operation> [<paren_args> <brace_block>?|<brace_block>]
-
- | <atom> [[<'.'>|<'::'>][<operation2> <paren_args>? <brace_block>? | <paren_args><brace_block>? ]
- | <'::'> <operation3> <brace_block>?
- | \[ <call_args>? <rbracket> <brace_block>? ]
+ | <atom>
+ [
+ | [<'.'>|<'::'>][<operation2> <paren_args>? <brace_block>? | <paren_args> <brace_block>? ]
+ | <'::'> <operation3> <brace_block>?
+ #| \[ <call_args>? <rbracket> <brace_block>? ]
+ | <call_args>? <rbracket> <brace_block>?
+ ]
| <'super'> <paren_args> <brace_block>?
}
rule method_call_block {
- | \{ <block_parameter>? <compound_statement> \}
- | <'do'> <block_parameter>? <compound_statement> <'end'>
+ | <brace_block>
+ | <do_block>
}
+rule brace_block { \{ <block_parameter>? <compound_statement> \} }
rule do_block { <'do'> <block_parameter>? <compound_statement> <'end'> }
rule command_call {
@@ -280,52 +310,24 @@ rule multiple_right_hand_side {
| \* <expression>
}
-rule primary {
- | <atom>[<'::'><CONSTANT>]?
-# | <operation> <brace_block> # put this in method call
-# | <method_call> <brace_block>?
-}
-
rule atom {
- | <literal>
- | <string>
- | <xstring>
- | <regexp>
- | <words>
- | <qwords>
- | <back_reference>
- | <FID>
- | \( <expression> <rparen>
- | \( <compound_statement> \)
- | \:\: <CONSTANT>
- | \[ <array_reference_args>? \]
- | \{ <assoc_list> \}
- #|<lang_statements>
- | <variable>
-}
-
-rule lang_statements {
- | <'return'>
- | <'break'>
- | <'next'>
- | <'redo'>
- | <'retry'>
- | <'yield'> [\( <call_args>? <rparen>]? #\)
- | <'defined'> <newline>? \( <expression> <rparen> #\)
-# |<operation> <brace_block> # put this in method call
-# |<method_call> <brace_block>?
- | <'->'> <lambda>
- | $<begin>:=<'begin'> <body_statement> <'end'>
- | <if_clause>
- | $<unless>:=<'unless'> <expression> <then_clause> <compound_statement> <else_clause>? <'end'>
- | $<while_until>:=<'while'> <expression> <'do'>? <compound_statement> <'end'>
- | $<while_until>:=<'until'> <expression> <'do'>? <compound_statement> <'end'>
- | $<case>:=<'case'> <?terminators>? <expression> <?terminator>? [<WHEN> <expression> <then_clause> <compound_statement>]+ <else_clause>? <'end'>
- | $<for>:=<'for'> <for_variable> <'in'> <expression> <compound_statement> <'end'>
- | $<class>:=<'class'> <class_path> <superclass> <'do'>? <body_statement> <'end'>
- | $<class2>:=<'class'> <'<<'> <expression> <term> <body_statement> <'end'>
- | $<module>:=<'module'> <class_path> <body_statement> <'end'>
- | $<def>:=<'def'> [<singleton> [<'.'>|<'::'>]]? <function_name> <function_prototype_arg_list> <body_statement> <'end'>
+ [
+ | <literal>
+ | <string>
+ | <xstring>
+ #| <regexp>
+ | <words>
+ | <qwords>
+ | <back_reference>
+ | <FID>
+ | \( <expression> <rparen>
+ | \( <compound_statement> \)
+ | \:\: <CONSTANT>
+ | \[ <array_reference_args>? \]
+ | \{ <assoc_list> \}
+ #|<lang_statements>
+ | <variable>
+ ][<'::'><CONSTANT>]?
}
rule if_clause {
@@ -447,29 +449,29 @@ rule undef_list { [<fitem> \,]* <fitem> }
token LABEL { \: <IDENTIFIER> }
token INTEGER {
- | <DECIMAL>
+ | <?DECIMAL>
| 0 [<[0..7]> | _]* <[0..7]>
| 0 <[xX]> $hex:=[[ <xdigit> | _ ]* <xdigit> ]
| 0 <[bB]> $bin:=[[ <[01]> | _ ]* <[01]> ]
| 0 <[dD]> $dec:=[[ <digit> | _ ] <digit> ]
}
token FLOAT {
- <DECIMAL>
+ <?DECIMAL>
[
- |\. <DIGITS> <EXPONENT>?
- | <EXPONENT>
+ |\. <?DIGITS> <?EXPONENT>?
+ | <?EXPONENT>
]
}
token DECIMAL { 0 | <[1..9]> [ [_]? <digit> ]* }
token DIGITS { <digit> [ [_]? <digit>]* }
token EXPONENT { <[eE]> <[+\-]>? <DIGITS> }
#Identifiers
token ident { [ <alnum> | _ ] }
-token CONSTANT { <upper> <ident>* } #starts with an uppercase letter eg Class and Module names
-token IDENTIFIER { <!reserved_words> [ <lower> | _ ] <ident>* } #starts with a lowercase letter eg variables
+token CONSTANT { <?upper> <?ident>* } #starts with an uppercase letter eg Class and Module names
+token IDENTIFIER { <!reserved_words> [ <?lower> | _ ] <?ident>* } #starts with a lowercase letter eg variables
token SYMBOL { \:<SYMBOL_NAME> }
-token SYMBOL_NAME { <ident>+ }
+token SYMBOL_NAME { <?ident>+ }
token GLOBAL_VARIABLE {\$[<[~*$?!@/\\;,.=:<>"]>|<IDENTIFIER>|<CONSTANT>]}
token CLASS_VARIABLE { <'@@'><IDENTIFIER> }
View
8 src/pmc/rubybignum.pmc
@@ -11,7 +11,13 @@
#include "parrot/parrot.h"
-pmclass RubyBignum extends BigInt extends RubyObject dynpmc group ruby_group hll Ruby maps BigInt {
+pmclass RubyBignum
+ extends BigInt
+ extends RubyObject
+ dynpmc
+ group ruby_group
+ hll Ruby
+ maps BigInt {
METHOD PMC* interpret() {
return SELF;
View
7 src/pmc/rubyclass.pmc
@@ -24,8 +24,10 @@ static INTVAL dynpmc_RubyString;
static INTVAL dynpmc_RubyFloat;
static INTVAL dynpmc_RubyInteger;
-pmclass RubyClass dynpmc group ruby_group {
-
+pmclass RubyClass
+ dynpmc
+ group ruby_group
+{
void class_init() {
if (pass) {
dynpmc_RubyString = pmc_type(INTERP,
@@ -51,6 +53,7 @@ pmclass RubyClass dynpmc group ruby_group {
type = dynpmc_RubyFloat;
break;
}
+
pmc_reuse(INTERP, SELF, type, 0);
}
View
8 src/pmc/rubycomplex.pmc
@@ -11,7 +11,13 @@
#include "parrot/parrot.h"
-pmclass RubyComplex extends Complex extends RubyObject dynpmc group ruby_group hll Ruby maps Complex {
+pmclass RubyComplex
+ extends Complex
+ extends RubyObject
+ dynpmc
+ group ruby_group
+ hll Ruby
+ maps Complex {
METHOD PMC* interpret() {
return SELF;
View
9 src/pmc/rubyfixnum.pmc
@@ -11,7 +11,14 @@
#include "parrot/parrot.h"
-pmclass RubyFixnum extends Integer extends RubyObject dynpmc group ruby_group hll Ruby maps Integer {
+pmclass RubyFixnum
+ extends Integer
+ extends RubyObject
+ does integer
+ dynpmc
+ group ruby_group
+ hll Ruby
+ maps Integer {
METHOD PMC* interpret() {
return SELF;
View
9 src/pmc/rubyfloat.pmc
@@ -15,7 +15,14 @@
#define RUBY_NUMBER_FMT ("%.14g")
-pmclass RubyFloat extends Float extends RubyObject dynpmc group ruby_group hll Cardinal maps Float {
+pmclass RubyFloat
+ extends Float
+ extends RubyObject
+ does float
+ dynpmc
+ group ruby_group
+ hll Cardinal
+ maps Float {
STRING* get_string () {
UINTVAL buflen;
View
10 src/pmc/rubyhash.pmc
@@ -29,7 +29,15 @@ This is the Hash PMC for the Ruby implementation.
#include "parrot/parrot.h"
-pmclass RubyHash extends Hash extends RubyObject need_ext does hash dynpmc group ruby_group hll Ruby maps Hash {
+pmclass RubyHash
+ extends Hash
+ extends RubyObject
+ does hash
+ need_ext
+ dynpmc
+ group ruby_group
+ hll Ruby
+ maps Hash {
}
View
12 src/pmc/rubyinteger.pmc
@@ -11,12 +11,18 @@
#include "parrot/parrot.h"
-pmclass RubyInteger extends Integer extends RubyObject dynpmc group ruby_group hll Ruby maps Integer {
-
+pmclass RubyInteger
+ extends Integer
+ extends RubyObject
+ does integer
+ dynpmc
+ group ruby_group
+ hll Ruby
+ maps Integer
+{
METHOD PMC* interpret() {
return SELF;
}
-
}
View
5 src/pmc/rubyobject.pmc
@@ -24,7 +24,10 @@ static INTVAL dynpmc_RubyString;
static INTVAL dynpmc_RubyFloat;
static INTVAL dynpmc_RubyInteger;
-pmclass RubyObject dynpmc group ruby_group {
+pmclass RubyObject
+ dynpmc
+ group ruby_group
+{
void class_init() {
if (pass) {
View
8 src/pmc/rubyrange.pmc
@@ -11,7 +11,13 @@
#include "parrot/parrot.h"
-pmclass RubyRange need_ext extends Slice dynpmc group ruby_group hll Ruby {
+pmclass RubyRange
+ need_ext
+ extends Slice
+ dynpmc
+ group ruby_group
+ hll Ruby
+{
METHOD PMC* interpret() {
return SELF;
View
10 src/pmc/rubystring.pmc
@@ -15,8 +15,14 @@
static STRING *true, *false, *yes, *no;
-pmclass RubyString extends String dynpmc group ruby_group hll Ruby maps String {
-
+pmclass RubyString
+ extends String
+ does string
+ dynpmc
+ group ruby_group
+ hll Ruby
+ maps String
+{
void class_init () {
PMC *string_anchor;
INTVAL fixedstringarray_typenum;
View
36 tools/gen_runtime.pl
@@ -0,0 +1,36 @@
+#! perl
+use strict;
+use warnings;
+use lib qw(lib);
+
+my $runtime_dir = 'runtime/parts';
+
+print <<EOH;
+# This file automatically generated by $0.
+
+EOH
+
+my @runtime_cmds = pir_cmds_in_dir($runtime_dir);
+
+print ".HLL 'Ruby', 'ruby_group'\n";
+
+print " .include 'languages/cardinal/$runtime_dir/$_.pir'\n"
+ for @runtime_cmds;
+
+sub pir_cmds_in_dir {
+ my ($dir) = @_;
+
+ opendir(DIR,$dir);
+ # only return pir files (and strip the extension)
+ my @files = grep {s/\.pir$//} readdir(DIR);
+ closedir(DIR);
+
+ return @files;
+}
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:

0 comments on commit 362250e

Please sign in to comment.