Files
mercury/tests/hard_coded/deconstruct_arg.exp
Zoltan Somogyi 7c526ed15e Allow the RTTI routines and the debugger to treat arrays as other types.
Estimated hours taken: 4 + 4 in mail
Branches: main

Allow the RTTI routines and the debugger to treat arrays as other types.

The RTTI routines used to pretend that terms of array type had no arguments.
This led the browser to believe that their size was small, and handed them
over to io__write, which then printed the entire array. For large arrays,
this could take minutes. It also led the browser to believe that you can't
"cd" to an element of an array.

The RTTI routines now treat arrays mostly like they treat tuples, which fixes
both problems.

The debugger's prettyprinters do not yet use limited_deconstruct; that is
future work.

library/std_util.m:
	Add a new predicate, limited_deconstruct, which usually does what
	deconstruct does, but fails (and does not allocate any memory) if
	the arity of the supplied term is beyond a given limit. With normal
	terms, the memory allocated by deconstruct to hold the typeinfos
	of the arguments is not a problem. However, arrays can have millions
	of elements, and for them this *is* a problem. Programmers can avoid
	this problem by using limited_deconstruct instead of deconstruct.

	Make ML_arg (used by the arg and argument predicates) avoid the
	construction of a typeinfo vector for all the arguments, for the same
	reason.

	Since we now need more variants of ML_expand than ever, and we don't
	want the new, relatively rarely used functionality to slow down the old
	functionality, create several variants of ML_expand, each specialized
	to a given use, and choose between them at compile time, not run time.
	This should actually speed up the old functionality.

runtime/mercury_ml_expand_body.h:
	A new file which is included several times in library/std_util.m,
	containing the bodies of the several variants of the old ML_expand.

runtime/Mmakefile:
	Mention the new file.

browser/browse.m:
	Avoid unlimited deconstructions when checking whether the term fits
	within the size range we give to io__write.

	Special case path resolution on terms of type array, because while
	in the debugger we count arguments from one, array elements start at
	index zero, and any other behavior would be misleading.

tests/hard_coded/deconstruct_arg.{m,exp}:
	A new test case to check the various variants of ML_expand through
	its callers, the predicates functor, argument, deconstruct and
	limited_deconstruct, on all kinds of data types.

tests/hard_coded/Mmakefile:
	Enable the new test case.
2001-06-22 03:14:33 +00:00

163 lines
4.6 KiB
Plaintext

