Check-in [c5f9a2da90]

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

Overview
Comment:Correct the type name for boolean strings. Add a better 'isNumericOrBoolean' check
Timelines: family | ancestors | descendants | both | kbk-domain-check | notworking
Files: files | file ages | folders
SHA3-256:c5f9a2da90f93ee076673acd73b5f1d205f745a3dfeeed997fba9e25da0e1dd7
User & Date: kbk 2018-03-26 00:42:54
Context
2018-03-26
02:10
Avoid type promotion on jumpTrue and jumpFalse. check-in: 5913b29fcd user: kbk tags: kbk-domain-check, notworking
00:42
Correct the type name for boolean strings. Add a better 'isNumericOrBoolean' check check-in: c5f9a2da90 user: kbk tags: kbk-domain-check, notworking
2018-03-22
05:43
Start debugging the support for type checking of Boolean operands check-in: c415818ee6 user: kbk tags: kbk-domain-check, notworking
Changes

Changes to codegen/build.tcl.

4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
....
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
    #
    #	Generate code to check if the given STRING contains something that
    #	can be parsed to get either a NUMERIC or a BOOLEAN (suitable, in
    #	other words, for a conditional. Quadcode implementation ('jumpFalse',
    #	'jumpTrue', 'land', 'lor', 'not')

    method instanceOf.NUMERIC_OR_BOOLEAN(STRING) {value {name ""}} {
	set isNum [my call ${tcl.isNumeric} [list $value [Const false bool]] \
		       isNumeric]
	set isBool [my call ${tcl.booleanTest} [list $value]]
	return [my or $isNum $isBool $name]
    }
    method instanceOf.IMPURE_NUMERIC_OR_BOOLEAN(STRING) {value {name ""}} {
	set isNum [my call ${tcl.isNumeric} [list $value [Const false bool]] \
		       isNumeric]
	set isBool [my call ${tcl.booleanTest} [list $value]]
	return [my or $isNum $isBool $name]
    }

    # Builder:instanceOf.ZEROONE_BOOLEAN --
    #
    #	Generate code to check if the given STRING contains something that
    #	can be parsed to get a ZEROONE or a BOOLEAN (suitable, in
    #	other words, for a conditional. Quadcode implementation ('jumpFalse',
................................................................................
    #	name (optional) -
    #		A name to give to the result value.
    #
    # Results:
    #	An LLVM INT value reference containing a boolean value.

    method isBoolean(STRING) {value {name ""}} {
	my call ${tcl.booleanTest} [list $value] $name
    }

    # Builder:land(INT,INT) --
    #
    #	Generate code to compute the logical and of two INTs.  Quadcode
    #	implementation ('land').
    #







|
<
<
<


|
<
<
<







 







|







4361
4362
4363
4364
4365
4366
4367
4368



4369
4370
4371



4372
4373
4374
4375
4376
4377
4378
....
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
    #
    #	Generate code to check if the given STRING contains something that
    #	can be parsed to get either a NUMERIC or a BOOLEAN (suitable, in
    #	other words, for a conditional. Quadcode implementation ('jumpFalse',
    #	'jumpTrue', 'land', 'lor', 'not')

    method instanceOf.NUMERIC_OR_BOOLEAN(STRING) {value {name ""}} {
	my call ${tcl.isNumericOrBoolean} [list $value] $name



    }
    method instanceOf.IMPURE_NUMERIC_OR_BOOLEAN(STRING) {value {name ""}} {
	my call ${tcl.isNumericOrBoolean} [list $value] $name



    }

    # Builder:instanceOf.ZEROONE_BOOLEAN --
    #
    #	Generate code to check if the given STRING contains something that
    #	can be parsed to get a ZEROONE or a BOOLEAN (suitable, in
    #	other words, for a conditional. Quadcode implementation ('jumpFalse',
................................................................................
    #	name (optional) -
    #		A name to give to the result value.
    #
    # Results:
    #	An LLVM INT value reference containing a boolean value.

    method isBoolean(STRING) {value {name ""}} {
	my call ${tcl.isBoolean} [list $value] $name
    }

    # Builder:land(INT,INT) --
    #
    #	Generate code to compute the logical and of two INTs.  Quadcode
    #	implementation ('land').
    #

Changes to codegen/mathlib.tcl.

26
27
28
29
30
31
32
33

34
35
36
37
38
39
40
....
1336
1337
1338
1339
1340
1341
1342
1343
1344














1345













1346
1347
1348
1349
1350
1351
1352
1353
    variable tcl.not tcl.neg tcl_div
    variable tcl.land tcl.land.double tcl.lor tcl.lor.double
    variable tcl.add.numeric tcl.sub.numeric tcl.mult.numeric tcl.div.numeric
    variable tcl.pow.numeric tcl.land.numeric tcl.lor.numeric tcl.not.numeric
    variable tcl.not.numericOrBoolean
    variable tcl.neg.numeric tcl.eq.numeric tcl.ne.numeric tcl.lt.numeric
    variable tcl.le.numeric tcl.gt.numeric tcl.ge.numeric
    variable tcl.isBoolean tcl.isNumeric tcl.isDouble tcl.isInteger

    variable tcl.isZeroOneBoolean
    variable tcl.extractNumeric tcl.extractNumericOrBoolean
    variable tcl.extractDouble tcl.extractInteger
    variable tcl.stringify.double tcl.stringify.int
    variable tcl.stringify.numeric
    variable tcl.cmp.strstr tcl.cmp.strnum

