File: NonlocalBranch.h

package info (click to toggle)
guavac 1.0-5
  • links: PTS
  • area: main
  • in suites: hamm, slink
  • size: 2,716 kB
  • ctags: 2,357
  • sloc: cpp: 19,765; yacc: 1,629; makefile: 492; lex: 348; ansic: 284; sh: 280
file content (41 lines) | stat: -rw-r--r-- 1,637 bytes parent folder | download | duplicates (2)
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
// Copyright (c) 1996  David Engberg  All rights reserved
// $Id: NonlocalBranch.h,v 1.1 1996/03/31 19:35:29 geppetto Exp $
#ifndef _NonlocalBranch_h
#define _NonlocalBranch_h
#pragma interface

#include "CompileContext.h"

//
//  Class name : CNonlocalBranch
//  Description : The nonlocal branch object encapsulates a non-structed
//    branch from a deeper scope to a higher scope.  For example, if you
//    use 'break' in a switch or while body, you are generating one of these.
//    This bundles two important pieces of information.  The first is the
//    location of the branch offset in the code body.  The enclosing scope
//    needs to know where the branch instruction is so that it can go back and
//    insert the correct address for the code to jump to.
//    The other piece of information is the compile context that was in use
//    at the brach site.  This is important because it needs to be merged with
//    the context at the point where it branches to to correctly reflect the
//    initialization of local variables, etc.
//
class CNonlocalBranch {
public:
  CNonlocalBranch(unsigned long address, const CCompileContext& branchContext);
  CNonlocalBranch(const CNonlocalBranch& source);
  ~CNonlocalBranch();
  CNonlocalBranch& operator=(const CNonlocalBranch& source);

  const CCompileContext& GetContext() const { return fContext; }
  unsigned long GetAddress() const { return fBranchAddress; }

  CNonlocalBranch();
  bool operator==(const CNonlocalBranch& source) const;
  bool operator<(const CNonlocalBranch& source) const;
private:
  CCompileContext fContext;
  unsigned long fBranchAddress;
};

#endif