Skip to content

Commit

Permalink
Merge branch 'ptrbuf'
Browse files Browse the repository at this point in the history
Conflicts:
	compilers/imcc/imcparser.c
	compilers/imcc/imcparser.h
  • Loading branch information
plobsing committed Feb 26, 2011
2 parents b245c77 + 0f23cb8 commit 787ca74
Show file tree
Hide file tree
Showing 16 changed files with 1,722 additions and 84 deletions.
5 changes: 5 additions & 0 deletions MANIFEST
Expand Up @@ -1387,6 +1387,9 @@ src/pmc/parrotthread.pmc []
src/pmc/pmc.num []
src/pmc/pmcproxy.pmc []
src/pmc/pointer.pmc []
src/pmc/ptr.pmc []
src/pmc/ptrbuf.pmc []
src/pmc/ptrobj.pmc []
src/pmc/resizablebooleanarray.pmc []
src/pmc/resizablefloatarray.pmc []
src/pmc/resizableintegerarray.pmc []
Expand All @@ -1402,6 +1405,7 @@ src/pmc/string.pmc []
src/pmc/stringbuilder.pmc []
src/pmc/stringhandle.pmc []
src/pmc/stringiterator.pmc []
src/pmc/structview.pmc []
src/pmc/sub.pmc []
src/pmc/task.pmc []
src/pmc/threadinterpreter.pmc []
Expand Down Expand Up @@ -1918,6 +1922,7 @@ t/pmc/string.t [test]
t/pmc/stringbuilder.t [test]
t/pmc/stringhandle.t [test]
t/pmc/stringiterator.t [test]
t/pmc/structview.t [test]
t/pmc/sub.t [test]
t/pmc/sys.t [test]
t/pmc/task.t [test]
Expand Down
8 changes: 8 additions & 0 deletions MANIFEST.generated
Expand Up @@ -104,6 +104,9 @@ include/pmc/pmc_parrotlibrary.h [devel]include
include/pmc/pmc_parrotthread.h [devel]include
include/pmc/pmc_pmcproxy.h [devel]include
include/pmc/pmc_pointer.h [devel]include
include/pmc/pmc_ptr.h [devel]include
include/pmc/pmc_ptrbuf.h [devel]include
include/pmc/pmc_ptrobj.h [devel]include
include/pmc/pmc_resizablebooleanarray.h [devel]include
include/pmc/pmc_resizablefloatarray.h [devel]include
include/pmc/pmc_resizableintegerarray.h [devel]include
Expand All @@ -120,6 +123,7 @@ include/pmc/pmc_string.h [devel]include
include/pmc/pmc_stringbuilder.h [devel]include
include/pmc/pmc_stringhandle.h [devel]include
include/pmc/pmc_stringiterator.h [devel]include
include/pmc/pmc_structview.h [devel]include
include/pmc/pmc_sub.h [devel]include
include/pmc/pmc_task.h [devel]include
include/pmc/pmc_threadinterpreter.h [devel]include
Expand Down Expand Up @@ -407,6 +411,9 @@ src/pmc/parrotlibrary.dump [devel]src
src/pmc/parrotthread.dump [devel]src
src/pmc/pmcproxy.dump [devel]src
src/pmc/pointer.dump [devel]src
src/pmc/ptr.dump [devel]src
src/pmc/ptrbuf.dump [devel]src
src/pmc/ptrobj.dump [devel]src
src/pmc/resizablebooleanarray.dump [devel]src
src/pmc/resizablefloatarray.dump [devel]src
src/pmc/resizableintegerarray.dump [devel]src
Expand All @@ -423,6 +430,7 @@ src/pmc/string.dump [devel]src
src/pmc/stringbuilder.dump [devel]src
src/pmc/stringhandle.dump [devel]src
src/pmc/stringiterator.dump [devel]src
src/pmc/structview.dump [devel]src
src/pmc/sub.dump [devel]src
src/pmc/task.dump [devel]src
src/pmc/threadinterpreter.dump [devel]src
Expand Down
32 changes: 11 additions & 21 deletions compilers/imcc/imclexer.c
Expand Up @@ -78,6 +78,7 @@ typedef int flex_int32_t;
typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
#endif /* ! C99 */

