cvsuser 04/10/07 06:36:52
Modified: . MANIFEST MANIFEST.generated
build_tools parrot_config_c.pl
imcc imcc.l parser_util.c
include/parrot library.h
src library.c
tools/dev install_files.pl
Log:
runtime prefix 4 - use prefix for include and load_library
* unify runtime code loading - all gets now through one interface
* old code is disabled
* install library source files too
* some fixes
Revision Changes Path
1.747 +42 -42 parrot/MANIFEST
Index: MANIFEST
===================================================================
RCS file: /cvs/public/parrot/MANIFEST,v
retrieving revision 1.746
retrieving revision 1.747
diff -u -w -r1.746 -r1.747
--- MANIFEST 7 Oct 2004 08:09:55 -0000 1.746
+++ MANIFEST 7 Oct 2004 13:36:47 -0000 1.747
@@ -2598,47 +2598,47 @@
lib/Test/Simple.pm [devel]
lib/Text/Balanced.pm [devel]
libnci.def []
-runtime/parrot/library/Data/Sort.imc [devel]
-runtime/parrot/library/Data/Escape.imc [devel]
-runtime/parrot/library/Data/Replace.imc [devel]
-runtime/parrot/library/Data/Dumper.imc [devel]
-runtime/parrot/library/Data/Dumper/Base.imc [devel]
-runtime/parrot/library/Data/Dumper/Default.imc [devel]
-runtime/parrot/library/SDL.imc [devel]
-runtime/parrot/library/SDL/App.imc [devel]
-runtime/parrot/library/SDL/Button.imc [devel]
-runtime/parrot/library/SDL/Color.imc [devel]
-runtime/parrot/library/SDL/Constants.imc [devel]
-runtime/parrot/library/SDL/Event.imc [devel]
-runtime/parrot/library/SDL/EventHandler.imc [devel]
-runtime/parrot/library/SDL/Font.imc [devel]
-runtime/parrot/library/SDL/Image.imc [devel]
-runtime/parrot/library/SDL/LCD.imc [devel]
-runtime/parrot/library/SDL/LCD.png [devel]
-runtime/parrot/library/SDL/Rect.imc [devel]
-runtime/parrot/library/SDL/Sprite.imc [devel]
-runtime/parrot/library/SDL/StopWatch.imc [devel]
-runtime/parrot/library/SDL/Surface.imc [devel]
-runtime/parrot/library/Stream/Base.imc [devel]
-runtime/parrot/library/Stream/Buffer.imc [devel]
-runtime/parrot/library/Stream/Combiner.imc [devel]
-runtime/parrot/library/Stream/Coroutine.imc [devel]
-runtime/parrot/library/Stream/Filter.imc [devel]
-runtime/parrot/library/Stream/Lines.imc [devel]
-runtime/parrot/library/Stream/ParrotIO.imc [devel]
-runtime/parrot/library/Stream/Replay.imc [devel]
-runtime/parrot/library/Stream/Sub.imc [devel]
-runtime/parrot/library/Stream/Writer.imc [devel]
-runtime/parrot/library/config.imc [devel]
-runtime/parrot/library/dumper.imc [devel]
-runtime/parrot/library/libpcre.imc [devel]
-runtime/parrot/library/ncurses.declarations [devel]
-runtime/parrot/library/ncurses.imc [devel]
-runtime/parrot/library/ncurses.pasm [devel]
-runtime/parrot/library/pcre.imc [devel]
-runtime/parrot/library/postgres.declarations [devel]
-runtime/parrot/library/postgres.imc [devel]
-runtime/parrot/library/postgres.pasm [devel]
+runtime/parrot/library/Data/Sort.imc [library]
+runtime/parrot/library/Data/Escape.imc [library]
+runtime/parrot/library/Data/Replace.imc [library]
+runtime/parrot/library/Data/Dumper.imc [library]
+runtime/parrot/library/Data/Dumper/Base.imc [library]
+runtime/parrot/library/Data/Dumper/Default.imc [library]
+runtime/parrot/library/SDL.imc [library]
+runtime/parrot/library/SDL/App.imc [library]
+runtime/parrot/library/SDL/Button.imc [library]
+runtime/parrot/library/SDL/Color.imc [library]
+runtime/parrot/library/SDL/Constants.imc [library]
+runtime/parrot/library/SDL/Event.imc [library]
+runtime/parrot/library/SDL/EventHandler.imc [library]
+runtime/parrot/library/SDL/Font.imc [library]
+runtime/parrot/library/SDL/Image.imc [library]
+runtime/parrot/library/SDL/LCD.imc [library]
+runtime/parrot/library/SDL/LCD.png [library]
+runtime/parrot/library/SDL/Rect.imc [library]
+runtime/parrot/library/SDL/Sprite.imc [library]
+runtime/parrot/library/SDL/StopWatch.imc [library]
+runtime/parrot/library/SDL/Surface.imc [library]
+runtime/parrot/library/Stream/Base.imc [library]
+runtime/parrot/library/Stream/Buffer.imc [library]
+runtime/parrot/library/Stream/Combiner.imc [library]
+runtime/parrot/library/Stream/Coroutine.imc [library]
+runtime/parrot/library/Stream/Filter.imc [library]
+runtime/parrot/library/Stream/Lines.imc [library]
+runtime/parrot/library/Stream/ParrotIO.imc [library]
+runtime/parrot/library/Stream/Replay.imc [library]
+runtime/parrot/library/Stream/Sub.imc [library]
+runtime/parrot/library/Stream/Writer.imc [library]
+runtime/parrot/library/config.imc [library]
+runtime/parrot/library/dumper.imc [library]
+runtime/parrot/library/libpcre.imc [library]
+runtime/parrot/library/ncurses.declarations [library]
+runtime/parrot/library/ncurses.imc [library]
+runtime/parrot/library/ncurses.pasm [library]
+runtime/parrot/library/pcre.imc [library]
+runtime/parrot/library/postgres.declarations [library]
+runtime/parrot/library/postgres.imc [library]
+runtime/parrot/library/postgres.pasm [library]
ops/bit.ops []
ops/cmp.ops []
ops/core.ops []
@@ -2658,7 +2658,7 @@
ops/string.ops []
ops/sys.ops []
ops/var.ops []
-parrot-config.imc [devel]
+parrot-config.imc [main]
parrot.spec []
parrotbug []
pf/pf_items.c []
1.7 +1 -0 parrot/MANIFEST.generated
Index: MANIFEST.generated
===================================================================
RCS file: /cvs/public/parrot/MANIFEST.generated,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -w -r1.6 -r1.7
--- MANIFEST.generated 7 Oct 2004 08:49:53 -0000 1.6
+++ MANIFEST.generated 7 Oct 2004 13:36:47 -0000 1.7
@@ -44,4 +44,5 @@
runtime/parrot/include/timer.pasm [main]
runtime/parrot/include/tm.pasm [main]
runtime/parrot/include/vtable_methods.pasm [main]
+runtime/parrot/include/warnings.pasm [main]
blib/lib/icu/2.6.1/icudt26l.dat [main]
1.2 +15 -9 parrot/build_tools/parrot_config_c.pl
Index: parrot_config_c.pl
===================================================================
RCS file: /cvs/public/parrot/build_tools/parrot_config_c.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -r1.1 -r1.2
--- parrot_config_c.pl 7 Oct 2004 08:09:57 -0000 1.1
+++ parrot_config_c.pl 7 Oct 2004 13:36:48 -0000 1.2
@@ -1,6 +1,6 @@
#! perl -w
# Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
-# $Id: parrot_config_c.pl,v 1.1 2004/10/07 08:09:57 leo Exp $
+# $Id: parrot_config_c.pl,v 1.2 2004/10/07 13:36:48 leo Exp $
=head1 NAME
@@ -40,18 +40,24 @@
static const char* runtime_prefix = \"$prefix\";
const char*
-Parrot_get_runtime_prefix(Interp *interpreter, STRING **prefix)
+Parrot_get_runtime_prefix(Interp *interpreter, STRING **prefix_str)
{
- STRING *s;
+ static STRING *s;
+ static int init_done;
+ static const char *prefix;
if (!*runtime_prefix)
return NULL;
+ if (!init_done) {
+ init_done = 1;
+ prefix = runtime_prefix;
s = const_string(interpreter, runtime_prefix);
- if (prefix)
- *prefix = s;
- if (Parrot_stat_info_intval(interpreter, s, STAT_EXISTS))
- return runtime_prefix;
- return NULL;
+ if (!Parrot_stat_info_intval(interpreter, s, STAT_EXISTS))
+ prefix = NULL;
+ }
+ if (prefix_str)
+ *prefix_str = s;
+ return prefix;
}
EOF
1.116 +10 -30 parrot/imcc/imcc.l
Index: imcc.l
===================================================================
RCS file: /cvs/public/parrot/imcc/imcc.l,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -w -r1.115 -r1.116
--- imcc.l 5 Oct 2004 15:23:52 -0000 1.115
+++ imcc.l 7 Oct 2004 13:36:49 -0000 1.116
@@ -840,41 +840,21 @@
{
struct macro_frame_t *frame;
FILE *file = 0;
- char *ext;
+ char *ext, *s;
frame = new_frame();
-
-/* XXX: use this code for miniparrot */
-#if !defined(_PARROTLIB)
- {
- extern const char* Parrot_imcc_include_paths[];
- STRING *str = Parrot_library_fallback_locate(interp, file_name,
Parrot_imcc_include_paths);
-
- if (str) {
- char* s = string_to_cstring(interp, str);
-
+ s = Parrot_locate_runtime_file(interp, file_name,
+ PARROT_RUNTIME_FT_INCLUDE);
+ if (s) {
file = fopen(s, "r");
- if (file)
- sourcefile = s;
- else
- string_cstring_free(s);
- }
- }
-#else
- {
- STRING* name = string_from_cstring(interp, file_name, strlen(file_name));
- STRING* result = Parrot_library_query(interp, "include_file_location", name);
-
- if (result) {
- /* FIXME: leak */
- sourcefile = strdup(string_to_cstring(interp, result));
- file = fopen( sourcefile, "r" );
+ if (!file) {
+ mem_sys_free(s);
+ fataly(EX_SOFTWARE, sourcefile, line, strerror(errno));
}
}
-#endif
-
- if (!file)
+ else
fataly(EX_SOFTWARE, sourcefile, line, strerror(errno));
+ sourcefile = s;
ext = strrchr(file_name, '.');
if (ext) {
1.77 +4 -18 parrot/imcc/parser_util.c
Index: parser_util.c
===================================================================
RCS file: /cvs/public/parrot/imcc/parser_util.c,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -w -r1.76 -r1.77
--- parser_util.c 30 Sep 2004 16:00:37 -0000 1.76
+++ parser_util.c 7 Oct 2004 13:36:49 -0000 1.77
@@ -29,14 +29,6 @@
*/
void imcc_init(Parrot_Interp interpreter);
-/* includes to use if parrotlib is not available */
-const char *Parrot_imcc_include_paths[] = {
- "./",
- "runtime/parrot/include/",
- "runtime/parrot/",
- 0,
-};
-
/*
* P = new type, [init]
* PASM like:
@@ -534,16 +526,10 @@
void * __ptr;
} __ptr_u;
-#if defined(_PARROTLIB)
- STRING *str = string_from_cstring(interp, s, strlen(s));
- str = Parrot_library_query(interp, "imcc_compile_file_location", str);
-#else
- STRING *str = Parrot_library_fallback_locate(interp, s,
Parrot_imcc_include_paths);
-#endif
- if (str) {
- fullname = string_to_cstring(interp, str);
- }
- if (!str || !(new = fopen(fullname, "r"))) {
+ fullname = Parrot_locate_runtime_file(interp, s, PARROT_RUNTIME_FT_SOURCE);
+ if (!fullname)
+ fatal(1, "imcc_compile_file", "couldn't find '%s'\n", s);
+ if (!(new = fopen(fullname, "r"))) {
fatal(1, "imcc_compile_file", "couldn't open '%s'\n", fullname);
string_cstring_free(fullname);
return NULL;
1.3 +13 -3 parrot/include/parrot/library.h
Index: library.h
===================================================================
RCS file: /cvs/public/parrot/include/parrot/library.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -r1.2 -r1.3
--- library.h 26 May 2004 19:14:28 -0000 1.2
+++ library.h 7 Oct 2004 13:36:50 -0000 1.3
@@ -1,7 +1,7 @@
/* library.h
* Copyright: 2004 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: library.h,v 1.2 2004/05/26 19:14:28 jrieks Exp $
+ * $Id: library.h,v 1.3 2004/10/07 13:36:50 leo Exp $
* Overview:
* Contains accessor functions for the _parrotlib bytecode interface
* Data Structure and Algorithms:
@@ -13,8 +13,18 @@
#if !defined(PARROT_LIBRARY_H_GUARD)
#define PARROT_LIBRARY_H_GUARD
-void* Parrot_library_query(Parrot_Interp, const char *func_name, ...);
-STRING* Parrot_library_fallback_locate(Parrot_Interp interp, const char *file_name,
const char **incl);
+typedef enum {
+ PARROT_RUNTIME_FT_LIBRARY = 0x0001,
+ PARROT_RUNTIME_FT_INCLUDE = 0x0002,
+ PARROT_RUNTIME_FT_PBC = 0x0010,
+ PARROT_RUNTIME_FT_PASM = 0x0100,
+ PARROT_RUNTIME_FT_PIR = 0x0200,
+ PARROT_RUNTIME_FT_PAST = 0x0400,
+ PARROT_RUNTIME_FT_SOURCE = 0x0F00
+} enum_runtime_ft;
+
+char* Parrot_locate_runtime_file(Interp *, const char *file_name,
+ enum_runtime_ft);
#endif /* PARROT_LIBRARY_H_GUARD */
1.9 +93 -1 parrot/src/library.c
Index: library.c
===================================================================
RCS file: /cvs/public/parrot/src/library.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -w -r1.8 -r1.9
--- library.c 30 Sep 2004 16:00:38 -0000 1.8
+++ library.c 7 Oct 2004 13:36:51 -0000 1.9
@@ -1,6 +1,6 @@
/*
Copyright: 2004 The Perl Foundation. All Rights Reserved.
-$Id: library.c,v 1.8 2004/09/30 16:00:38 leo Exp $
+$Id: library.c,v 1.9 2004/10/07 13:36:51 leo Exp $
=head1 NAME
@@ -22,6 +22,7 @@
#include <assert.h>
#include "library.str"
+#if 0
/*
=item C<static void
@@ -142,6 +143,97 @@
return str;
}
+#endif
+
+/*
+
+=item C<char* Parrot_locate_runtime_file(Interp *, const char *file_name,
+ enum_runtime_ft type)>
+
+Locate the full patch for C<file_name> and the given file type(s). If
+successfull returns a mem_sys_allocate()ed string or NULL otherwise.
+
+The C<enum_runtime_ft type> is one or more of the types defined in
+F<include/parrot/library.h>.
+
+*/
+
+char* Parrot_locate_runtime_file(Interp *interpreter, const char *file_name,
+ enum_runtime_ft type)
+{
+ char *full_name, *ext;
+ const char **ptr;
+ const char *prefix;
+ STRING *str;
+ const char *include_paths[] = {
+ "runtime/parrot/include/",
+ "runtime/parrot/",
+ "./",
+ NULL
+ };
+ int length;
+
+ prefix = Parrot_get_runtime_prefix(interpreter, NULL);
+ if (!prefix)
+ prefix = "";
+
+ ext = strchr(file_name, '.');
+ /*
+ * if the extension is given use it
+ * TODO if not try extensions according to type
+ */
+ if (!ext) {
+ internal_exception(UNIMPLEMENTED, "no extension");
+ }
+ length = 0;
+ for (ptr = include_paths; *ptr; ++ptr) {
+ int len = strlen(*ptr);
+ length = (len > length) ? len : length;
+ }
+ length += strlen(prefix) + strlen(file_name) + 2;
+ full_name = mem_sys_allocate(length);
+
+ for( ptr = include_paths; *ptr; ++ptr ) {
+ strcpy(full_name, prefix);
+ if (*prefix) {
+#ifdef WIN32
+ strcat(full_name, "\\");
+#else
+ strcat(full_name, "/");
+#endif
+ }
+ strcat(full_name, *ptr);
+ strcat(full_name, file_name);
+#ifdef WIN32
+ {
+ char *p;
+ while ( (p = strchr(full_name, '/')) )
+ *p = '\\';
+ }
+#endif
+ str = string_from_cstring(interpreter, full_name, strlen(full_name));
+ if (Parrot_stat_info_intval(interpreter, str, STAT_EXISTS))
+ return full_name;
+ }
+ /*
+ * finally if prefix is set, try current location
+ */
+ if (*prefix) {
+ strcpy(full_name, file_name);
+#ifdef WIN32
+ {
+ char *p;
+ while ( (p = strchr(full_name, '/')) )
+ *p = '\\';
+ }
+#endif
+ str = string_from_cstring(interpreter, full_name, strlen(full_name));
+ if (Parrot_stat_info_intval(interpreter, str, STAT_EXISTS))
+ return full_name;
+ }
+ return NULL;
+}
+
/*
=back
1.10 +5 -3 parrot/tools/dev/install_files.pl
Index: install_files.pl
===================================================================
RCS file: /cvs/public/parrot/tools/dev/install_files.pl,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -w -r1.9 -r1.10
--- install_files.pl 7 Oct 2004 08:49:54 -0000 1.9
+++ install_files.pl 7 Oct 2004 13:36:52 -0000 1.10
@@ -1,7 +1,7 @@
#! perl -w
################################################################################
# Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
-# $Id: install_files.pl,v 1.9 2004/10/07 08:49:54 leo Exp $
+# $Id: install_files.pl,v 1.10 2004/10/07 13:36:52 leo Exp $
################################################################################
=head1 TITLE
@@ -160,7 +160,7 @@
$meta =~ s/^\[(.*?)\]//;
next unless $package; # Skip if this file belongs to no package
- next unless $package eq 'main'; # XXX -lt
+ next unless $package =~ /main|library/; # XXX -lt
my %meta;
@meta{split(/,/, $meta)} = ();
@@ -200,14 +200,16 @@
}
}
}
+print("Installing ...\n");
foreach (@files) {
my ($src, $dest) = @$_;
if ($options{'dry-run'}) {
- print "cp $src \t$dest\n";
+ print "$src -> $dest\n";
next;
}
else {
copy($src, $dest) or die "copy $src to $dest: $!\n";
+ print "$dest\n";
}
my $mode = (stat($src))[2];
chmod $mode, $dest;