Author: leo
Date: Fri Jul 29 03:37:40 2005
New Revision: 8728
Added:
branches/leo-ctx5/build_tools/parrotdef.pl
- copied unchanged from rev 8719, trunk/build_tools/parrotdef.pl
Modified:
branches/leo-ctx5/MANIFEST
branches/leo-ctx5/build_tools/pmc2c.pl
branches/leo-ctx5/config/gen/makefiles/dynclasses.in
branches/leo-ctx5/config/gen/makefiles/dynclasses_pl.in
branches/leo-ctx5/config/gen/makefiles/root.in
branches/leo-ctx5/config/gen/makefiles/tcl.in
branches/leo-ctx5/config/init/hints/mswin32.pl
branches/leo-ctx5/include/parrot/interpreter.h
branches/leo-ctx5/include/parrot/pmc.h
branches/leo-ctx5/languages/tcl/t/tcl_pir_compiler.t
Log:
Merge the rest from trunk
* svn merge -r8711:8714
* svn merge -r8716:8719
* svn merge -r8722:8723
Modified: branches/leo-ctx5/MANIFEST
==============================================================================
--- branches/leo-ctx5/MANIFEST (original)
+++ branches/leo-ctx5/MANIFEST Fri Jul 29 03:37:40 2005
@@ -37,6 +37,7 @@ build_tools/list_unjitted.pl
build_tools/ops2c.pl [devel]
build_tools/ops2pm.pl [devel]
build_tools/parrot_config_c.pl []
+build_tools/parrotdef.pl
build_tools/pbc2c.pl [devel]
build_tools/pmc2c.pl []
build_tools/revision_c.pl [devel]
@@ -1443,6 +1444,9 @@ languages/tcl/tcl.pir_template
languages/tcl/tcl.pl [tcl]
languages/tcl/tcl-test.pl [tcl]
languages/testall []
+languages/unlambda/README [unlambda]
+languages/unlambda/hello.unl [unlambda]
+languages/unlambda/unl.pir [unlambda]
languages/urm/INSTALL [urm]
languages/urm/LICENSE [urm]
languages/urm/README [urm]
Modified: branches/leo-ctx5/build_tools/pmc2c.pl
==============================================================================
--- branches/leo-ctx5/build_tools/pmc2c.pl (original)
+++ branches/leo-ctx5/build_tools/pmc2c.pl Fri Jul 29 03:37:40 2005
@@ -718,6 +718,85 @@ sub gen_c {
Parrot::Pmc2c::Library
->new( \%opt, read_dump($include, "vtable.pmc"), %pmcs )
->write_all_files;
+
+ gen_def($include, \%pmcs) if $^O eq 'MSWin32';
+}
+
+#
+# gen_def( [$dir1, $dir2], \%pmc )
+#
+# Generate a .def file for symbols to export for dynamic PMCs.
+#
+sub gen_def {
+ my ($include, $pmcs) = @_;
+
+ my ($pmcfilename, $pmcname);
+ my %groups;
+ foreach $pmcfilename (keys %$pmcs) {
+ # Skip for non-dynpmcs.
+ next unless $pmcs->{$pmcfilename}->{flags}->{dynpmc};
+
+ # Get copy of name without extension.
+ $pmcname = $pmcfilename;
+ $pmcname =~ s/\.pmc$//;
+
+ # Locate .h file and add everything it exports to a list.
+ my @exports = ();
+ my $file = find_file($include, "pmc_$pmcname.h", 1);
+ print "Reading $file\n" if $opt{verbose};
+ open my $fh, "<", $file or die "Can't read '$file'";
+ while (<$fh>) {
+ if (/^(?:extern\s+)?\w+\*?\s+\*?(\w+)\s*\([^)]+\)\s*;/) {
+ push @exports, $1;
+ }
+ }
+ close $fh;
+
+ # Locate .c file and add everything it exports to a list.
+ $file = find_file($include, "$pmcname.c", 1);
+ print "Reading $file\n" if $opt{verbose};
+ open $fh, "<", $file or die "Can't read '$file'";
+ while (<$fh>) {
+ if (/^(?:extern\s+)?\w+\*?\s+\*?(\w+)\s*\([^)]+\)\s*;/) {
+ push @exports, $1;
+ }
+ }
+ close $fh;
+
+ # If it's in a group, put it in group's PMC array.
+ if ($pmcs->{$pmcfilename}->{flags}->{group}) {
+ for (keys %{$pmcs->{$pmcfilename}->{flags}->{group}}) {
+ $groups{$_} = [] unless $groups{$_};
+ push @{$groups{$_}}, @exports;
+ }
+ }
+
+ # Generate .def file for it.
+ # XXX JW Needn't generate these for PMCs in a group?
+ # For now, simplifies sutff.
+ $file =~ s/\.c$/.def/;
+ print "Writing $file\n" if $opt{verbose};
+ open $fh, ">", $file or die "Can't write '$file'";
+ print $fh "LIBRARY $pmcname\nEXPORTS\n";
+ print $fh "\t$_\n" foreach @exports;
+ close $fh;
+ }
+
+ # Generate .def file for groups.
+ for my $group (keys %groups) {
+ # Get filename of where we'll stash the .def file.
+ my $deffile = "$group.def";
+
+ # Does the DEF file already exist?
+ my $defexists = -e $deffile ? 1 : 0;
+
+ # Open the file to append to it.
+ print "Writing $deffile\n" if $opt{verbose};
+ open my $fh, ">>", $deffile or die "Can't write '$deffile'";
+ print $fh "LIBRARY $group\nEXPORTS\n\tParrot_lib_${group}_load\n"
unless $defexists;
+ print $fh "\t$_\n" foreach @{$groups{$group}};
+ close $fh;
+ }
}
#
Modified: branches/leo-ctx5/config/gen/makefiles/dynclasses.in
==============================================================================
--- branches/leo-ctx5/config/gen/makefiles/dynclasses.in (original)
+++ branches/leo-ctx5/config/gen/makefiles/dynclasses.in Fri Jul 29
03:37:40 2005
@@ -64,6 +64,8 @@ dynext-clean :
$(RM_F) *.ilk
# win32 exported functions and data items
$(RM_F) *.exp
+# win32 export definition files
+ $(RM_F) *.def
clean : testclean dynext-clean
$(RM_F) *.c pmc_*.h *_group.h *$(LOAD_EXT) *.dump lib-* *$(O)
Modified: branches/leo-ctx5/config/gen/makefiles/dynclasses_pl.in
==============================================================================
--- branches/leo-ctx5/config/gen/makefiles/dynclasses_pl.in (original)
+++ branches/leo-ctx5/config/gen/makefiles/dynclasses_pl.in Fri Jul 29
03:37:40 2005
@@ -31,7 +31,7 @@ our $O = qq[${o}];
our $LIBPARROT = qq[${build_dir}/src/extend${o}];
# XXX: ultimately, this should be replaced with:
# $LIBPARROT = qq[-L../blib/lib -lparrot];
-our $CFLAGS = qq[${ccflags} ${cc_shared} ${cc_debug} ${ccwarn} ${cc_hasjit}
${cg_flag} ${gc_flag}];
+our $CFLAGS = qq[${ccflags} ${cc_shared} ${cc_debug} ${ccwarn} ${cc_hasjit}
${cg_flag} ${gc_flag} ${cc_building_dynclass_flag}];
# Here comes some stuff for Win32.
our $PATHQUOTE = '';
@@ -40,10 +40,11 @@ if ($^O eq 'MSWin32') {
$PATHQUOTE = '"';
# Also need various libraries in the link line.
- my $extraLibs = '${blib_lib_libparrot_a} ${libs} ${icu_shared}
..\\src\\parrot_config.obj';
+ my $extraLibs = '${libs} ${icu_shared}';
$extraLibs =~ s/blib/..\\blib/g;
$extraLibs =~ s/\Q$(A)\E/.lib/g;
$LD_LOAD_FLAGS =~ s/(-def:)/$extraLibs $1..\\/;
+ $LIBPARROT = '${build_dir}/parrot.lib';
}
# PMC2C Config
@@ -63,17 +64,20 @@ sub compile_cmd {
sub partial_link_cmd {
my ($target, $libs, $sources) = @_;
-
+
my $liblist;
+ my $def = '';
if ($^O =~ /mswin32/i) {
$liblist = join( ' ', map { "$_.lib" } keys %$libs );
+ $def = "-def:$target ";
+ $def =~ s/\.dll/.def/i;
} else {
$liblist = join( ' ', map { "-l$_" } keys %$libs );
}
return
"$LD $LDFLAGS $LD_LOAD_FLAGS $liblist $PATHQUOTE$LIBPARROT$PATHQUOTE ".
- "${ld_out}" . $target . " " .
+ "${ld_out}" . $target . " " . $def .
join(" ", map {"$PATHQUOTE$_$PATHQUOTE"} @$sources);
}
Modified: branches/leo-ctx5/config/gen/makefiles/root.in
==============================================================================
--- branches/leo-ctx5/config/gen/makefiles/root.in (original)
+++ branches/leo-ctx5/config/gen/makefiles/root.in Fri Jul 29 03:37:40 2005
@@ -2,6 +2,13 @@
# $Id$
###############################################################################
+# NOTES:
+#
+# This makefile makes use of specific .dummy targets (rather than .PHONY
+# or .VIRTUAL targets) in an effort to work with various flavors of make.
+###############################################################################
+
+###############################################################################
#
# INSTALL CONFIGURATIONS:
#
@@ -654,10 +661,13 @@ runtime/parrot/include/config.fpmc : myc
@echo If the next line prints $(VERSION), it did help.
$(MINIPARROT) parrot-config.imc VERSION DEVEL
+parrot.def :
+ perl build_tools/parrotdef.pl
+
$(PARROT) : $(IMCC_DIR)/main$(O) $(GEN_HEADERS) $(LIBPARROT) \
lib/Parrot/OpLib/core.pm $(SRC_DIR)/parrot_config$(O) \
- $(MINIPARROT)
- $(LINK) ${ld_out}$(PARROT) $(LINKFLAGS) $(LINK_DYNAMIC) \
+ $(MINIPARROT) ${parrot_exe_def}
+ $(LINK) ${ld_out}$(PARROT) $(LINKFLAGS) $(LINK_DYNAMIC)
${ld_parrot_exe_def} \
$(IMCC_DIR)/main$(O) $(ALL_PARROT_LIBS) $(SRC_DIR)/parrot_config$(O)
#
# TODO build the real miniparrot
@@ -1192,7 +1202,7 @@ test : test_prep
$(PERL) t/harness $(EXTRA_TEST_ARGS) $(PARROT_ARGS) $(TEST_FILES)
$(SRC_TEST_FILES) $(PERL_TEST_FILES)
# Test various run cores and other stuff
-# 'testC', 'testg' and 'testj' are tested only,
+# 'testC', 'testg' and 'testj' are tested only
# when the needed runcores are available
fulltest : \
testb \
@@ -1315,6 +1325,7 @@ prog-clean :
$(PERL) build_tools/c2str.pl --init
$(RM_F) $(STR_FILES) $(INC_DIR)/string_private_cstring.h
$(RM_F) classes/*.c classes/*.h classes/*.dump vtable.dump
+ $(RM_F) *.def *.lib *.exp
dynext-clean :
# shared libs
@@ -1328,7 +1339,8 @@ dynext-clean :
$(RM_F) *.ilk $(DYNEXT_DIR)/*.ilk
# win32 exported functions and data items
$(RM_F) $(DYNEXT_DIR)/*.exp
-
+# win32 export definition files
+ $(RM_F) *.def
# Remove files generated by the test suite
test-clean :
Modified: branches/leo-ctx5/config/gen/makefiles/tcl.in
==============================================================================
--- branches/leo-ctx5/config/gen/makefiles/tcl.in (original)
+++ branches/leo-ctx5/config/gen/makefiles/tcl.in Fri Jul 29 03:37:40 2005
@@ -46,7 +46,6 @@ lib${slash}commands${slash}lrange.pir \
lib${slash}commands${slash}lrepeat.pir \
lib${slash}commands${slash}namespace.pir \
lib${slash}commands${slash}open.pir \
-lib${slash}commands${slash}package.pir \
lib${slash}commands${slash}proc.pir \
lib${slash}commands${slash}puts.pir \
lib${slash}commands${slash}rename.pir \
@@ -81,6 +80,9 @@ pmcs:
@cd $(CLASSDIR) && $(BUILD) linklibs $(PMCS)
@cd $(CLASSDIR) && $(BUILD) copy "--destination=$(DESTDIR)" $(PMCS)
+$(DEPS) :
+
+
lib${slash}tcllib.pir: $(DEPS)
$(PERL) tcl.pl > lib${slash}tcllib.pir
Modified: branches/leo-ctx5/config/init/hints/mswin32.pl
==============================================================================
--- branches/leo-ctx5/config/init/hints/mswin32.pl (original)
+++ branches/leo-ctx5/config/init/hints/mswin32.pl Fri Jul 29 03:37:40 2005
@@ -69,7 +69,19 @@
$linkflags =~ s/-opt:\S+//;
Configure::Data->set('linkflags', $linkflags);
}
- }
+
+ # We need to build a .def file to export parrot.exe symbols.
+ Configure::Data->set(
+ ld_parrot_exe_def => '-def:parrot.def',
+ parrot_exe_def => 'parrot.def'
+ );
+
+ # When building dynclasses we need to flag up the need to
+ # mark shared variables with __declspec(dllimport).
+ Configure::Data->set(
+ cc_building_dynclass_flag =>
'-DPARROT_BUILDING_WIN32_DLL'
+ );
+ }
elsif( $is_intel ) {
Configure::Data->set(
share_ext => '.dll',
Modified: branches/leo-ctx5/include/parrot/interpreter.h
==============================================================================
--- branches/leo-ctx5/include/parrot/interpreter.h (original)
+++ branches/leo-ctx5/include/parrot/interpreter.h Fri Jul 29 03:37:40 2005
@@ -430,7 +430,11 @@ typedef enum {
#define PARROT_CATCH_NULL 1
#if PARROT_CATCH_NULL
-extern PMC * PMCNULL; /* Holds single Null PMC */
+# if !defined(PARROT_BUILDING_WIN32_DLL)
+extern PMC * PMCNULL; /* Holds single Null PMC
*/
+# else
+__declspec(dllimport) extern PMC * PMCNULL; /* Holds single Null PMC
*/
+# endif /* PARROT_BUILDING_WIN32_DLL */
# define PMC_IS_NULL(p) (!(p) || (p) == PMCNULL)
#else
# define PMCNULL NULL
Modified: branches/leo-ctx5/include/parrot/pmc.h
==============================================================================
--- branches/leo-ctx5/include/parrot/pmc.h (original)
+++ branches/leo-ctx5/include/parrot/pmc.h Fri Jul 29 03:37:40 2005
@@ -18,7 +18,11 @@
#include "parrot/thread.h"
#define PARROT_MAX_CLASSES 100
+#if !defined(PARROT_BUILDING_WIN32_DLL)
VAR_SCOPE VTABLE **Parrot_base_vtables;/*[PARROT_MAX_CLASSES];*/
+#else
+__declspec(dllimport) VTABLE **Parrot_base_vtables;/*[PARROT_MAX_CLASSES];*/
+#endif /* PARROT_BUILDING_WIN32_DLL */
VAR_SCOPE INTVAL class_table_size;
VAR_SCOPE INTVAL enum_class_max;
VAR_SCOPE Parrot_mutex class_count_mutex;
Modified: branches/leo-ctx5/languages/tcl/t/tcl_pir_compiler.t
==============================================================================
--- branches/leo-ctx5/languages/tcl/t/tcl_pir_compiler.t (original)
+++ branches/leo-ctx5/languages/tcl/t/tcl_pir_compiler.t Fri Jul 29
03:37:40 2005
@@ -1,8 +1,9 @@
#!perl
use lib qw(tcl/t t . ../lib ../../lib ../../../lib);
-use Parrot::Test tests => 2;
+use Parrot::Test tests => 3;
use Test::More;
+use vars qw($TODO);
pir_output_is(<<'CODE', <<'OUTPUT', "test tcl compiler, verify double call
works");
.sub main @MAIN
@@ -34,3 +35,25 @@ CODE
ok 1
OUTPUT
+TODO: {
+ local $TODO = "stack too deep?";
+
+pir_output_is(<<'CODE', <<'OUTPUT', "pass arguments to a tcl proc from PIR");
+.sub main @MAIN
+
+ load_bytecode "languages/tcl/lib/tcllib.pbc"
+
+ $P0 = compreg "TCL"
+ $P1 = compile $P0, "proc _tmp {a} {puts $a}"
+ $P1()
+
+ $P2 = find_global "Tcl", "&_tmp"
+
+ $P3 = new String
+ $P3 = "hello"
+ $P2($P3)
+.end
+CODE
+hello
+OUTPUT
+}