apple/1
argument 0 of apple([]) is []
argument 1 of apple([]) doesn't exist
argument 2 of apple([]) doesn't exist
deconstruct: functor apple arity 1
[[]]
limited deconstruct 3 of apple([])
functor apple arity 1 [[]]
apple/1
argument 0 of apple([9, 5, 1]) is [9, 5, 1]
argument 1 of apple([9, 5, 1]) doesn't exist
argument 2 of apple([9, 5, 1]) doesn't exist
deconstruct: functor apple arity 1
[[9, 5, 1]]
limited deconstruct 3 of apple([9, 5, 1])
functor apple arity 1 [[9, 5, 1]]
zop/2
argument 0 of zop(3.30000000000000, 2.03000000000000) is 3.30000000000000
argument 1 of zop(3.30000000000000, 2.03000000000000) is 2.03000000000000
argument 2 of zop(3.30000000000000, 2.03000000000000) doesn't exist
deconstruct: functor zop arity 2
[3.30000000000000, 2.03000000000000]
limited deconstruct 3 of zop(3.30000000000000, 2.03000000000000)
functor zop arity 2 [3.30000000000000, 2.03000000000000]
zap/3
argument 0 of zap(50, 51.0000000000000, 52) is 50
argument 1 of zap(50, 51.0000000000000, 52) is 51.0000000000000
argument 2 of zap(50, 51.0000000000000, 52) is 52
deconstruct: functor zap arity 3
[50, 51.0000000000000, 52]
limited deconstruct 3 of zap(50, 51.0000000000000, 52)
functor zap arity 3 [50, 51.0000000000000, 52]
zip/4
argument 0 of zip(50, 51, 52, 53) is 50
argument 1 of zip(50, 51, 52, 53) is 51
argument 2 of zip(50, 51, 52, 53) is 52
deconstruct: functor zip arity 4
[50, 51, 52, 53]
limited deconstruct 3 of zip(50, 51, 52, 53)
failed
wombat/0
argument 0 of wombat doesn't exist
argument 1 of wombat doesn't exist
argument 2 of wombat doesn't exist
deconstruct: functor wombat arity 0
[]
limited deconstruct 3 of wombat
functor wombat arity 0 []
qwerty/1
argument 0 of qwerty(5) is 5
argument 1 of qwerty(5) doesn't exist
argument 2 of qwerty(5) doesn't exist
deconstruct: functor qwerty arity 1
[5]
limited deconstruct 3 of qwerty(5)
functor qwerty arity 1 [5]
'a'/0
argument 0 of a doesn't exist
argument 1 of a doesn't exist
argument 2 of a doesn't exist
deconstruct: functor 'a' arity 0
[]
limited deconstruct 3 of a
functor 'a' arity 0 []
3.14159000000000/0
argument 0 of 3.14159000000000 doesn't exist
argument 1 of 3.14159000000000 doesn't exist
argument 2 of 3.14159000000000 doesn't exist
deconstruct: functor 3.14159000000000 arity 0
[]
limited deconstruct 3 of 3.14159000000000
functor 3.14159000000000 arity 0 []
4/0
argument 0 of 4 doesn't exist
argument 1 of 4 doesn't exist
argument 2 of 4 doesn't exist
deconstruct: functor 4 arity 0
[]
limited deconstruct 3 of 4
functor 4 arity 0 []
univ_cons/1
argument 0 of ["hi! I\'m a univ!"] is ["hi! I\'m a univ!"]
argument 1 of ["hi! I\'m a univ!"] doesn't exist
argument 2 of ["hi! I\'m a univ!"] doesn't exist
deconstruct: functor univ_cons arity 1
[["hi! I\'m a univ!"]]
limited deconstruct 3 of ["hi! I\'m a univ!"]
functor univ_cons arity 1 [["hi! I\'m a univ!"]]
<<predicate>>/0
argument 0 of '<<predicate>>' doesn't exist
argument 1 of '<<predicate>>' doesn't exist
argument 2 of '<<predicate>>' doesn't exist
deconstruct: functor <<predicate>> arity 0
[]
limited deconstruct 3 of '<<predicate>>'
functor <<predicate>> arity 0 []
{}/2
argument 0 of {1, 'b'} is 1
argument 1 of {1, 'b'} is 'b'
argument 2 of {1, 'b'} doesn't exist
deconstruct: functor {} arity 2
[1, 'b']
limited deconstruct 3 of {1, 'b'}
functor {} arity 2 [1, 'b']
{}/3
argument 0 of {1, 'b', "third"} is 1
argument 1 of {1, 'b', "third"} is 'b'
argument 2 of {1, 'b', "third"} is "third"
deconstruct: functor {} arity 3
[1, 'b', "third"]
limited deconstruct 3 of {1, 'b', "third"}
functor {} arity 3 [1, 'b', "third"]
{}/4
argument 0 of {1, 'b', "third", {1, 2, 3, 4}} is 1
argument 1 of {1, 'b', "third", {1, 2, 3, 4}} is 'b'
argument 2 of {1, 'b', "third", {1, 2, 3, 4}} is "third"
deconstruct: functor {} arity 4
[1, 'b', "third", {1, 2, 3, 4}]
limited deconstruct 3 of {1, 'b', "third", {1, 2, 3, 4}}
failed
<<array>>/2
argument 0 of array([1000, 2000]) is 1000
argument 1 of array([1000, 2000]) is 2000
argument 2 of array([1000, 2000]) doesn't exist
deconstruct: functor <<array>> arity 2
[1000, 2000]
limited deconstruct 3 of array([1000, 2000])
functor <<array>> arity 2 [1000, 2000]
<<array>>/3
argument 0 of array([100, 200, 300]) is 100
argument 1 of array([100, 200, 300]) is 200
argument 2 of array([100, 200, 300]) is 300
deconstruct: functor <<array>> arity 3
[100, 200, 300]
limited deconstruct 3 of array([100, 200, 300])
functor <<array>> arity 3 [100, 200, 300]
<<array>>/4
argument 0 of array([10, 20, 30, 40]) is 10
argument 1 of array([10, 20, 30, 40]) is 20
argument 2 of array([10, 20, 30, 40]) is 30
deconstruct: functor <<array>> arity 4
[10, 20, 30, 40]
limited deconstruct 3 of array([10, 20, 30, 40])
failed