/* Limits of integral types. */
#ifndef INT8_MIN
Expand Down Expand Up @@ -108,8 +109,6 @@ typedef unsigned int flex_uint32_t;
#define UINT32_MAX (4294967295U)
#endif

#endif /* ! C99 */

#endif /* ! FLEXINT_H */

#ifdef __cplusplus
Expand Down Expand Up @@ -183,15 +182,7 @@ typedef void* yyscan_t;

/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k.
* Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
* Ditto for the __ia64__ case accordingly.
*/
#define YY_BUF_SIZE 32768
#else
#define YY_BUF_SIZE 16384
#endif /* __ia64__ */
#endif

/* The state buf must be large enough to hold one state per character in the main buffer.
Expand Down Expand Up @@ -2245,7 +2236,7 @@ static int handle_identifier(PARROT_INTERP, YYSTYPE *valp, ARGIN(const char *id)



#line 2249 "compilers/imcc/imclexer.c"
#line 2240 "compilers/imcc/imclexer.c"

#define INITIAL 0
#define emit 1
Expand Down Expand Up @@ -2340,6 +2331,10 @@ int yyget_lineno (yyscan_t yyscanner );

void yyset_lineno (int line_number ,yyscan_t yyscanner );

int yyget_column (yyscan_t yyscanner );

void yyset_column (int column_no ,yyscan_t yyscanner );

/* Macros after this point can all be overridden by user definitions in
* section 1.
*/
Expand Down Expand Up @@ -2380,12 +2375,7 @@ static int input (yyscan_t yyscanner );

/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k */
#define YY_READ_BUF_SIZE 16384
#else
#define YY_READ_BUF_SIZE 8192
#endif /* __ia64__ */
#endif

