@@ -1195,6 +1195,8 @@ globalAssignmentFun(x:globalAssignmentCode):Expr := (
11951195
11961196ParallelAssignmentError(n:int):Expr := buildErrorPacket(
11971197 "parallel assignment: expected a sequence of " + tostring(n) + " values");
1198+ ParallelAssignmentErrorAt(n:int):Expr := buildErrorPacket(
1199+ "parallel assignment: failure at argument " + tostring(n));
11981200parallelAssignmentFun(x:parallelAssignmentCode):Expr := (
11991201 nlhs := length(x.lhs);
12001202 value := eval(x.rhs);
@@ -1203,16 +1205,77 @@ parallelAssignmentFun(x:parallelAssignmentCode):Expr := (
12031205 if nlhs == 1 then value = seq(value);
12041206 when value
12051207 is values:Sequence do (
1206- if nlhs == length(values)
1207- then Expr(new Sequence len nlhs at i do provide (
1208- when x.lhs.i
1209- is y:globalMemoryReferenceCode do (
1210- globalAssignment(y.var.frameindex, y.var, values.i))
1211- is y:localMemoryReferenceCode do (
1212- localAssignment(y.nestingDepth, y.frameindex, values.i))
1213- is y:threadMemoryReferenceCode do (
1214- globalAssignment(y.var.frameindex, y.var, values.i))
1215- else nullE)) -- TODO: handle other cases
1208+ if nlhs == length(values) then (
1209+ pos := codePosition(x.rhs);
1210+ e := nullE;
1211+ result := new Sequence len nlhs at i do provide (
1212+ when e is Error do nullE
1213+ else (
1214+ c := Code(evaluatedCode(values.i, pos));
1215+ r := when x.lhs.i
1216+ is y:globalMemoryReferenceCode do (
1217+ globalAssignment(y.var.frameindex, y.var, values.i))
1218+ is y:localMemoryReferenceCode do (
1219+ localAssignment(y.nestingDepth, y.frameindex, values.i))
1220+ is y:threadMemoryReferenceCode do (
1221+ globalAssignment(y.var.frameindex, y.var, values.i))
1222+ is y:binaryCode do (
1223+ codeseq := CodeSequence(
1224+ convertGlobalOperator(y.oper), y.lhs, y.rhs, c);
1225+ if x.colon then InstallMethodFun(codeseq)
1226+ else (
1227+ if y.oper == DotS.symbol || y.oper == SharpS.symbol
1228+ then AssignElemFun(y.lhs, y.rhs, c)
1229+ else InstallValueFun(codeseq)))
1230+ is y:adjacentCode do (
1231+ codeseq := CodeSequence(
1232+ convertGlobalOperator(AdjacentS.symbol),
1233+ y.lhs, y.rhs, c);
1234+ if x.colon then InstallMethodFun(codeseq)
1235+ else InstallValueFun(codeseq))
1236+ is y:unaryCode do (
1237+ oper := convertGlobalOperator(y.oper);
1238+ if x.colon then UnaryInstallMethodFun(oper, y.rhs, c)
1239+ else UnaryInstallValueFun(oper, y.rhs, c))
1240+ is y:sequenceCode do (
1241+ parallelAssignmentFun(parallelAssignmentCode(x.colon,
1242+ y.x, c, y.position)))
1243+ is y:listCode do (
1244+ parallelAssignmentFun(parallelAssignmentCode(x.colon,
1245+ y.y, c, y.position)))
1246+ is y:arrayCode do (
1247+ parallelAssignmentFun(parallelAssignmentCode(x.colon,
1248+ y.z, c, y.position)))
1249+ is y:angleBarListCode do (
1250+ parallelAssignmentFun(parallelAssignmentCode(x.colon,
1251+ y.t, c, y.position)))
1252+ is y:newCode do (
1253+ if x.colon
1254+ then AssignNewFun(y.newClause, c)
1255+ else ParallelAssignmentErrorAt(i + 1))
1256+ is y:newOfCode do (
1257+ if x.colon
1258+ then AssignNewOfFun(y.newClause, y.ofClause, c)
1259+ else ParallelAssignmentErrorAt(i + 1))
1260+ is y:newFromCode do (
1261+ if x.colon
1262+ then AssignNewFromFun(y.newClause, y.fromClause, c)
1263+ else ParallelAssignmentErrorAt(i + 1))
1264+ is y:newOfFromCode do (
1265+ if x.colon
1266+ then AssignNewOfFromFun(CodeSequence(
1267+ y.newClause, y.ofClause, y.fromClause, c))
1268+ else ParallelAssignmentErrorAt(i + 1))
1269+ is nullCode do nullE
1270+ else ParallelAssignmentErrorAt(i + 1);
1271+ when r
1272+ is Error do (
1273+ e = r;
1274+ nullE)
1275+ else r));
1276+ when e
1277+ is Error do e
1278+ else if nlhs == 1 then result.0 else Expr(result))
12161279 else ParallelAssignmentError(nlhs))
12171280 else ParallelAssignmentError(nlhs));
12181281
0 commit comments