[Nickle] nickle: Branch 'master' - 6 commits
Keith Packard
keithp at keithp.com
Sun Jan 6 16:27:13 PST 2008
compile.c | 18 +++++++++++---
configure.in | 2 -
debian/changelog | 7 +++++
file.c | 8 +++++-
gram.y | 11 ++++++++
lex.l | 15 +++++++++++
pretty.c | 26 +++++++++++++++-----
type.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
value.h | 2 +
9 files changed, 147 insertions(+), 11 deletions(-)
New commits:
commit 8e8c6197f0b7448fd27fa1bae5daf2bb839ce1df
Author: Keith Packard <keithp at keithp.com>
Date: Sun Jan 6 16:26:07 2008 -0800
Exit with status 1 if last action was parse failure.
Nickle normally exits with the status of the last thread; if the last action
of the user was a parse failure (causing no thread to execute), exit with
failure (status 1).
diff --git a/gram.y b/gram.y
index 1437f08..4f358f7 100644
--- a/gram.y
+++ b/gram.y
@@ -218,6 +218,7 @@ reset :
CurrentNamespace = TopNamespace;
funcDepth = 0;
notCommand = 0;
+ lastThreadError = True;
}
;
commit edc47ba279d74bbc18de3531dd8aabdbbdd60f70
Author: Keith Packard <keithp at keithp.com>
Date: Sun Jan 6 16:18:49 2008 -0800
Function declarations would segfault the pretty printer.
void g () { void f (int i); }
print g
would segfault as 'f' was a function declaration without a code body.
Fixed by adding pretty printing code to handle this case.
diff --git a/pretty.c b/pretty.c
index a067028..9e33ced 100644
--- a/pretty.c
+++ b/pretty.c
@@ -605,6 +605,9 @@ _PrettyCatch (Value f, Expr *e, int level, Bool nest, ProfileData *pd)
FilePuts (f, "\n");
}
+static void
+PrintArgs (Value f, ArgType *args);
+
void
PrettyStatement (Value f, Expr *e, int level, int blevel, Bool nest, ProfileData *pd)
{
@@ -739,12 +742,23 @@ PrettyStatement (Value f, Expr *e, int level, int blevel, Bool nest, ProfileData
{
DeclListPtr decl = e->decl.decl;
ExprPtr init = decl->init;
- CodePtr code = init->code.code;
-
- PrettyCode (f, code, decl->name,
- e->decl.class,
- e->decl.publish,
- level, nest);
+ if (init)
+ {
+ CodePtr code = init->code.code;
+
+ PrettyCode (f, code, decl->name,
+ e->decl.class,
+ e->decl.publish,
+ level, nest);
+ }
+ else
+ {
+ Type *t = e->decl.type;
+ FilePrintf (f, "%p%k%T %A ", e->decl.publish,
+ e->decl.class, t->func.ret, decl->name);
+ PrintArgs (f, t->func.args);
+ FilePuts (f, ";");
+ }
}
FilePuts (f, "\n");
break;
commit 691a76447cea42cb3c5bdc3ccb1aae228081fe3b
Author: Keith Packard <keithp at keithp.com>
Date: Sun Jan 6 15:51:07 2008 -0800
Check for duplicate function param and struct/union members
While duplicate function parameters and struct/union members may have well
defined semantics, they're a bad idea, so we make them an error.
diff --git a/compile.c b/compile.c
index c21bc8d..d7ce654 100644
--- a/compile.c
+++ b/compile.c
@@ -4117,10 +4117,10 @@ static ObjPtr
CompileType (ObjPtr obj, ExprPtr decls, TypePtr type, ExprPtr stat, CodePtr code)
{
ENTER();
- ArgType *at;
+ ArgType *at, *aat;
StructType *st;
TypeElt *et;
- int i;
+ int i, j;
switch (type->base.tag) {
case type_prim:
@@ -4132,8 +4132,14 @@ CompileType (ObjPtr obj, ExprPtr decls, TypePtr type, ExprPtr stat, CodePtr code
break;
case type_func:
obj = CompileType (obj, decls, type->func.ret, stat, code);
- for (at = type->func.args; at; at = at->next)
+ for (at = type->func.args; at; at = at->next) {
+ if (at->name)
+ for (aat = at->next; aat; aat = aat->next)
+ if (aat->name == at->name)
+ CompileError (obj, stat, "Duplicate function parameter '%A'",
+ at->name);
obj = CompileType (obj, decls, at->type, stat, code);
+ }
break;
case type_array:
obj = CompileArrayType (obj, decls, type, stat, code);
@@ -4147,7 +4153,13 @@ CompileType (ObjPtr obj, ExprPtr decls, TypePtr type, ExprPtr stat, CodePtr code
case type_union:
st = type->structs.structs;
for (i = 0; i < st->nelements; i++)
+ {
+ for (j = 0; j < i; j++)
+ if (StructTypeAtoms(st)[j] == StructTypeAtoms(st)[i])
+ CompileError (obj, stat, "Duplicate structure member %A",
+ StructTypeAtoms(st)[i]);
obj = CompileType (obj, decls, BoxTypesElements(st->types)[i], stat, code);
+ }
break;
case type_types:
for (et = type->types.elt; et; et = et->next)
commit cf60fcd340021ed1e29fdc208fe4634924c124e1
Author: Keith Packard <keithp at keithp.com>
Date: Sun Jan 6 15:50:39 2008 -0800
Reduce warnings when compiling flex output
diff --git a/lex.l b/lex.l
index d0b0aac..36c0efa 100644
--- a/lex.l
+++ b/lex.l
@@ -17,6 +17,21 @@
#include <readline/history.h>
#endif
+/*
+ * Silence gcc by providing prototypes for these functions
+ */
+int yyget_lineno (void);
+FILE *yyget_in (void);
+FILE *yyget_out (void);
+int yyget_leng (void);
+char *yyget_text (void);
+void yyset_lineno (int);
+void yyset_in (FILE *);
+void yyset_out (FILE *);
+int yyget_debug (void);
+void yyset_debug (int);
+int yylex_destroy (void);
+
typedef struct _lexInput {
DataType data;
struct _lexInput *next;
commit 4ae8bb3a888432b3101e16fbbd63e04c9229fb9b
Author: Keith Packard <keithp at keithp.com>
Date: Sun Jan 6 15:20:10 2008 -0800
Add new '+' type operator; creates subtypes for struct/union types.
Merges two struct, union or enum types together to form
a unified type containing each of the elements of the two
original structures.
diff --git a/file.c b/file.c
index 933b544..0628cfa 100644
--- a/file.c
+++ b/file.c
@@ -1659,7 +1659,13 @@ FilePutType (Value f, Type *t, Bool minimal)
break;
case type_struct:
case type_union:
- if (t->structs.enumeration)
+ if (t->structs.left && t->structs.right)
+ {
+ FilePutType (f, t->structs.left, False);
+ FilePuts (f, " + ");
+ FilePutType (f, t->structs.right, False);
+ }
+ else if (t->structs.enumeration)
{
FilePuts (f, "enum { ");
st = t->structs.structs;
diff --git a/gram.y b/gram.y
index 0f2970a..1437f08 100644
--- a/gram.y
+++ b/gram.y
@@ -941,6 +941,16 @@ type : subtype subscripts %prec CALL
{ $$ = NewTypeRef (NewTypeRef ($2, False), False); }
| LAND type %prec POINTER
{ $$ = NewTypeRef ($2, False); }
+ | type PLUS type
+ {
+ if (ParseCanonType ($1, False) != CanonTypeDefined)
+ YYERROR;
+ if (ParseCanonType ($3, False) != CanonTypeDefined)
+ YYERROR;
+ $$ = NewTypePlus ($1, $3);
+ if (!$$)
+ YYERROR;
+ }
;
subtype : basetype
| STRUCT OC struct_members CC
diff --git a/type.c b/type.c
index fa2b59c..33c77fc 100644
--- a/type.c
+++ b/type.c
@@ -89,6 +89,8 @@ TypeStructMark (void *object)
TypeStruct *ts = object;
MemReference (ts->structs);
+ MemReference (ts->left);
+ MemReference (ts->right);
}
static void
@@ -215,6 +217,8 @@ NewTypeStruct (StructType *structs)
t->base.tag = type_struct;
t->structs.structs = structs;
t->structs.enumeration = False;
+ t->structs.left = NULL;
+ t->structs.right = NULL;
RETURN (t);
}
@@ -228,9 +232,74 @@ NewTypeUnion (StructType *structs, Bool enumeration)
t->base.tag = type_union;
t->structs.structs = structs;
t->structs.enumeration = enumeration;
+ t->structs.left = NULL;
+ t->structs.right = NULL;
RETURN (t);
}
+static Type *
+TypePlusPart (Type *type)
+{
+ type = TypeCanon (type);
+ switch (type->base.tag) {
+ case type_struct:
+ case type_union:
+ break;
+ default:
+ ParseError ("Type '%T' not struct or union", type);
+ return NULL;
+ }
+ return type;
+}
+
+static int
+AddPlusType (StructType *new, StructType *old, int pos)
+{
+ int i;
+
+ for (i = 0; i < old->nelements; i++) {
+ AddBoxType (&new->types, BoxTypesElements (old->types)[i]);
+ StructTypeAtoms (new)[pos] = StructTypeAtoms (old)[i];
+ pos++;
+ }
+ return pos;
+}
+
+Type *
+NewTypePlus (Type *left, Type *right)
+{
+ ENTER ();
+ Type *t, *l, *r;;
+ StructType *st;
+ int i;
+
+ l = TypePlusPart (left);
+ r = TypePlusPart (right);
+ if (!l || !r)
+ RETURN (NULL);
+ if (l->base.tag != r->base.tag) {
+ ParseError ("'%T' and '%T' are not the same type", left, right);
+ RETURN (NULL);
+ }
+
+ st = NewStructType (l->structs.structs->nelements + r->structs.structs->nelements);
+ i = AddPlusType (st, l->structs.structs, 0);
+ if (i < 0)
+ RETURN (NULL);
+ i = AddPlusType (st, r->structs.structs, i);
+ if (i < 0)
+ RETURN (NULL);
+
+ t = ALLOCATE (&TypeStructType, sizeof (TypeStruct));
+ t->base.tag = l->base.tag;
+ t->structs.structs = st;
+ t->structs.enumeration = l->structs.enumeration && r->structs.enumeration;
+ t->structs.left = left;
+ t->structs.right = right;
+ RETURN (t);
+}
+
+
Type *
NewTypeTypes (TypeElt *elt)
{
diff --git a/value.h b/value.h
index af33302..fbebfe8 100644
--- a/value.h
+++ b/value.h
@@ -440,6 +440,7 @@ typedef struct _typeStruct {
TypeBase base;
StructTypePtr structs;
Bool enumeration;
+ TypePtr left, right;
} TypeStruct;
typedef struct _typeElt {
@@ -483,6 +484,7 @@ extern Type *typePrim[rep_void + 1];
Type *NewTypeName (ExprPtr expr, SymbolPtr name);
Type *NewTypeRef (Type *ref, Bool pointer);
+Type *NewTypePlus (Type *left, Type *right);
Type *NewTypePointer (Type *ref);
Type *NewTypeFunc (Type *ret, ArgType *args);
Type *NewTypeArray (Type *type, ExprPtr dimensions, Bool resizable);
commit 7761936b1b7318d29d4cc948308f9742f5c3f433
Author: Keith Packard <keithp at keithp.com>
Date: Fri Jan 4 00:41:57 2008 -0800
Bump to version 2.64
diff --git a/configure.in b/configure.in
index 7eaa968..b920c70 100644
--- a/configure.in
+++ b/configure.in
@@ -7,7 +7,7 @@ dnl for licensing information.
AC_PREREQ(2.59)
AC_INIT([nickle],
- 2.63,
+ 2.64,
[http://nickle.org],
nickle)
diff --git a/debian/changelog b/debian/changelog
index 68c4aeb..eb35ca5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+nickle (2.64-1) unstable; urgency=low
+ * Fix float floor/ceil with small values
+ * Copy hash key/value on insert
+ * Bump to version 2.64
+
+ -- Keith Packard <keithp at keithp.com> Fri, 04 Jan 2008 00:41:15 -0800
+
nickle (2.63-1) unstable; urgency=low
* Avoid using extra libraries unless necessary
* Fix -Wl,-E testing by using AC_LINK_IFELSE
More information about the Nickle
mailing list