summaryrefslogtreecommitdiff
path: root/compiler/ncgnstfl.pas
blob: f17a881e324c412f6f4534ade5441f927aac373e (plain)
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
69
{
    Copyright (c) 2016 by Jonas Maebe

    Generate assembler for nodes that influence the flow

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

 ****************************************************************************
}
unit ncgnstfl;

{$i fpcdefs.inc}

interface

    uses
      node,
      nflw, ncgflw;

    type
      tcgnestgotonode = class(tcggotonode)
        function pass_typecheck: tnode; override;
      end;

implementation

    uses
      globtype,globals,
      nld,
      symdef,symsym,symcreat;


    function tcgnestgotonode.pass_typecheck: tnode;
      begin
        result:=inherited;
        if (m_non_local_goto in current_settings.modeswitches) and
           assigned(labelsym) and
           assigned(labelsym.jumpbuf) then
          begin
            { we will access this jumpbuf local variable from a nested context,
              but the loadnode to do so only gets created in pass_1. This is too
              late for us to detect that it should have been added to the
              parentfpstruct, so temporarily create and typecheckpass a load
              node for the jumpbuf here (so that it can be added now) }
            with cloadnode.create(labelsym.jumpbuf,labelsym.jumpbuf.Owner) do
              begin
                pass_typecheck;
                free
              end;
          end;
      end;


begin
  cgotonode:=tcgnestgotonode;
end.