Check-in [af5efe3e99]

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

Overview
Comment:Added missing 'nre.tcl'
Timelines: family | ancestors | descendants | both | kbk-nre
Files: files | file ages | folders
SHA3-256:af5efe3e9993f55979420822a2215a886f18c9f9f2346aa071dc2a34c3954433
User & Date: kbk 2018-03-28 01:09:21
Context
2018-03-28
04:21
Write the function tcl.coro.resume - CRASHES ON MODULE INITIALIZATION check-in: 41b58defb4 user: kbk tags: notworking, kbk-nre
01:09
Added missing 'nre.tcl' check-in: af5efe3e99 user: kbk tags: kbk-nre
2018-03-27
01:44
merge trunk check-in: 6b733cc796 user: kbk tags: kbk-nre
Changes

Added quadcode/nre.tcl.









































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# nre.tcl --
#
#	Code to check, locally, whether a particular quadcode sequence
#	does anything locally to require non-recursive evaluation (NRE).
#
# Copyright (c) 2018 by Kevin B. Kenny
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
#------------------------------------------------------------------------------

# quadcode::transformer method needsNRE --
#
#	Computes whether a given quadcode sequence requires
#	non-recursive evaluation.
#
# Results:
#	Returns 1 if NRE is required, 0 otherwise.
#
# NRE is needed if the sequence invokes any command that requires NRE,
# or if it does anything that might switch coroutine, or if it tailcalls
# or evaluates uncontrolled code.

oo::define quadcode::transformer method needsNRE {} {

    # If the answer is already known, just return it

    if {[info exists nre]} {
	return $nre
    }

    # Walk the quads to determine whether NRE is needed.

    set nre 0
    set b -1
    foreach bb $bbcontent {
	incr b
	set pc -1
	foreach q $bb {
	    incr pc
	    switch -exact [lindex $q 0] {
		"invoke" - "invokeExpanded" {

		    # If we're invoking an unknown callee, we have to be NRE

		    set callee [lindex $q 3]
		    if {[lindex $callee 0] ne "literal"} {
			return [set nre 1]
		    }

		    # Find the argument types for this invoke

		    set alist [lrange $q 4 end]
		    set atypes [lmap a $alist {
			::quadcode::typeOfOperand $types $a
		    }]

		    if {[$specializer needsNRE $q $atypes]} {
			return [set nre 1]
		    }
		}
	    }
	}
    }
    return $nre
}