1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
|
set thismodule [set [my varname m]]
set f [$m local "tcl.strreplace" STRING<-STRING,INT,INT,STRING]
params str:stringPtr fromInt toInt substr:substringPtr
build {
nonnull $str $substr
set strreplace [$thismodule function.existing strreplace]
set ft [llvmtcl TypeOf $strreplace]
set pt [llvmtcl GetParamTypes [llvmtcl GetElementType $ft]]
my ret [my cast(ptr) [my Call strreplace \
[my cast(ptr) $str void] \
[my getInt32 $fromInt] \
[my getInt32 $toInt] \
[my cast(ptr) $substr void]\
] Tcl_Obj]
# set from [my max $0 [my getInt32 $fromInt] "from"]
# set to [my getInt32 $toInt "to"]
# set length [my getInt32 [my strlen(STRING) $str] "length"]
# my condBr [my or [my gt $from $to] [my gt $from $length]] \
# $returnString $checkIfTrivial
# label returnString "return.string"
# my br $replaceDone
# label returnSubstring "return.substring"
# my br $replaceDone
# label checkIfTrivial "check.trivial"
# set to [my min $length $to "to"]
# my condBr [my and [my eq $from $0] [my eq $to $length]] \
# $returnSubstring $checkRemoveTail
# label checkRemoveTail "check.remove.tail"
# set length3 [my getInt32 [my strlen(STRING) $substr] "length3"]
# set refCount [my refCount $str "refCount"]
# my condBr [my and [my eq $length3 $0] [my eq $to $length]] \
# $testUnshared $checkIfInPlace
# label testUnshared "check.unshared"
# my condBr [my le $refCount $1] $trimTail $checkIfInPlace
# label trimTail "replace.remove.tail"
# $api Tcl_SetObjLength $str $from
# my br $returnString
# label checkIfInPlace "check.in.place"
# my condBr [my eq [my sub $length3 $1] [my sub $to $from]] \
# $inPlace $complex
# label inPlace "in.place"
# my condBr [my le $refCount $1] $inPlaceTypecheck $inPlaceAlloc
# label inPlaceAlloc "in.place.dup"
# set allocated [$api Tcl_DuplicateObj $str]
# my br $inPlaceTypecheck
# label inPlaceTypecheck "in.place.typecheck"
# set strIP [my phi [list $str $allocated] \
# [list $inPlace $inPlaceAlloc]]
# my condBr [my and \
# [my isByteArray $strIP] \
# [my isByteArray $substr]] \
# $inPlaceBA $inPlaceUni
# label inPlaceBA "in.place.bytes"
# set bytes1 [$api Tcl_GetByteArray $strIP]
# set bytes2 [$api Tcl_GetByteArray $substr]
# my memcpy [my getelementptr $bytes1 [list $from]] $bytes2 $length3
# $api TclInvalidateStringRep $strIP
# my br $replaceDone
# label inPlaceUni "in.place.unicode"
# set bytes1 [$api Tcl_GetUnicode $strIP]
# set bytes2 [$api Tcl_GetUnicode $substr]
# my memcpy [my getelementptr $bytes1 [list $from]] $bytes2 \
# [my mult $length3 $sizeof(Tcl_UniChar)]
# my store $0 [my getelementptr [my cast(ptr) \
# [my gep $strIP 0 Tcl_Obj.internalRep] int] [list $1]]
# $api TclInvalidateStringRep $strIP
# my br $replaceDone
# label complex "replace"
# lassign [my GetUnicode $str str] length ustring1
# my condBr [my eq $length3 $0] $removeSubstr $replaceSubstr
# label removeSubstr "replace.remove"
# my condBr [my eq $from $0] $removeFront $removeBody
# label removeFront "replace.remove.front"
# set newstrFront [$api Tcl_NewUnicodeObj \
# [my getelementptr $ustring1 [my add $to $1]] \
# [list [my sub $length $to]]]
# my br $replaceDone
# label removeBody "replace.remove.body"
# set newstr [$api Tcl_NewUnicodeObj $ustring1 $from]
# my condBr [my lt $to $length] $removeBodyMid $replaceDone
# label removeBodyMid "replace.remove.body.mid"
# $api Tcl_AppendUnicodeToObj $newstr \
# [my getelementptr $ustring1 [list [my add $to $1]]] \
# [my sub $length $to]
# my br $replaceDone
# label replaceSubstr "replace.substr"
# my condBr [my gt $from $0] $replaceMid $replaceFrontTest
# label replaceFrontTest "replace.substr.front.test"
# my condBr [my shared $substr] \
# $replaceFrontShared $replaceFrontUnshared
# label replaceMid "replace.substr.mid"
# set newstrMid [$api Tcl_NewUnicodeObj $ustring1 $from]
# $api Tcl_AppendObjToObj $newstrMid $substr
# my condBr [my lt $to $length] $replaceTail $replaceDone
# label replaceFrontShared "replace.substr.front.shared"
# set newstrShared [$api Tcl_DuplicateObj $substr]
# my condBr [my lt $to $length] $replaceTail $replaceDone
# label replaceFrontUnshared "replace.subst.front.unshared"
# my condBr [my lt $to $length] $replaceTail $replaceDone
# label replaceTail "replace.subst.tail"
# set sources [list $replaceMid $replaceFrontShared $replaceFrontUnshared]
# set newstrTail [my phi [list $newstrMid $newstrShared $substr] \
# $sources "tail"]
# $api Tcl_AppendUnicodeToObj $newstrTail \
# [my getelementptr $ustring1 [list [my add $to $1]]] \
# [my sub [my sub $length $to] $1]
# my br $replaceDone
# label replaceDone "done"
# set sources [list $returnString $returnSubstring $inPlaceBA \
# $inPlaceUni $removeFront $removeBody $removeBodyMid \
# $replaceMid $replaceFrontShared $replaceFrontUnshared \
# $replaceTail]
# set values [list $str $substr $strIP $strIP $newstrFront $newstr \
# $newstr $newstrMid $newstrShared $substr $newstrTail]
# set newstr [my phi $values $sources]
# my addReference(STRING) $newstr
# my ret $newstr
}
##### Function tcl.strreplace.idx #####
#
# Type signature: objPtr:STRING * fromIdx:STRING * toIdx:STRING *
# * substringPtr:STRING * ecvar:int* -> STRING?
#
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
|
set thismodule [set [my varname m]]
set f [$m local "tcl.strreplace" STRING<-STRING,INT,INT,STRING]
params str:stringPtr fromInt toInt substr:substringPtr
build {
nonnull $str $substr
set strreplace [$thismodule function.existing strreplace]
my ret [my cast(ptr) [my Call strreplace \
[my cast(ptr) $str void] \
[my getInt32 $fromInt] \
[my getInt32 $toInt] \
[my cast(ptr) $substr void]\
] Tcl_Obj]
}
##### Function tcl.strreplace.idx #####
#
# Type signature: objPtr:STRING * fromIdx:STRING * toIdx:STRING *
# * substringPtr:STRING * ecvar:int* -> STRING?
#
|