Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

newclay/compiler: update evaluation and analysis to handle minor AST …

…changes
  • Loading branch information...
commit 42280af02146014c7c12d497394329ed994222d8 1 parent 4a7b1fc
@jckarter jckarter authored
View
5 newclay/compiler/newclay/analysis/analysis.clay
@@ -476,6 +476,9 @@ overload analyzeExprListItem(
overload analyzeNode(s:SpecializationContext, env:Env, expr:ast.Expr) Maybe[RTValues]
= analyzeNode(s, env, *expr);
+overload analyzeNode(s:SpecializationContext, env:Env, expr:ast.SubExprList) Maybe[RTValues]
+ = analyzeNode(s, env, expr.exprList);
+
overload analyzeNode(s:SpecializationContext, env:Env, unpack:ast.UnpackExpr)
= analyzeMultiExprSubnode(s, env, unpack.expr);
@@ -1196,6 +1199,7 @@ private singleExpr(s, env, exprList:ast.ExprList) {
ast.Expr, x => Maybe(x),
ast.StatementExprList, x =>
analyzeStatementExprNode2(s, env, x.statements, x.exprList, singleExpr),
+ ast.SubExprList, x => singleExpr(s, env, x.exprList),
);
}
@@ -1206,6 +1210,7 @@ private singleExpr?(exprList:ast.ExprList) {
ast.UnpackExpr, x => false,
ast.Expr, x => true,
ast.StatementExprList, x => singleExpr?(x.exprList),
+ ast.SubExprList, x => singleExpr?(x.exprList),
);
}
View
2  newclay/compiler/newclay/ast/ast.clay
@@ -204,7 +204,7 @@ overload Identifier(x:S) = Identifier(String(x));
alias ExprList = Vector[ExprListItem];
record SubExprList = ast(
- exprs: ExprList,
+ exprList: ExprList,
);
variant ExprListItem = UnpackExpr
View
20 newclay/compiler/newclay/evaluator/evaluator.clay
@@ -764,6 +764,9 @@ procedure evaluateExprListItem;
overload evaluateExprListItem(x:ast.ExprListItem, env) {
return evaluateExprListItem(*x, env);
}
+overload evaluateExprListItem(x:ast.SubExprList, env) {
+ return evaluateExprList(x.exprList, env);
+}
overload evaluateExprListItem(x:ast.Expr, env) {
return ValueList(evaluateExpr(x, env));
}
@@ -927,10 +930,14 @@ overload evaluateCall(x:RTPrimitive, args) ValueList {
return ValueList();
}
-evaluateLambdaCodeBody(x:ast.StatementReturnExprList, env) {
- verifyStatementExprStatements(x.statements);
+overload evaluateLambdaCodeBody(x, env) {
+ genericError("lambda block statement not allowed in static context");
+ return ValueList();
+}
+
+evaluateLambdaCodeBody(x:ast.ExprCodeBody, env) {
var exprList = ast.ExprList();
- for (item in x.exprList) {
+ for (item in x.exprs) {
withLocation(item, () ref=> {
if (just?(item.kind))
genericError("reference returns not allowed in static lambda evaluation");
@@ -941,11 +948,6 @@ evaluateLambdaCodeBody(x:ast.StatementReturnExprList, env) {
return evaluateExprList(exprList, env);
}
-overload evaluateLambdaCodeBody(x:ast.Block, env) {
- genericError("lambda block statement not allowed in static context");
- return ValueList();
-}
-
//
// evaluateIndexing
@@ -2312,7 +2314,7 @@ private rtLambdaResults(l:StaticLambdaValue) {
var s = SpecializationContext(&body, &complete?, &returns);
addEnvRvalues(s, l.env);
- return analyzeCodeBody(s, l.env, transformLambdaCodeBody(*l.value.body));
+ return analyzeCodeBody(s, l.env, l.value.body);
}
private addEnvRvalues(s, envParent) {}
Please sign in to comment.
Something went wrong with that request. Please try again.