From dae111326db85383af87cdf79cd774edec30a05f Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Thu, 27 Jul 2017 23:13:50 +0200 Subject: Don't allow tuples with arity > 32 (ABC-machine limitation) --- Sil/Compile.icl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Sil/Compile.icl') diff --git a/Sil/Compile.icl b/Sil/Compile.icl index dc846d2..7ef48e4 100644 --- a/Sil/Compile.icl +++ b/Sil/Compile.icl @@ -30,6 +30,7 @@ import Sil.Util.Printer instance toString CompileError where toString (UndefinedName n) = "Undefined name '" <+ n <+ "'." + toString (UndefinedField f) = "Undefined field '" <+ f <+ "'." toString VariableLabel = "Variable stored at label." toString FunctionOnStack = "Function stored on the stack." toString (TypeError err e) = "Type error in '" <+ e <+ "': " <+ err @@ -376,6 +377,7 @@ where comment "Return" *> gen e *> gets returnType >>= \rettype -> + comment ("Checking type " <+ rettype <+ " on " <+ e <+ "...") *> checkType rettype e *> gets stackoffsets >>= \so -> updateReturnFrame (typeSize rettype) so *> @@ -495,13 +497,14 @@ where shrinkStack {zero & asize=i} gen e=:(Field f e`) | isTuple = - getType e` >>= \(TTuple arity tes) -> + getType e` >>= \t=:(TTuple arity tes) -> gen e` *> tell [ 'ABC'.ReplArgs arity arity , 'ABC'.Pop_a (tupleEl - 1) , 'ABC'.Update_a 0 (arity - tupleEl) , 'ABC'.Pop_a (arity - tupleEl) ] *> + if (0 >= tupleEl || tupleEl > arity) (error $ TypeError (IllegalField f t) e) nop *> case typeSize $ tes!!(tupleEl - 1) of {bsize=0} -> nop {btypes} -> mapM (flip toBStack 1) btypes *> nop -- cgit v1.2.3