| 1 | \ (C) Copyright 2005 IBM Corporation. All Rights Reserved. |
|---|
| 2 | \ Licensed under the Common Public License (CPL) version 1.0 |
|---|
| 3 | \ for full details see: |
|---|
| 4 | \ http://www.opensource.org/licenses/cpl1.0.php |
|---|
| 5 | \ |
|---|
| 6 | \ Module Author: David L. Paktor dlpaktor@us.ibm.com |
|---|
| 7 | |
|---|
| 8 | \ Support file for development of FCode that uses Local Values |
|---|
| 9 | \ FLoad this right after LocalValuesSupport.fth |
|---|
| 10 | \ Remove it from your final product. |
|---|
| 11 | |
|---|
| 12 | \ Exported Function: max-local-storage-size ( -- n ) |
|---|
| 13 | \ Returns the measured maximum size of storage for Local Values |
|---|
| 14 | \ used by any given test run. This number can be used to guide |
|---|
| 15 | \ the declaration of _local-storage-size_ |
|---|
| 16 | \ |
|---|
| 17 | \ (C) Copyright 2005 IBM Corporation. All Rights Reserved. |
|---|
| 18 | \ Module Author: David L. Paktor dlpaktor@us.ibm.com |
|---|
| 19 | |
|---|
| 20 | \ Count the current depth on a per-instance basis, |
|---|
| 21 | \ but collect the maximum depth over all instances. |
|---|
| 22 | |
|---|
| 23 | headers |
|---|
| 24 | 0 instance value local-storage-depth |
|---|
| 25 | |
|---|
| 26 | external |
|---|
| 27 | 0 value max-local-storage-size |
|---|
| 28 | headers |
|---|
| 29 | |
|---|
| 30 | \ Overload the {push-locals} and {pop-locals} routines to do this. |
|---|
| 31 | \ Do not suppress the overload warnings; they'll serve as a reminder. |
|---|
| 32 | : {pop-locals} ( #locals -- ) |
|---|
| 33 | local-storage-depth over - to local-storage-depth |
|---|
| 34 | {pop-locals} |
|---|
| 35 | ; |
|---|
| 36 | |
|---|
| 37 | : {push-locals} ( #ilocals #ulocals -- ) |
|---|
| 38 | 2dup + local-storage-depth + |
|---|
| 39 | dup to local-storage-depth |
|---|
| 40 | max-local-storage-size max |
|---|
| 41 | to max-local-storage-size |
|---|
| 42 | {push-locals} |
|---|
| 43 | ; |
|---|
| 44 | |
|---|