................................................................................
	    my condBr [my isInteger $value] $yes $checkEmptyOK
	label checkEmptyOK:
	    my condBr $emptyOK $checkEmpty $checkDouble
	label checkEmpty:
	    my condBr [my Call tcl.impl.strempty $value] $yes $checkDouble
	label checkDouble:
	    set d [my GetDouble $value]
	    my condBr [my extract $d 0] $yes $checkInt
	label checkInt:














	    set i [my GetWide $value]













	    my ret [my extract $i 0]
	label yes:
	    my ret [Const true bool]
	}

	##### Function tcl.isDouble #####
	#
	# Type signature: value:STRING -> ZEROONE







|
>







 







|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
|







26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
....
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
    variable tcl.not tcl.neg tcl_div
    variable tcl.land tcl.land.double tcl.lor tcl.lor.double
    variable tcl.add.numeric tcl.sub.numeric tcl.mult.numeric tcl.div.numeric
    variable tcl.pow.numeric tcl.land.numeric tcl.lor.numeric tcl.not.numeric
    variable tcl.not.numericOrBoolean
    variable tcl.neg.numeric tcl.eq.numeric tcl.ne.numeric tcl.lt.numeric
    variable tcl.le.numeric tcl.gt.numeric tcl.ge.numeric
    variable tcl.isBoolean tcl.isDouble tcl.isInteger
    variable tcl.isNumeric tcl.isNumericOrBoolean
    variable tcl.isZeroOneBoolean
    variable tcl.extractNumeric tcl.extractNumericOrBoolean
    variable tcl.extractDouble tcl.extractInteger
    variable tcl.stringify.double tcl.stringify.int
    variable tcl.stringify.numeric
    variable tcl.cmp.strstr tcl.cmp.strnum

................................................................................
	    my condBr [my isInteger $value] $yes $checkEmptyOK
	label checkEmptyOK:
	    my condBr $emptyOK $checkEmpty $checkDouble
	label checkEmpty:
	    my condBr [my Call tcl.impl.strempty $value] $yes $checkDouble
	label checkDouble:
	    set d [my GetDouble $value]
	    my ret [my extract $d 0]
	label yes:
	    my ret [Const true bool]
	}

	##### Function: tcl.isNumericOrBoolean #####
	#
	# Type signature: value:STRING -> ZEROONE
	#
	# Tests if a STRING can be parsed as either a NUMERIC or BOOLEAN
	# (and hence might be an argument to commands like 'if'). Part of
	# the implementation of quadcode 'instanceOf'.

	set f [$m local "tcl.isNumericOrBoolean" ZEROONE<-STRING]
	params value
	build {
	    nonnull $value
	    my condBr [my nonnull [my dereference $value 0 Tcl_Obj.typePtr]] \
		$checkTypes $getDouble
	label checkTypes:
	    my condBr [my isDouble $value] $yes $checkIntType
	label checkIntType:
	    my condBr [my isInteger $value] $yes $checkBooleanType
	label checkBooleanType:
	    my condBr [my isBoolean $value] $yes $getDouble
	label getDouble:
	    set d [my GetDouble $value]
	    my condBr [my extract $d 0] $yes $getBool
	label getBool:
	    set b [my GetBoolean $value]
	    my ret [my extract $b 0]
	label yes:
	    my ret [Const true bool]
	}

	##### Function tcl.isDouble #####
	#
	# Type signature: value:STRING -> ZEROONE

Changes to codegen/tclapi.tcl.

2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
	# Special "constants"
	my buildInSection APIvar {
	    my APIVar tclIntType \
		[set it [my Tcl_GetObjType [$b constString "int" "type.int"]]]
	    my APIVar tclDoubleType \
		[my Tcl_GetObjType [$b constString "double" "type.double"]]
	    my APIVar tclBooleanType \
		[my Tcl_GetObjType [$b constString "boolean" "type.boolean"]]
	    my APIVar tclByteArrayType \
		[my Tcl_GetObjType [$b constString "bytearray" "type.bytes"]]
	    my APIVar tclStringType \
		[my Tcl_GetObjType [$b constString "string" "type.string"]]
	    set wt [my Tcl_GetObjType [$b constString "wideInt" "type.wide"]]
	    my APIVar tclWideIntType [$b select [$b nonnull $wt] $wt $it]
	    my APIVar tclListType \







|







2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
	# Special "constants"
	my buildInSection APIvar {
	    my APIVar tclIntType \
		[set it [my Tcl_GetObjType [$b constString "int" "type.int"]]]
	    my APIVar tclDoubleType \
		[my Tcl_GetObjType [$b constString "double" "type.double"]]
	    my APIVar tclBooleanType \
		[my Tcl_GetObjType [$b constString "booleanString" type.boolean"]]
	    my APIVar tclByteArrayType \
		[my Tcl_GetObjType [$b constString "bytearray" "type.bytes"]]
	    my APIVar tclStringType \
		[my Tcl_GetObjType [$b constString "string" "type.string"]]
	    set wt [my Tcl_GetObjType [$b constString "wideInt" "type.wide"]]
	    my APIVar tclWideIntType [$b select [$b nonnull $wt] $wt $it]
	    my APIVar tclListType \