Check-in [60af66d773]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Working on making a proper [dict update].
Timelines: family | ancestors | descendants | both | dkf-dict-update
Files: files | file ages | folders
SHA3-256:60af66d773ee1df6e6109ee01161c7e5a0053582acdb3f8120d06f9c8aabb7b0
User & Date: dkf 2017-12-17 17:44:57
Context
2017-12-18
20:40
Following the rabbit through the type logic. check-in: 0b30d236de user: dkf tags: dkf-dict-update
2017-12-17
17:44
Working on making a proper [dict update]. check-in: 60af66d773 user: dkf tags: dkf-dict-update
07:10
Implementation of local arrays that can be moved in and out of the callframe cheaply, instead of previous hack with dictionaries. check-in: e0c9c0d70f user: dkf tags: trunk
Changes

Changes to codegen/stdlib.tcl.

2995
2996
2997
2998
2999
3000
3001






















































3002
3003
3004
3005
3006
3007
3008
....
3107
3108
3109
3110
3111
3112
3113























3114
3115
3116
3117
3118
3119
3120
		[my constString TCL] [my constString LOOKUP] \
		[my constString DICT] $keyval {}
	    my br $notOK
	label notOK:
	    my store $1 $ecvar
	    my ret [my fail STRING]
	}























































	##### Function tcl.dict.set1 #####
	#
	# Type signature: dict:STRING * key:STRING * value:STRING
	#			* ecvar:int32* -> STRING?
	#
	# Sets a key in a dictionary to map to a value.  Can fail if the
................................................................................
	label OK:
	    my ret [my ok $dict]
	label notOK:
	    my Call obj.cleanup $dd
	    my store $1 $ecvar
	    my ret [my fail STRING]
	}
























	##### Function tcl.dict.addIterReference #####
	#
	# Type signature: iter:DICTITER -> void
	#
	# Increments the reference count inside a dictionary iteration state.








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
....
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
		[my constString TCL] [my constString LOOKUP] \
		[my constString DICT] $keyval {}
	    my br $notOK
	label notOK:
	    my store $1 $ecvar
	    my ret [my fail STRING]
	}

	##### Function tcl.dict.get.empty #####
	#
	# Type signature: dict:STRING * pathlen:int * pathobjs:STRING*
	#			* ecvar:int32* -> STRING!?
	#
	# Gets a value by key from a dictionary. Can only fail if the "dict"
	# is not a valid dictionary; an absent key in the terminal dictionary
	# is reported as an NEXIST result.

	set f [$m local "tcl.dict.get.empty" STRING!?<-STRING,int,STRING*,int*]
	params dict keyc keyv ecvar
	build {
	    noalias $dict $keyv $ecvar
	    nonnull $dict $keyv $ecvar
	    set interp [$api tclInterp]
	    my condBr [my eq $keyc $0] $verify $get
	label verify:
	    set dummy [my alloc int "dummy"]
	    set code [$api Tcl_DictObjSize $interp $dict $dummy]
	    my condBr [my eq $code $0] $return $notOK
	label get:
	    set n [my sub $keyc $1]
	    set dict2 [$api TclTraceDictPath $interp $dict $n $keyv $0]
	    SetValueName $dict2 "dictObj"
	    my condBr [my nonnull $dict2] $lookup $notOK
	label lookup:
	    set resvar [my alloc STRING "valueVar"]
	    set key [my load [my getelementptr $keyv [list $n]] "key"]
	    set result [$api Tcl_DictObjGet $interp $dict2 $key $resvar]
	    my condBr [my eq $result $0] $OK $fail
	label OK:
	    set value [my load $resvar "value"]
	    my condBr [my nonnull $value] $return $empty
	label return:
	    set value [my phi [list $dict $value] [list $verify $OK] "value"]
	    my addReference(STRING) $value
	    my ret [my ok [my just $value]]
	label empty:
	    my ret [my ok [my nothing STRING]]
	label fail:
	    set keyval [$api Tcl_GetString $key]
	    $api Tcl_SetObjResult $interp \
		[$api Tcl_ObjPrintf [my constString \
			"key \"%s\" not known in dictionary"] \
		    $keyval]
	    $api Tcl_SetErrorCode $interp \
		[my constString TCL] [my constString LOOKUP] \
		[my constString DICT] $keyval {}
	    my br $notOK
	label notOK:
	    my store $1 $ecvar
	    my ret [my fail STRING!]
	}

	##### Function tcl.dict.set1 #####
	#
	# Type signature: dict:STRING * key:STRING * value:STRING
	#			* ecvar:int32* -> STRING?
	#
	# Sets a key in a dictionary to map to a value.  Can fail if the
................................................................................
	label OK:
	    my ret [my ok $dict]
	label notOK:
	    my Call obj.cleanup $dd
	    my store $1 $ecvar
	    my ret [my fail STRING]
	}

	##### Function tcl.dict.set.empty #####
	#
	# Type signature: dict:STRING * pathlen:int * pathobjs:STRING*
	#			* value:STRING! * ecvar:int32* -> STRING?
	#
	# Sets a key (or rather a key path) in a dictionary to map to a value,
	# or removes the mapping if the value is NEXIST. Can fail if the
	# "dict" is not a valid dictionary.

	set f [$m local "tcl.dict.set.empty" \
		   STRING?<-STRING,int,STRING*,STRING!,int*]
	params dict pathlen pathobjs value ecvar
	build {
	    noalias $pathobjs $ecvar
	    nonnull $dict $pathobjs $value $ecvar
	    my condBr [my exists $value] $reallySet $reallyUnset
	label reallySet "real.set"
	    set value [my unmaybe $value]
	    my ret [my Call tcl.dict.set $dict $pathlen $pathobjs $value $ecvar]
	label reallyUnset "real.unset"
	    my ret [my Call tcl.dict.unset $dict $pathlen $pathobjs $ecvar]
	}

	##### Function tcl.dict.addIterReference #####
	#
	# Type signature: iter:DICTITER -> void
	#
	# Increments the reference count inside a dictionary iteration state.