aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorronny2000-02-24 12:26:59 +0000
committerronny2000-02-24 12:26:59 +0000
commite476c30a6367b8d0cdcf6dec69ab152e8d8fecc8 (patch)
treea682ded63ad34c202f344779cb562012b88e7cbf
parentInitial import (diff)
Removed debug modules (they moved to separate directory)
git-svn-id: https://svn.cs.ru.nl/repos/clean-compiler/trunk@103 1f8540f1-abd5-4d5b-9d24-4c5ce8603e2d
-rw-r--r--frontend/Debug.dcl17
-rw-r--r--frontend/Debug.icl173
-rw-r--r--frontend/RWSDebug.dcl5
-rw-r--r--frontend/RWSDebug.icl18
-rw-r--r--frontend/ShowWrapped.dcl5
-rw-r--r--frontend/ShowWrapped.icl92
-rw-r--r--frontend/Wrap.dcl46
-rw-r--r--frontend/Wrap.icl712
8 files changed, 0 insertions, 1068 deletions
diff --git a/frontend/Debug.dcl b/frontend/Debug.dcl
deleted file mode 100644
index 2e0af9f..0000000
--- a/frontend/Debug.dcl
+++ /dev/null
@@ -1,17 +0,0 @@
-definition module Debug
-
-:: DebugShowFunction a :== !a -> [{#Char}]
-
-debugBefore :: !.a !(DebugShowFunction .a) .b -> .b
-debugAfter :: !.a !(DebugShowFunction .a) !.b -> .b
-debugValue :: !(DebugShowFunction .a) !.a -> .a
-
-debugShow :: DebugShowFunction .a
-debugShowWithOptions :: [DebugShowOption] -> DebugShowFunction .a
-
-:: DebugShowOption
- = DebugMaxDepth !Int // default MaxInt
- | DebugMaxBreadth !Int // default MaxInt
- | DebugMaxChars !Int // default MaxInt
- | DebugTerminator !{#Char} // default "\n"
-
diff --git a/frontend/Debug.icl b/frontend/Debug.icl
deleted file mode 100644
index 1b1ae0a..0000000
--- a/frontend/Debug.icl
+++ /dev/null
@@ -1,173 +0,0 @@
-implementation module Debug
-
-import StdArray, StdEnum
-from StdFile import <<<, ferror, stderr
-from StdMisc import abort
-from StdTuple import fst
-from StdList import ++
-from StdBool import &&
-from StdString import %
-
-import Wrap, ShowWrapped
-
-print :: ![{#Char}] .b -> .b
-print debugStrings value
- | fst (ferror (stderr <<< debugStrings))
- = abort "Debug, print: couldn't write to stderr"
- // otherwise
- = value
-
-debugBefore :: !.a !(DebugShowFunction .a) .b -> .b
-debugBefore debugValue show value
- = print (show debugValue) value
-
-debugAfter :: !.a !(DebugShowFunction .a) !.b -> .b
-debugAfter debugValue show value
- = print (show debugValue) value
-
-debugValue :: !(DebugShowFunction .a) !.a -> .a
-debugValue show value
- = print (show copy1) copy2
- where
- (copy1, copy2)
- = copyUniqueValue value
-
- copyUniqueValue :: !.a -> (!.a, !.a)
- copyUniqueValue value
- = code {
- .o 1 0
- push_a 0
- .d 2 0
- }
-
-:: DebugShowFunction a :== !a -> [{#Char}]
-
-debugShow :: DebugShowFunction .a
-debugShow
- = \debugValue -> showWrapped (wrapNode debugValue) ++ ["\n"]
-
-
-:: DebugOptionRecord
- = {maxDepth :: !Int, maxBreadth :: !Int, maxChars :: !Int, terminator :: !{#Char}}
-DebugDefaultOptions
- :== {maxDepth = MaxInt, maxBreadth = MaxInt, maxChars = MaxInt, terminator = "\n"}
-
-MaxInt
- :== (1<<31)-1
-
-:: DebugShowOption
- = DebugMaxDepth !Int // default MaxInt
- | DebugMaxBreadth !Int // default MaxInt
- | DebugMaxChars !Int // default MaxInt
- | DebugTerminator !{#Char} // default "\n"
-
-debugShowWithOptions :: [DebugShowOption] -> DebugShowFunction .a
-debugShowWithOptions debugOptions
- = \debug -> chop maxChars (showWrapped (pruneWrappedNode maxDepth maxBreadth (wrapNode debug))) ++ [terminator]
- where
- {maxDepth, maxBreadth, maxChars, terminator}
- = set debugOptions DebugDefaultOptions
- where
- set [] options
- = options
- set [DebugMaxDepth maxDepth:t] options
- = set t {options & maxDepth=maxDepth}
- set [DebugMaxBreadth maxBreadth:t] options
- = set t {options & maxBreadth=maxBreadth}
- set [DebugMaxChars maxChars:t] options
- = set t {options & maxChars=maxChars}
- set [DebugTerminator terminator:t] options
- = set t {options & terminator=terminator}
-
-:: Indicators
- = ...
- | .+.
-
-MaxCharsString
- :== ".."
-MaxBreadthString
- :== "..."
-MaxBreadthIndicator
- :== wrapNode ...
-MaxDepthIndicator
- :== wrapNode .+.
-
-pruneWrappedNode :: !Int !Int !WrappedNode -> !WrappedNode
-pruneWrappedNode maxDepth maxBreadth value
- = prune 0 value
- where
- prune :: !Int WrappedNode -> WrappedNode
- prune depth value
- | depth == maxDepth
- = MaxDepthIndicator
- prune depth (WrappedIntArray a)
- = pruneBasicArray depth a
- prune depth (WrappedBoolArray a)
- = pruneBasicArray depth a
- prune depth (WrappedRealArray a)
- = pruneBasicArray depth a
- prune depth (WrappedFileArray a)
- = pruneBasicArray depth a
- prune depth (WrappedString a)
- | size a > maxBreadth
- = WrappedString ((a % (0, maxBreadth-1)) +++ MaxBreadthString)
- prune depth (WrappedArray a)
- = WrappedArray (pruneArray depth a)
- prune depth (WrappedRecord descriptor args)
- = WrappedRecord descriptor (pruneArray depth args)
- prune depth (WrappedOther WrappedDescriptorCons args)
- | size args == 2
- = WrappedOther WrappedDescriptorCons
- {prune (depth+1) args.[0], prune depth args.[1]}
- prune depth (WrappedOther WrappedDescriptorTuple args)
- = WrappedOther WrappedDescriptorTuple (pruneArray depth args)
- prune depth (WrappedOther descriptor args)
- = WrappedOther descriptor (pruneArray depth args)
- prune _ a
- = a
-
- pruneArray :: !Int !{WrappedNode} -> {WrappedNode}
- pruneArray depth a
- | size a > maxBreadth
- = {{prune (depth+1) e \\ e <-: a & i <- [0 .. maxBreadth]}
- & [maxBreadth] = MaxBreadthIndicator}
- // otherwise
- = {prune (depth+1) e \\ e <-: a}
-
- pruneBasicArray :: !Int !(a b) -> WrappedNode | Array .a & ArrayElem b
- pruneBasicArray depth a
- | size a > maxBreadth
- = WrappedArray (pruneArray depth {wrapNode e \\ e <-: a & i <- [0 .. maxBreadth]})
- // otherwise
- = WrappedArray {wrapNode e \\ e <-: a}
-
-chop :: !Int ![{#Char}] -> [{#Char}]
-chop _ []
- = []
-chop maxSize list=:[string:strings]
- | maxSize < stringSize + sizeMaxCharsString
- | fits maxSize list
- = list
- | stringSize > sizeMaxCharsString
- = [string % (0, maxSize-sizeMaxCharsString-1), MaxCharsString]
- // otherwise
- = [MaxCharsString]
- // otherwise
- = [string : chop (maxSize - stringSize) strings]
- where
- fits _ []
- = True
- fits maxSize [h : t]
- = maxSize >= size h && fits (maxSize - size h) t
-
- stringSize
- = size string
- sizeMaxCharsString
- = size MaxCharsString
-
-instance <<< [a] | <<< a where
- (<<<) :: *File [a] -> *File | <<< a
- (<<<) file []
- = file
- (<<<) file [h:t]
- = file <<< h <<< t
diff --git a/frontend/RWSDebug.dcl b/frontend/RWSDebug.dcl
deleted file mode 100644
index b59baf6..0000000
--- a/frontend/RWSDebug.dcl
+++ /dev/null
@@ -1,5 +0,0 @@
-definition module RWSDebug
-
-(->>) :: !.a !.b -> .a
-(<<-) :: .a !.b -> .a
-<<->> :: !.a -> .a \ No newline at end of file
diff --git a/frontend/RWSDebug.icl b/frontend/RWSDebug.icl
deleted file mode 100644
index 98c5ed9..0000000
--- a/frontend/RWSDebug.icl
+++ /dev/null
@@ -1,18 +0,0 @@
-implementation module RWSDebug
-
-import Debug
-
-show x
- = debugShowWithOptions [DebugMaxChars 80, DebugMaxDepth 5] x
-
-(->>) :: !.a !.b -> .a
-(->>) value debugValue
- = debugAfter debugValue show value
-
-(<<-) :: .a !.b -> .a
-(<<-) value debugValue
- = debugBefore debugValue show value
-
-<<->> :: !.a -> .a
-<<->> value
- = debugValue show value
diff --git a/frontend/ShowWrapped.dcl b/frontend/ShowWrapped.dcl
deleted file mode 100644
index 1801f91..0000000
--- a/frontend/ShowWrapped.dcl
+++ /dev/null
@@ -1,5 +0,0 @@
-definition module ShowWrapped
-
-from Wrap import WrappedNode
-
-showWrapped :: WrappedNode -> [{#Char}] \ No newline at end of file
diff --git a/frontend/ShowWrapped.icl b/frontend/ShowWrapped.icl
deleted file mode 100644
index 7254b40..0000000
--- a/frontend/ShowWrapped.icl
+++ /dev/null
@@ -1,92 +0,0 @@
-implementation module ShowWrapped
-
-import StdEnv
-import Wrap
-
-ShowParentheses
- :== True
-Don`tShowParentheses
- :== False
-
-showWrapped :: WrappedNode -> [{#Char}]
-showWrapped node
- = show Don`tShowParentheses node
-
-show :: Bool WrappedNode -> [{#Char}]
-show _ (WrappedInt i)
- = [toString i]
-show _ (WrappedChar c)
- = ["\'" +++ toString c +++ "\'"]
-show _ (WrappedBool b)
- = [toString b]
-show _ (WrappedReal r)
- = [toString r]
-show _ (WrappedFile _)
- = ["File"]
-show _ (WrappedString s)
- = ["\"" +++ s +++ "\""]
-show _ (WrappedIntArray a)
- = showBasicArray a
-show _ (WrappedBoolArray a)
- = showBasicArray a
-show _ (WrappedRealArray a)
- = showBasicArray a
-show _ (WrappedFileArray a)
- = showBasicArray a
-show _ (WrappedArray a)
- = ["{" : flatten (separate [", "] [show Don`tShowParentheses el \\ el <-: a])] ++ ["}"]
-show _ (WrappedRecord descriptor args)
- = ["{" : flatten (separate [" "] [[showDescriptor descriptor] : [show ShowParentheses arg \\ arg <-: args]])] ++ ["}"]
-show _ (WrappedOther WrappedDescriptorCons args)
- | size args == 2
- = ["[" : flatten [show Don`tShowParentheses args.[0] : showTail args.[1]]] ++ ["]"]
- where
- showTail :: WrappedNode -> [[{#Char}]]
- showTail (WrappedOther WrappedDescriptorCons args)
- | size args == 2
- = [[", "], show Don`tShowParentheses args.[0] : showTail args.[1]]
- showTail (WrappedOther WrappedDescriptorNil args)
- | size args == 0
- = []
- showTail node // abnormal list
- = [[" : " : show Don`tShowParentheses node]]
-show _ (WrappedOther WrappedDescriptorTuple args)
- = ["(" : flatten (separate [", "] [show Don`tShowParentheses arg \\ arg <-: args])] ++ [")"]
-show parentheses (WrappedOther descriptor args)
- | parentheses && size args > 0
- = ["(" : application] ++ [")"]
- // otherwise
- = application
- where
- application
- = flatten (separate [" "] [[showDescriptor descriptor] : [show ShowParentheses arg \\ arg <-: args]])
-
-showDescriptor :: WrappedDescriptor -> {#Char}
-showDescriptor (WrappedDescriptorOther id)
- = toString id
-showDescriptor WrappedDescriptorNil
- = "[]"
-showDescriptor WrappedDescriptorCons
- = "[:]"
-showDescriptor WrappedDescriptorTuple
- = "(..)"
-
-showBasicArray :: {#a} -> [{#Char}] | toString, ArrayElem a
-showBasicArray a
- = ["{" : separate ", " [toString el \\ el <-: a]] ++ ["}"]
-
-showWrappedArray :: {WrappedNode} -> [{#Char}]
-showWrappedArray a
- = ["{" : flatten (separate [", "] [show Don`tShowParentheses el \\ el <-: a])] ++ ["}"]
-
-separate :: a [a] -> [a]
-separate separator [a : t=:[b : _]]
- = [a, separator : separate separator t]
-separate _ l
- = l
-
-instance toString File
-where
- toString :: File -> {#Char}
- toString _
- = "File"
diff --git a/frontend/Wrap.dcl b/frontend/Wrap.dcl
deleted file mode 100644
index 8cb683a..0000000
--- a/frontend/Wrap.dcl
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- Wrap Clean nodes (for debugging purposes).
-
- Version 1.0.1
- Ronny Wichers Schreur
- ronny@cs.kun.nl
-*/
-definition module Wrap
-
-from StdOverloaded import toString
-
-:: WrappedDescriptorId
-
-instance toString WrappedDescriptorId
-
-:: WrappedDescriptor
- = WrappedDescriptorCons
- | WrappedDescriptorNil
- | WrappedDescriptorTuple
- | WrappedDescriptorOther !WrappedDescriptorId
-
-:: WrappedNode
- // basic types
- = WrappedInt !Int
- | WrappedChar !Char
- | WrappedBool !Bool
- | WrappedReal !Real
- | WrappedFile !File
-
- // unboxed arrays of basic types
- | WrappedString !{#Char}
- | WrappedIntArray !{#Int}
- | WrappedBoolArray !{#Bool}
- | WrappedRealArray !{#Real}
- | WrappedFileArray !{#File}
-
- // other arrays
- | WrappedArray !{WrappedNode}
-
- // records
- | WrappedRecord !WrappedDescriptor !{WrappedNode}
-
- // other nodes
- | WrappedOther !WrappedDescriptor !{WrappedNode}
-
-wrapNode :: !.a -> WrappedNode \ No newline at end of file
diff --git a/frontend/Wrap.icl b/frontend/Wrap.icl
deleted file mode 100644
index 64f0d08..0000000
--- a/frontend/Wrap.icl
+++ /dev/null
@@ -1,712 +0,0 @@
-/*
- Wrap Clean nodes (for debugging purposes).
-
- Version 1.0.1
- Ronny Wichers Schreur
- ronny@cs.kun.nl
-*/
-implementation module Wrap
-
-import StdOverloaded
-
-:: WrappedDescriptorId = {descriptorId :: !Int}
-
-:: WrappedDescriptor
- = WrappedDescriptorCons
- | WrappedDescriptorNil
- | WrappedDescriptorTuple
- | WrappedDescriptorOther !WrappedDescriptorId
-
-:: WrappedNode
- = WrappedInt !Int
- | WrappedChar !Char
- | WrappedBool !Bool
- | WrappedReal !Real
- | WrappedFile !File
- | WrappedString !{#Char}
- | WrappedIntArray !{#Int}
- | WrappedBoolArray !{#Bool}
- | WrappedRealArray !{#Real}
- | WrappedFileArray !{#File}
- | WrappedArray !{WrappedNode}
- | WrappedRecord !WrappedDescriptor !{WrappedNode}
- | WrappedOther !WrappedDescriptor !{WrappedNode}
-
-instance toString WrappedDescriptorId where
- toString :: WrappedDescriptorId -> {#Char}
- toString {descriptorId}
- = descriptorIDtoString descriptorId
- where
- descriptorIDtoString :: !Int -> {#Char}
- descriptorIDtoString id
- = code
- {
- .d 0 1 i
- jsr DtoAC
- .o 1 0
- }
-
-wrapNode :: !.a -> WrappedNode
-wrapNode node
- = code
- {
- | A: <node> <result>
- | B:
- eq_desc BOOL 0 0
- jmp_false not_a_bool
- pushB_a 0
- pop_a 1
- fill_r e_Wrap_kWrappedBool 0 1 0 0 0
- pop_b 1
- .d 1 0
- rtn
- :not_a_bool
-
- eq_desc INT 0 0
- jmp_false not_an_int
-
- pushI_a 0
- pop_a 1
- fill_r e_Wrap_kWrappedInt 0 1 0 0 0
- pop_b 1
- .d 1 0
- rtn
- :not_an_int
-
- eq_desc CHAR 0 0
- jmp_false not_a_char
-
- pushC_a 0
- pop_a 1
- fill_r e_Wrap_kWrappedChar 0 1 0 0 0
- pop_b 1
- .d 1 0
- rtn
- :not_a_char
-
- eq_desc REAL 0 0
- jmp_false not_a_real
-
- pushR_a 0
- pop_a 1
- fill_r e_Wrap_kWrappedReal 0 2 0 0 0
- pop_b 2
- .d 1 0
- rtn
- :not_a_real
-
- eq_desc FILE 0 0
- jmp_false not_a_file
-
- pushF_a 0
- pop_a 1
- fill_r e_Wrap_kWrappedFile 0 2 0 0 0
- pop_b 2
- .d 1 0
- rtn
- :not_a_file
-
- eq_desc ARRAY 1 0
- jmp_true wrap_array
-
- eq_desc _ARRAY_ 0 0
- jmp_true wrap__array
-
- eq_desc _STRING_ 0 0
- jmp_true wrap__string
-
- is_record 0
- .d 2 0
- jmp_true wrap_record
-
- get_node_arity 0
- | B: <n>
- eqI_b 0 0
- jmp_true wrap_no_args
-
- :wrap_args
- push_a 0
- push_b 0
- push_b 0
- repl_args_b
- | A: <arg_1 .. arg_n> <node> <result>
- push_b 0
- create_array_ _ 1 0
- | A: <_{args}> <arg_1 .. arg_n> <node> <result>
- pushI 0
-
- :wrap_args_loop
- | A: <_{args}> <arg_(i+1) .. arg_n> <node> <result>
- | B: <i> <n>
- | wrap arg
- push_a 1
- build e_Wrap_swrapNode 1 e_Wrap_nwrapNode
- update_a 0 2
- pop_a 1
-
- | update i-th element of _args array with wrapped arg
- push_b 0
- update _ 1 0
-
- | increment index
- incI
-
- push_b 0
- push_b 2
- eqI
- jmp_false wrap_args_loop
-
- pop_b 2
- | A: <_{args}> <node> <result>
- | B:
- .d 3 0
- jmp wrap_descriptor
-
- :wrap_no_args
- | A: <node> <result>
- | B: <0>
- create_array_ _ 1 0
-
- .o 3 0
- :wrap_descriptor
- | A: <_{args}> <node> <result>
- push_a 1
- update_a 1 2
- update_a 0 1
- pop_a 1
- | A: <node> <_{args}> <result>
- eq_nulldesc _Tuple 0
- jmp_false not_a_tuple
- build e_Wrap_dWrappedDescriptorTuple 0 _hnf
- .d 4 0
- jmp wrap_other
- :not_a_tuple
-
- eq_nulldesc _Cons 0
- jmp_false not_a_cons
- build e_Wrap_dWrappedDescriptorCons 0 _hnf
- jmp wrap_other
- :not_a_cons
-
- eq_desc _Nil 0 0
- jmp_false not_a_nil
- build e_Wrap_dWrappedDescriptorNil 0 _hnf
- jmp wrap_other
- :not_a_nil
-
- | A: <node> <_{args}> <result>
- pushD_a 0
- build_r e_Wrap_rWrappedDescriptorId 0 1 0 0
- pop_b 1
-
- build_r e_Wrap_kWrappedDescriptorOther 1 0 0 0
- update_a 0 1
- pop_a 1
- .o 4 0
- :wrap_other
- | A: <descriptor> <node> <_{args}> <result>
- update_a 0 1
- pop_a 1
- | A: <descriptor> <_{args}> <result>
- fill_r e_Wrap_kWrappedOther 2 0 2 0 0
- pop_a 2
- | A: <result>
- .d 1 0
- rtn
-
- .o 2 0
- | constructors with strict arguments are also represented by records
- :wrap_record
- pushI 0
- pushD_a 0
- | A: <node> <result>
- | B: <desc> <return>
- push_t_r_args
-
- :wrap_record_fields
- | A: <afield_1 .. afield_m> <result>
- | B: <l> <bfield_1 .. bfield_n> <desc> <return>
- | (l: points to record layout,
- | desc: record descriptor
- | return: return selector)
-
- | determine if it's a record or a constructor with strict arguments
- push_b 0
- push_r_arg_t
- eqC_b 'd' 0
- jmp_false is_record
-
- pop_b 1
- | increment <l> if it's not a record
- incI
- pushB FALSE
- jmp count_fields
-
- :is_record
- pop_b 1
- pushB TRUE
-
- :count_fields
- push_b 1
-
- :count_fields_loop
- | A: <afield_1 .. afield_m> <result>
- | B: <p> <is_record> <l> <bfield_1 .. bfield_n> <desc> <return>
- | (p=l+offset)
- push_b 0
- push_r_arg_t
- eqI_b 0 0
- jmp_true end_count_record_fields
- pop_b 1
-
- | increment <p>
- incI
-
- jmp count_fields_loop
-
- :end_count_record_fields
- pop_b 1
- push_b 0
- update_b 3 1
- subI
- | A: <afield_1 .. afield_m> <result>
- | B: <n+m> <is_record> <l> <bfield_1 .. bfield_n> <desc> <return>
- create_array_ _ 1 0
- pushI 0
- push_b 2
- update_b 2 3
- update_b 1 2
- update_b 0 1
- pop_b 1
-
- :wrap_fields_loop
- | A: <_{fields}> <afield_ .. afield_m> <result>
- | B: <p> <i> <is_record> <bfield_ .. bfield_n> <desc> <return>
- push_b 0
- push_r_arg_t
- eqI_b 0 0
- jmp_true end_wrap_record_fields
- eqC_b 'i' 0
- jmp_true wrap_int_field
- eqC_b 'c' 0
- jmp_true wrap_char_field
- eqC_b 'r' 0
- jmp_true wrap_real_field
- eqC_b 'b' 0
- jmp_true wrap_bool_field
- eqC_b 'f' 0
- jmp_true wrap_file_field
- eqC_b 'a' 0
- jmp_true wrap_graph_field
- print_sc "Wrap.wrapNode: unimplemented record field type\n"
- halt
-
- :wrap_int_field
- pop_b 1
-
- | create and fill int node
- create
- fillI_b 3 0
- push_a 1
- update_a 1 2
- update_a 0 1
- pop_a 1
-
- update_b 2 3
- update_b 1 2
- update_b 0 1
- pop_b 1
-
- jmp wrap_field
-
- :wrap_char_field
- pop_b 1
-
- | create and fill char node
- create
- fillC_b 3 0
- push_a 1
- update_a 1 2
- update_a 0 1
- pop_a 1
-
- update_b 2 3
- update_b 1 2
- update_b 0 1
- pop_b 1
-
- jmp wrap_field
-
- :wrap_bool_field
- pop_b 1
-
- | create and fill bool node
- create
- fillB_b 3 0
- push_a 1
- update_a 1 2
- update_a 0 1
- pop_a 1
-
- update_b 2 3
- update_b 1 2
- update_b 0 1
- pop_b 1
-
- jmp wrap_field
-
-
- :wrap_real_field
- pop_b 1
-
- | create and fill real node
- create
- fillR_b 3 0
- push_a 1
- update_a 1 2
- update_a 0 1
- pop_a 1
-
- update_b 2 4
- update_b 1 3
- update_b 0 2
- pop_b 2
-
- jmp wrap_field
-
- :wrap_file_field
- pop_b 1
-
- | create and fill file node
- create
- fillF_b 3 0
- push_a 1
- update_a 1 2
- update_a 0 1
- pop_a 1
-
- update_b 2 4
- update_b 1 3
- update_b 0 2
- pop_b 2
-
- jmp wrap_field
-
- :wrap_graph_field
- pop_b 1
- jmp wrap_field
-
- :wrap_field
- | A: <_{fields}> <field> <afield_ .. afield_m>
- | wrap field
- push_a 1
- build e_Wrap_swrapNode 1 e_Wrap_nwrapNode
- update_a 0 2
- pop_a 1
-
- | update i-th element of _fields array with wrapped field
- push_b 1
- update _ 1 0
- | A: <_{fields}> <afield_ .. afield_m> <result>
- | B: <p> <i> <is_record> <bfield_ .. bfield_n> <desc> <return>
-
- | increment index
- push_b 1
- incI
- update_b 0 2
- pop_b 1
-
- | increment pointer in layout string
- incI
-
- jmp wrap_fields_loop
-
- :end_wrap_record_fields
- | A: <_{fields}> <result>
- | B: <i=0> <p> <i> <is_record> <desc> <return>
- pop_b 3
- | A: <_{fields}> <result>
- | B: <is_record> <desc> <return>
-
- push_b 1
- update_b 1 2
- update_b 0 1
- pop_b 1
- | B: <desc> <is_record> <return>
-
- | create WrappedDescriptorOther node
- build_r e_Wrap_rWrappedDescriptorId 0 1 0 0
- pop_b 1
- build_r e_Wrap_kWrappedDescriptorOther 1 0 0 0
- update_a 0 1
- pop_a 1
- | A: <descriptor> <{fields}> <result>
- | B: <is_record> <return>
-
- | pop is_record +++ use this
- jmp_false fill_constructor_result
-
- | fill result node for record
- fill_r e_Wrap_kWrappedRecord 2 0 2 0 0
- pop_a 2
- jmp wrapped_record_return_to_caller
-
- :fill_constructor_result
- | fill result node for constructor
-
- fill_r e_Wrap_kWrappedOther 2 0 2 0 0
- pop_a 2
-
- :wrapped_record_return_to_caller
- | A: <result>
- | B: <return>
- | return to caller (determined by the return selector)
- eqI_b 0 0
- jmp_true wrap_record_return_node
- eqI_b 1 0
- jmp_true wrap_record_array_return
- print_sc "Wrap.wrapNode: (record fields) unknown return selector\n"
- halt
-
- :wrap_record_return_node
- | A: <result>
- | B: <return>
- pop_b 1
- .d 1 0
- | A: <result>
- | B:
- rtn
-
- :wrap_array
- | A: <array> <result>
- | replace ARRAY by _ARRAY_
- pushA_a 0
- update_a 0 1
- pop_a 1
-
- :wrap__array
- | A: <_array> <result>
- eq_desc _STRING_ 0 0
- jmp_false not_a_string
-
- :wrap__string
- | fill result node
- fill_r e_Wrap_kWrappedString 1 0 1 0 0
- pop_a 1
- .d 1 0
- | A: <result>
- rtn
- :not_a_string
-
- | push array element descriptor
- push_r_args_b 0 0 2 2 1
- | A: <_array> <result>
- | B: <desc>
- push_b 0
- eq_desc_b BOOL 0
- jmp_true wrap_bool_array
- push_b 0
- eq_desc_b INT 0
- jmp_true wrap_int_array
- push_b 0
- eq_desc_b REAL 0
- jmp_true wrap_real_array
- push_b 0
- eq_desc_b FILE 0
- jmp_true wrap_file_array
-
- pushI 0
- push_a 0
- push_arraysize _ 0 1
- | A: <_array> <result>
- | B: <n> <i> <desc>
- push_b 2
- update_b 2 3
- update_b 1 2
- update_b 0 1
- pop_b 1
- | B: <desc> <n> <i>
- pushI 0
- eqI
- | B: <n> <i>
- jmp_false wrap_record_array
-
- push_b 0
- create_array_ _ 1 0
- | A: <_wrapped_array> <_array> <result>
- | B: <n> <i>
- .d 3 2 i i
- jmp wrap_array_test
-
- .o 3 2 i i
- :wrap_array_elements
- | A: <_wrapped_array> <_array> <result>
- | B: <n> <i>
-
- | wrap element
- push_b 1
- push_a 1
- select _ 1 0
- build e_Wrap_swrapNode 1 e_Wrap_nwrapNode
- | A: <element> <_wrapped_array> <_array> <result>
- | B: <n> <i>
- | update i-th element of _wrapped_array with wrapped element
- push_a 1
- push_b 1
- update _ 1 0
- update_a 0 1
- pop_a 1
- | B: <n> <i>
- | increment index
- push_b 1
- incI
- update_b 0 2
-
- | decrement n
- pop_b 1
- decI
-
- .o 3 2 i i
- :wrap_array_test
- | B: <n> <i>
- eqI_b 0 0
- .d 3 2 i i
- jmp_false wrap_array_elements
- | A: <_wrapped_array> <_array> <result>
- | B: <n> <i>
- pop_b 2
- update_a 0 1
- pop_a 1
- | A: <_wrapped_array> <result>
- | B:
- | fill result node
- fill_r e_Wrap_kWrappedArray 1 0 1 0 0
- pop_a 1
- .d 1 0
- | A: <result>
- | B:
- rtn
-
-
- :wrap_bool_array
- | A: <_array> <result>
- | B: <desc>
- pop_b 1
-
- | fill result node
- fill_r e_Wrap_kWrappedBoolArray 1 0 1 0 0
- pop_a 1
- .d 1 0
- | A: <result>
- | B:
- rtn
-
- :wrap_int_array
- | A: <_array> <result>
- | B: <desc>
- pop_b 1
-
- | fill result node
- fill_r e_Wrap_kWrappedIntArray 1 0 1 0 0
- pop_a 1
- .d 1 0
- | A: <result>
- | B:
- rtn
-
- :wrap_real_array
- | A: <_array> <result>
- | B: <desc>
- pop_b 1
-
- | fill result node
- fill_r e_Wrap_kWrappedRealArray 1 0 1 0 0
- pop_a 1
- .d 1 0
- | A: <result>
- | B:
- rtn
-
- :wrap_file_array
- | A: <_array> <result>
- | B: <desc>
- pop_b 1
-
- | fill result node
- fill_r e_Wrap_kWrappedFileArray 1 0 1 0 0
- pop_a 1
- .d 1 0
- | A: <result>
- | B:
- rtn
-
- :wrap_record_array
- | A: <_array> <result>
- | B: <n> <i>
- push_b 0
- create_array_ _ 1 0
- | A: <_wrapped_array> <_array> <result>
- | B: <n> <i>
-
- jmp wrap_record_array_test
-
- :wrap_record_array_loop
- | B: <n> <i>
- pushI 1
- | push record element descriptor
- push_r_args_b 1 0 2 2 1
- | B: <desc> <return> <n> <i>
-
- | create result node for wrap_record_fields
- create
-
- | push fields from i-th array element
- push_b 3
- push_a 2
- push_a_r_args
- | A: <afield_1 .. afield_m> <elresult> <_wrapped_array> <_array> <result>
- | B: <l> <bfieldb_1 .. bfield_n> <desc> <return> <n> <i>
- | wrap record element
- jmp wrap_record_fields
- :wrap_record_array_return
- | A: <element> <_wrapped_array> <_array> <result>
- | B: <return> <n> <i>
- pop_b 1
- | A: <element> <_wrapped_array> <_array> <result>
- | B: <n> <i>
- | update i-th of _wrapped_array with wrapped record element
- push_a 1
- push_b 1
- update _ 1 0
- update_a 0 1
- pop_a 1
- | A: <_wrapped_array> <_array> <result>
- | B: <n> <i>
- | increment index
- push_b 1
- incI
- update_b 0 2
- pop_b 1
-
- | decrement n
- decI
-
- :wrap_record_array_test
- eqI_b 0 0
- jmp_false wrap_record_array_loop
- | A: <_wrapped_array> <_array> <result>
- | B: <n> <i>
- pop_b 2
- | B:
-
- update_a 0 1
- pop_a 1
- | A: <_wrapped_array> <result>
- | fill result node
- fill_r e_Wrap_kWrappedArray 1 0 1 0 0
- pop_a 1
- .d 1 0
- | A: <result>
- | B:
- rtn
- }