Browse files

[gsoc_nci] gsoc_nci_001 merge

git-svn-id: 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
N: Klaas-Jan Stol (kjs)
@@ -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
@@ -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>
.namespace [ 'C99::Compiler' ]
.loadlib 'c99_group'
.sub 'onload' :anon :load :init
load_bytecode 'PCT.pbc'
$P0 = get_hll_global ['PCT'], 'HLLCompiler'
$P1 = $P0.'new'()
=item main(args :slurpy) :main
Start compilation by passing any command line C<args>
to the C compiler.
.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
setattribute $P0, '$usage', $P2
$P2 = $P0.'command_line'(args)
.namespace [ 'PCT::HLLCompiler' ]
.sub 'nci_ast' :method
.param pmc source
.param pmc adverbs :slurpy :named
push_eh err_past
.local pmc ast
ast = source.'item'()
$I0 = isa ast, 'c99AST::Decls'
unless $I0 goto err_past
.return (ast)
$S0 = typeof source
.return self.'panic'('Unable to obtain c99AST from ', $S0)
.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)
.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"
# 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
## 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/
## 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)
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/
--output=src/gen_grammar.pir \
src/gen_actions.pir: $(NQP) $(PCT) src/parser/
$(PARROT) $(PARROT_ARGS) $(NQP) --output=src/gen_actions.pir \
--target=pir src/parser/
src/gen_builtins.pir: $(BUILTINS_PIR)
$(CAT) $(BUILTINS_PIR) >src/gen_builtins.pir
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
@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 ''"
@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
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)/*.exp \
$(PMC_DIR)/*.ilk \
$(PMC_DIR)/*.manifest \
$(PMC_DIR)/*.pdb \
$(PMC_DIR)/*.lib \
realclean: clean
$(RM_RF) Makefile
distclean: realclean
Oops, something went wrong.

0 comments on commit 2646951

Please sign in to comment.