[Commit]
nickle ChangeLog, 1.67, 1.68 compile.c, 1.155, 1.156 gram.y,
1.135, 1.136 lex.l, 1.75, 1.76 nickle.h, 1.118, 1.119 scope.c,
1.30, 1.31
Keith Packard
commit at keithp.com
Thu Jun 17 13:30:51 PDT 2004
Committed by: keithp
Update of /local/src/CVS/nickle
In directory home.keithp.com:/tmp/cvs-serv14549
Modified Files:
ChangeLog compile.c gram.y lex.l nickle.h scope.c
Log Message:
2004-06-17 Keith Packard <keithp at keithp.com>
* compile.c: (CompileLvalue):
Handle nested & in Lvalues with auto_reference so that &&7 works.
* gram.y:
* lex.l:
* nickle.h:
* scope.c: (NamespaceLocate):
Make ** and && work as unary operators.
Get CodePtr out of CurrentFrame so that execution can
refer to frame contents up the static link.
Index: ChangeLog
===================================================================
RCS file: /local/src/CVS/nickle/ChangeLog,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- ChangeLog 14 Jun 2004 06:58:32 -0000 1.67
+++ ChangeLog 17 Jun 2004 20:30:47 -0000 1.68
@@ -1,3 +1,15 @@
+2004-06-17 Keith Packard <keithp at keithp.com>
+
+ * compile.c: (CompileLvalue):
+ Handle nested & in Lvalues with auto_reference so that &&7 works.
+ * gram.y:
+ * lex.l:
+ * nickle.h:
+ * scope.c: (NamespaceLocate):
+ Make ** and && work as unary operators.
+ Get CodePtr out of CurrentFrame so that execution can
+ refer to frame contents up the static link.
+
2004-06-13 Keith Packard <keithp at keithp.com>
* file.5c:
Index: compile.c
===================================================================
RCS file: /local/src/CVS/nickle/compile.c,v
retrieving revision 1.155
retrieving revision 1.156
diff -u -d -r1.155 -r1.156
--- compile.c 8 Jun 2004 09:30:53 -0000 1.155
+++ compile.c 17 Jun 2004 20:30:47 -0000 1.156
@@ -526,13 +526,14 @@
case AMPER:
obj = CompileLvalue (obj, expr->tree.left, stat, code,
createIfNecessary, assign, initialize,
- True, False);
+ True, auto_reference);
expr->base.type = expr->tree.left->base.type;
break;
case COLONCOLON:
obj = CompileLvalue (obj, expr->tree.right, stat, code, False, assign, initialize,
amper, auto_reference);
expr->base.type = expr->tree.right->base.type;
+ amper = False; /* has been dealt with in nested call */
break;
case DOT:
obj = _CompileExpr (obj, expr->tree.left, True, stat, code);
@@ -666,6 +667,15 @@
}
}
}
+ else
+ {
+ if (amper && auto_reference)
+ {
+ BuildInst (obj, OpUnFunc, inst, stat);
+ inst->unfunc.func = do_reference;
+ expr->base.type = NewTypeRef (expr->base.type, True);
+ }
+ }
assert (expr->base.type);
RETURN (obj);
}
Index: gram.y
===================================================================
RCS file: /local/src/CVS/nickle/gram.y,v
retrieving revision 1.135
retrieving revision 1.136
diff -u -d -r1.135 -r1.136
--- gram.y 8 Jun 2004 09:30:54 -0000 1.135
+++ gram.y 17 Jun 2004 20:30:47 -0000 1.136
@@ -188,7 +188,7 @@
%left TIMES DIVIDE DIV MOD
%right POW
%left UNIONCAST
-%right UMINUS BANG FACT LNOT INC DEC STAR AMPER THREADID
+%right UMINUS BANG FACT LNOT INC DEC STAR STARSTAR AMPER THREADID
%left OS CS DOT ARROW STAROS CALL OP CP
%right POINTER
%right COLONCOLON
@@ -257,11 +257,12 @@
Value t;
NamespacePtr s;
FramePtr f;
+ CodePtr c;
e = BuildCall ("Command", "display",
1,NewExprTree (EXPR, $2, 0));
- GetNamespace (&s, &f);
- t = NewThread (f, CompileExpr (e, 0));
+ GetNamespace (&s, &f, &c);
+ t = NewThread (f, CompileExpr (e, c));
ThreadsRun (t, 0);
EXIT ();
}
@@ -272,11 +273,12 @@
Value t;
NamespacePtr s;
FramePtr f;
+ CodePtr c;
e = BuildCall("Command", "display_base",
2, NewExprTree (EXPR, $2, 0), $4);
- GetNamespace (&s, &f);
- t = NewThread (f, CompileExpr (e, 0));
+ GetNamespace (&s, &f, &c);
+ t = NewThread (f, CompileExpr (e, c));
ThreadsRun (t, 0);
EXIT ();
}
@@ -284,11 +286,12 @@
{
ENTER ();
NamespacePtr s;
- FramePtr f;
- Value t;
+ FramePtr f;
+ CodePtr c;
+ Value t;
- GetNamespace (&s, &f);
- t = NewThread (f, CompileStat ($2, 0));
+ GetNamespace (&s, &f, &c);
+ t = NewThread (f, CompileStat ($2, c));
ThreadsRun (t, 0);
EXIT ();
}
@@ -299,18 +302,19 @@
Value t;
NamespacePtr s;
FramePtr f;
- CommandPtr c;
+ CodePtr c;
+ CommandPtr cmd;
- c = CommandFind (CurrentCommands, $2);
- if (!c)
+ cmd = CommandFind (CurrentCommands, $2);
+ if (!cmd)
ParseError ("Undefined command \"%s\"", AtomName ($2));
else
{
e = NewExprTree (OP,
- NewExprConst (POLY_CONST, c->func),
+ NewExprConst (POLY_CONST, cmd->func),
$3);
- GetNamespace (&s, &f);
- t = NewThread (f, CompileExpr (e, 0));
+ GetNamespace (&s, &f, &c);
+ t = NewThread (f, CompileExpr (e, c));
ThreadsRun (t, 0);
}
EXIT ();
@@ -323,18 +327,19 @@
Value t;
NamespacePtr s;
FramePtr f;
- CommandPtr c;
+ CodePtr c;
+ CommandPtr cmd;
- c = CommandFind (CurrentCommands, $2);
- if (!c)
+ cmd = CommandFind (CurrentCommands, $2);
+ if (!cmd)
ParseError ("Undefined command \"%s\"", AtomName ($2));
else
{
e = NewExprTree (OP,
- NewExprConst (POLY_CONST, c->func),
+ NewExprConst (POLY_CONST, cmd->func),
$3);
- GetNamespace (&s, &f);
- t = NewThread (f, CompileExpr (e, 0));
+ GetNamespace (&s, &f, &c);
+ t = NewThread (f, CompileExpr (e, c));
ThreadsRun (t, 0);
}
EXIT ();
@@ -904,6 +909,10 @@
}
| TIMES type %prec POINTER
{ $$ = NewTypeRef ($2, True); }
+ | STARSTAR type %prec POINTER
+ { $$ = NewTypeRef (NewTypeRef ($2, True), True); }
+ | AND type %prec POINTER
+ { $$ = NewTypeRef (NewTypeRef ($2, False), False); }
| LAND type %prec POINTER
{ $$ = NewTypeRef ($2, False); }
;
@@ -1240,8 +1249,14 @@
}
| TIMES simpleexpr %prec STAR
{ $$ = NewExprTree(STAR, $2, (Expr *) 0); }
+ | STARSTAR simpleexpr %prec STAR
+ { $$ = NewExprTree(STAR, NewExprTree (STAR, $2, 0), 0); }
| LAND simpleexpr %prec AMPER
{ $$ = NewExprTree(AMPER, $2, (Expr *) 0); }
+ | AND simpleexpr %prec AMPER
+ { $$ = NewExprTree(AMPER,
+ NewExprTree (AMPER, $2, (Expr *) 0),
+ (Expr *) 0); }
| MINUS simpleexpr %prec UMINUS
{ $$ = NewExprTree(UMINUS, $2, (Expr *) 0); }
| LNOT simpleexpr
@@ -1272,7 +1287,7 @@
{ $$ = NewExprTree(DIV, $1, $3); }
| simpleexpr MOD simpleexpr
{ $$ = NewExprTree(MOD, $1, $3); }
- | simpleexpr POW simpleexpr
+ | simpleexpr STARSTAR simpleexpr %prec POW
{
$$ = NewExprTree(POW,
BuildName ("Math", "pow"),
@@ -1644,10 +1659,14 @@
}
void
-GetNamespace (NamespacePtr *scope, FramePtr *fp)
+GetNamespace (NamespacePtr *scope, FramePtr *fp, CodePtr *cp)
{
*scope = CurrentNamespace;
*fp = CurrentFrame;
+ if (CurrentFrame)
+ *cp = CurrentFrame->function->func.code;
+ else
+ *cp = 0;
}
ExprPtr
Index: lex.l
===================================================================
RCS file: /local/src/CVS/nickle/lex.l,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -d -r1.75 -r1.76
--- lex.l 8 Jun 2004 09:30:54 -0000 1.75
+++ lex.l 17 Jun 2004 20:30:47 -0000 1.76
@@ -388,7 +388,7 @@
"*" { yylval.ints = TIMES; return TIMES; }
"/" { yylval.ints = DIVIDE; return DIVIDE; }
"//" { yylval.ints = DIV; return DIV; }
-"**" { yylval.ints = POW; return POW; }
+"**" { yylval.ints = STARSTAR; return STARSTAR; }
"%" { yylval.ints = MOD; return MOD; }
"!" { yylval.ints = BANG; return BANG; }
"#" { yylval.ints = POUND; return POUND; }
Index: nickle.h
===================================================================
RCS file: /local/src/CVS/nickle/nickle.h,v
retrieving revision 1.118
retrieving revision 1.119
diff -u -d -r1.118 -r1.119
--- nickle.h 8 Jun 2004 09:30:54 -0000 1.118
+++ nickle.h 17 Jun 2004 20:30:47 -0000 1.119
@@ -690,7 +690,7 @@
Value lookupVar (char *ns, char *n);
void setVar (NamespacePtr, char *, Value, Type *type);
-void GetNamespace (NamespacePtr *, FramePtr *);
+void GetNamespace (NamespacePtr *, FramePtr *, CodePtr *);
Bool NamespaceLocate (Value names, NamespacePtr *s, SymbolPtr *symbol, Publish *publish, Bool complain);
ExprPtr BuildName (char *ns_name, char *name);
ExprPtr BuildCall (char *, char *, int, ...);
Index: scope.c
===================================================================
RCS file: /local/src/CVS/nickle/scope.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- scope.c 16 Apr 2004 21:41:52 -0000 1.30
+++ scope.c 17 Jun 2004 20:30:47 -0000 1.31
@@ -226,6 +226,7 @@
int i;
NamespacePtr namespace;
FramePtr f;
+ CodePtr c;
Value string;
NamelistPtr namelist = 0;
SymbolPtr symbol;
@@ -240,7 +241,7 @@
NewInt (0), names);
return False;
}
- GetNamespace (&namespace, &f);
+ GetNamespace (&namespace, &f, &c);
for (i = 0; i < ArrayLimits(&names->array)[0]; i++)
{
string = ArrayValue (&names->array, i);
More information about the Commit
mailing list