Permalink
Browse files

[gsoc_nci] gsoc_nci_001 merge

git-svn-id: https://svn.parrot.org/parrot/trunk@30452 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
tewk committed Aug 22, 2008
1 parent 619301d commit 264695152b69c6e06c0ab46626f1c3a31394da91
@@ -0,0 +1,7 @@
# $Id$
N: Kevin Tew
E: kevintew@tewk.com
N: Klaas-Jan Stol (kjs)
E: parrotcode@gmail.com
@@ -0,0 +1,4 @@
Add option to generate dlfuncs for certain h files not all includes.
Allow typedefs and structs with the same name in the symbol table.
Generate ManagedStructs definitions for structs and typedefs.
Generate parrot_builtin_type entries in the AST such as INT NUM STR o PMC
View
@@ -0,0 +1,136 @@
# $Id$
# Copyright (C) 2008, The Perl Foundation.
=head1 TITLE
c99.pir - A C99 compiler.
=head2 Description
This is the base file for the C99 compiler.
This file includes the parsing and grammar rules from
the src/ directory, loads the relevant PGE libraries,
and registers the compiler under the name 'C99'.
=head2 Functions
=over 4
=item onload()
Creates the C compiler using a C<PCT::HLLCompiler>
object.
=cut
.namespace [ 'C99::Compiler' ]
.loadlib 'c99_group'
.sub 'onload' :anon :load :init
load_bytecode 'PCT.pbc'
$P0 = get_hll_global ['PCT'], 'HLLCompiler'
$P1 = $P0.'new'()
$P1.'language'('C99')
$P1.'parsegrammar'('C99::Grammar')
$P1.'parseactions'('C99::Grammar::Actions')
.end
=item main(args :slurpy) :main
Start compilation by passing any command line C<args>
to the C compiler.
=cut
.sub 'main' :main
.param pmc args
$P0 = compreg 'C99'
$P1 = split ' ', 'parse nci_ast gen_nci_pir'
setattribute $P0, '@stages', $P1
$P1 = split ' ', 'e=s help|h target=s trace|t=s encoding=s output|o=s combine version|v libname|l=s nsname|n=s raw|r'
setattribute $P0, '@cmdoptions', $P1
## set the $usage attribute
$P2 = new 'String'
$P2 = <<'USAGE'
Usage: ncigen [switches] [--] [preprocessedfile] [arguments]
-l, --libname library to load symbols from
-n --nsname pir namepsace to place symbols into
-r --raw dump dlfunc pir statements only
Standard HLLCompiler Options:
-e program one line of program
-h, --help display this help text
--target=[stage] specify compilation stage to emit
-t, --trace=[flags] enable trace flags
--encoding=[mode] specify string encoding mode
-o, --output=[name] specify name of output file
-v, --version display version information
USAGE
setattribute $P0, '$usage', $P2
$P2 = $P0.'command_line'(args)
.end
.namespace [ 'PCT::HLLCompiler' ]
.sub 'nci_ast' :method
.param pmc source
.param pmc adverbs :slurpy :named
compile_match:
push_eh err_past
.local pmc ast
ast = source.'item'()
pop_eh
$I0 = isa ast, 'c99AST::Decls'
unless $I0 goto err_past
.return (ast)
err_past:
$S0 = typeof source
.return self.'panic'('Unable to obtain c99AST from ', $S0)
.end
.sub 'gen_nci_pir' :method
.param pmc source
.param pmc adverbs :slurpy :named
$P0 = compreg 'NCIPIR'
$P1 = $P0.'to_pir'(source, adverbs :flat :named)
say $P1
.return ($P1)
.end
.include 'src/c99AST.pir'
.include 'src/NCIPIR.pir'
.include 'src/gen_builtins.pir'
.include 'src/gen_grammar.pir'
.include 'src/gen_actions.pir'
.namespace [ 'C99::Grammar' ]
.sub 'debug'
.param pmc match
.param pmc arg
.param pmc attrs :slurpy
printerr arg
printerr "\n"
.end
=back
=cut
# Local Variables:
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir:
@@ -0,0 +1,121 @@
## $Id$
## arguments we want to run parrot with
PARROT_ARGS =
## configuration settings
BUILD_DIR = @build_dir@
LOAD_EXT = @load_ext@
O = @o@
## Setup some commands
LN_S = @lns@
PERL = @perl@
RM_RF = @rm_rf@
CP = @cp@
PARROT = ../../parrot@exe@
CAT = $(PERL) -MExtUtils::Command -e cat
BUILD_DYNPMC = $(PERL) $(BUILD_DIR)/tools/build/dynpmc.pl
RECONFIGURE = $(PERL) $(BUILD_DIR)/tools/dev/reconfigure.pl
## places to look for things
PARROT_DYNEXT = $(BUILD_DIR)/runtime/parrot/dynext
PGE_LIBRARY = $(BUILD_DIR)/runtime/parrot/library/PGE
PERL6GRAMMAR = $(PGE_LIBRARY)/Perl6Grammar.pbc
NQP = $(BUILD_DIR)/compilers/nqp/nqp.pbc
PCT = $(BUILD_DIR)/runtime/parrot/library/PCT.pbc
PMC_DIR = src/pmc
all: c99.pbc
C_GROUP = $(PMC_DIR)/c_group$(LOAD_EXT)
SOURCES = c99.pir \
src/gen_grammar.pir \
src/gen_actions.pir \
src/gen_builtins.pir \
src/c99AST.pir \
src/NCIPIR.pir \
# $(C_GROUP)
BUILTINS_PIR = \
src/builtins/say.pir \
# PMCS = c
# PMC_SOURCES = $(PMC_DIR)/c.pmc
# the default target
c99.pbc: $(PARROT) $(SOURCES)
$(PARROT) $(PARROT_ARGS) -o c99.pbc c99.pir
src/gen_grammar.pir: $(PERL6GRAMMAR) src/parser/grammar.pg
$(PARROT) $(PARROT_ARGS) $(PERL6GRAMMAR) \
--output=src/gen_grammar.pir \
src/parser/grammar.pg
src/gen_actions.pir: $(NQP) $(PCT) src/parser/actions.pm
$(PARROT) $(PARROT_ARGS) $(NQP) --output=src/gen_actions.pir \
--target=pir src/parser/actions.pm
src/gen_builtins.pir: $(BUILTINS_PIR)
$(CAT) $(BUILTINS_PIR) >src/gen_builtins.pir
$(C_GROUP): $(PARROT) $(PMC_SOURCES)
cd $(PMC_DIR) && $(BUILD_DYNPMC) generate $(PMCS)
cd $(PMC_DIR) && $(BUILD_DYNPMC) compile $(PMCS)
cd $(PMC_DIR) && $(BUILD_DYNPMC) linklibs $(PMCS)
cd $(PMC_DIR) && $(BUILD_DYNPMC) copy --destination=$(PARROT_DYNEXT) $(PMCS)
# This is a listing of all targets, that are meant to be called by users
help:
@echo ""
@echo "Following targets are available for the user:"
@echo ""
@echo " all: c.pbc"
@echo " This is the default."
@echo "Testing:"
@echo " test: Run the test suite."
@echo " testclean: Clean up test results."
@echo ""
@echo "Cleaning:"
@echo " clean: Basic cleaning up."
@echo " realclean: Removes also files generated by 'Configure.pl'"
@echo " distclean: Removes also anything built, in theory"
@echo ""
@echo "Misc:"
@echo " help: Print this help message."
@echo ""
test: all
$(PERL) t/harness
# this target has nothing to do
testclean:
CLEANUPS = \
c99.pbc \
src/gen_grammar.pir \
src/gen_actions.pir \
src/gen_builtins.pir \
$(PMC_DIR)/*.h \
$(PMC_DIR)/*.c \
$(PMC_DIR)/*.dump \
$(PMC_DIR)/*$(O) \
$(PMC_DIR)/*$(LOAD_EXT) \
$(PMC_DIR)/*.exp \
$(PMC_DIR)/*.ilk \
$(PMC_DIR)/*.manifest \
$(PMC_DIR)/*.pdb \
$(PMC_DIR)/*.lib \
clean:
$(RM_RF) $(CLEANUPS)
realclean: clean
$(RM_RF) Makefile
distclean: realclean
Oops, something went wrong.

0 comments on commit 2646951

Please sign in to comment.