/* Copy whatever the last rule matched to the standard output. */
Expand All @@ -2404,7 +2394,7 @@ static int input (yyscan_t yyscanner );
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
{ \
int c = '*'; \
size_t n; \
unsigned n; \
for ( n = 0; n < max_size && \
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
Expand Down Expand Up @@ -2509,7 +2499,7 @@ YY_DECL
return 0;
}

#line 2513 "compilers/imcc/imclexer.c"
#line 2503 "compilers/imcc/imclexer.c"

if ( !yyg->yy_init )
{
Expand Down Expand Up @@ -3692,7 +3682,7 @@ YY_RULE_SETUP
#line 724 "compilers/imcc/imcc.l"
ECHO;
YY_BREAK
#line 3696 "compilers/imcc/imclexer.c"
#line 3686 "compilers/imcc/imclexer.c"
case YY_STATE_EOF(pod):
case YY_STATE_EOF(cmt1):
case YY_STATE_EOF(cmt2):
Expand Down Expand Up @@ -4481,8 +4471,8 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr , yyscan_t yyscanner)

/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
* scan from a @e copy of @a bytes.
* @param yybytes the byte buffer to scan
* @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
* @param bytes the byte buffer to scan
* @param len the number of bytes in the buffer pointed to by @a bytes.
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
*/
Expand Down
13 changes: 10 additions & 3 deletions compilers/imcc/pbc.c
Expand Up @@ -1638,12 +1638,19 @@ build_key(PARROT_INTERP, ARGIN(SymReg *key_reg), ARGMOD(PackFile_ByteCode * bc))
/* don't emit mapped regs in key parts */
regno = r->color >= 0 ? r->color : -1 - r->color;

if (r->set == 'I')
switch (r->set) {
case 'I':
Parrot_key_set_register(interp, tail, regno, KEY_integer_FLAG);
else if (r->set == 'S')
break;
case 'S':
Parrot_key_set_register(interp, tail, regno, KEY_string_FLAG);
else
break;
case 'P':
Parrot_key_set_register(interp, tail, regno, KEY_pmc_FLAG);
break;
default:
IMCC_fatal(interp, 1, "build_key: wrong register set\n");
}

IMCC_debug(interp, DEBUG_PBC_CONST,
" keypart reg %s %c%d\n",
Expand Down
129 changes: 76 additions & 53 deletions include/parrot/datatypes.h
Expand Up @@ -13,6 +13,10 @@
#ifndef PARROT_DATATYPES_H_GUARD
#define PARROT_DATATYPES_H_GUARD

/* TODO: detect these with configure */
#define HAS_LONGLONG 0
#define HAS_LONGDOUBLE 0

/* &gen_from_enum(datatypes.pasm) subst(s/enum_type_(\w+)/uc("DATATYPE_$1")/e) */
typedef enum {
enum_type_undef, /* illegal */
Expand All @@ -22,8 +26,6 @@ typedef enum {
enum_type_FLOATVAL,
enum_type_STRING,
enum_type_PMC, /* actual PMCs have positive class numbers */
enum_type_BIGINT,
enum_type_DPOINTER,

enum_type_char, /* native integer types */
enum_type_short,
Expand All @@ -41,14 +43,14 @@ typedef enum {
enum_type_double,
enum_type_longdouble,

enum_type_bit, /* fixed size types */
enum_type_int1 = enum_type_bit,
enum_type_int4,
enum_type_int8,
enum_type_int8, /* fixed size types */
enum_type_int16,
enum_type_int32,
enum_type_int64,

enum_type_bit,
enum_type_uint1 = enum_type_bit,
enum_type_uint4,
enum_type_uint8, /* unsigned variants */
enum_type_uint16,
enum_type_uint32,
Expand All @@ -57,67 +59,88 @@ typedef enum {
enum_type_ptr, /* native pointer */
enum_type_cstr, /* c string */
enum_type_struct_ptr, /* pointer to another struct */
enum_type_struct, /* a nested struct */
enum_type_struct, /* a struct */
enum_type_union, /* a union */
enum_type_func_ptr, /* a function pointer */

enum_type_sized, /* arbitrary size type for list_new */
enum_type_sized,
enum_last_type /* + one */

} PARROT_DATA_TYPE;

/* &end_gen */
struct _data_types {
PARROT_OBSERVER const char *name;
int size;
size_t size;
size_t align;
};

#define ALIGNOF(x) offsetof(struct { char c; x d; }, d)

extern const struct _data_types data_types[];
#if defined(INSIDE_GLOBAL_SETUP)
const struct _data_types data_types[] = {
{ "INTVAL", INTVAL_SIZE }, /* parrot types */
{ "FLOATVAL", NUMVAL_SIZE },
{ "STRING", sizeof (void *) },
{ "PMC", sizeof (void *) }, /* actual PMCs have positive class numbers */
{ "BIGINT", sizeof (void *) },
{ "DPOINTER", sizeof (void *) },

{ "char", sizeof (char) }, /* native integer types */
{ "short", sizeof (short) },
{ "int", sizeof (int) },
{ "long", sizeof (long) },
{ "longlong", 0 }, /* TODO */

{ "uchar", sizeof (char) }, /* native unsigned types */
{ "ushort", sizeof (short)},
{ "uint", sizeof (int) },
{ "ulong", sizeof (long) },
{ "ulonglong", 0 }, /* TODO */

{ "float", sizeof (float) }, /* native float types */
{ "double", sizeof (double) },
{ "longdouble", 0 }, /* TODO */

{ "int1", 0 }, /* = bit */
{ "int4", 0 },
{ "int8", 1 },
{ "int16", 2 },
{ "int32", 4 },
{ "int64", 8 },

{ "uint8", 1 }, /* unsigned variants */
{ "uint16", 2 },
{ "uint32", 4 },
{ "uint64", 8 },

{ "ptr", sizeof (void*) },
{ "cstr", sizeof (char *) },
{ "struct_ptr", sizeof (void*) },
{ "struct", 0 },
{ "func_ptr", sizeof (void (*)(void)) },

{ "sized", 0 },

{ "illegal", 0 }
/* parrot types */
{ "INTVAL", sizeof (INTVAL), ALIGNOF(INTVAL) },
{ "FLOATVAL", sizeof (FLOATVAL), ALIGNOF(FLOATVAL) },
{ "STRING", sizeof (STRING *), ALIGNOF(STRING *) },
{ "PMC", sizeof (PMC *), ALIGNOF(PMC *) },

/* native integer types */
{ "char", sizeof (char), ALIGNOF(char) },
{ "short", sizeof (short), ALIGNOF(short) },
{ "int", sizeof (int), ALIGNOF(int) },
{ "long", sizeof (long), ALIGNOF(long) },
# if HAS_LONGLONG
{ "longlong", sizeof (long long), ALIGNOF(long long) },
# else
{ "longlong", 0, 0 },
# endif

/* native unsigned types */
{ "uchar", sizeof (unsigned char), ALIGNOF(unsigned char) },
{ "ushort", sizeof (unsigned short), ALIGNOF(unsigned short) },
{ "uint", sizeof (unsigned int), ALIGNOF(unsigned int) },
{ "ulong", sizeof (unsigned long), ALIGNOF(unsigned long) },
# if HAS_LONGLONG
{ "ulonglong", sizeof (unsigned long long), ALIGNOF(unsigned long long) },
# else
{ "ulonglong", 0, 0 },
# endif

/* native float types */
{ "float", sizeof (float), ALIGNOF(float) },
{ "double", sizeof (double), ALIGNOF(double) },
# if HAS_LONGDOUBLE
{ "longdouble", sizeof (long double), ALIGNOF(long double)},
# else
{ "longdouble", 0, 0 },
# endif

/* explicitly sized integer types */
{ "int8", 1, ALIGNOF(int /* TODO */) },
{ "int16", 2, ALIGNOF(int /* TODO */) },
{ "int32", 4, ALIGNOF(int /* TODO */) },
{ "int64", 8, ALIGNOF(int /* TODO */) },

/* unsigned variants */
{ "uint1", 0, 0 }, /* = bit */
{ "uint4", 0, 0 },
{ "uint8", 1, ALIGNOF(int /* TODO */) },
{ "uint16", 2, ALIGNOF(int /* TODO */) },
{ "uint32", 4, ALIGNOF(int /* TODO */) },
{ "uint64", 8, ALIGNOF(int /* TODO */) },

{ "ptr", sizeof (void *), ALIGNOF(void *) },
{ "cstr", sizeof (char *), ALIGNOF(char *) },
{ "struct_ptr", sizeof (void *), ALIGNOF(void *) },
{ "struct", 0, 0 },
{ "union", 0, 0 },
{ "func_ptr", sizeof (funcptr_t), ALIGNOF(funcptr_t) },

{ "sized", 0, 0 },

{ "illegal", 0, 0 }
};
#endif /* INSIDE_GLOBAL_SETUP */

Expand Down
4 changes: 4 additions & 0 deletions lib/Parrot/Headerizer.pm
Expand Up @@ -245,6 +245,10 @@ sub extract_function_declarations {
# Drop all text after HEADERIZER STOP
$text =~ s{/\*\s*HEADERIZER STOP.+}{}s;

# Drop begin/end PMC HEADER sections
$text =~ s{BEGIN_PMC_HEADER_PREAMBLE}{}sx;
$text =~ s{END_PMC_HEADER_PREAMBLE}{}sx;

# Strip blocks of comments
$text =~ s{^/\*.*?\*/}{}mxsg;

Expand Down
9 changes: 9 additions & 0 deletions lib/Parrot/Pmc2c/PMC.pm
Expand Up @@ -300,6 +300,12 @@ sub preamble {
return $self->{preamble};
}

sub hdr_preamble {
my ( $self, $value ) = @_;
$self->{hdr_preamble} = $value if $value;
return $self->{hdr_preamble};
}

sub postamble {
my ( $self, $value ) = @_;
$self->{postamble} = $value if $value;
Expand Down Expand Up @@ -562,6 +568,9 @@ EOH

$h->emit("#define PARROT_IN_EXTENSION\n") if ( $self->is_dynamic );

# Emit header preamble
$h->emit($self->hdr_preamble) if $self->hdr_preamble;

# Emit available functions for work with vtables.
my $export = 'PARROT_EXPORT ';
if ($self->is_dynamic) {
Expand Down

0 comments on commit 787ca74

Please sign in to comment.