github.com/tardisgo/tardisgo@v0.0.0-20161119180838-e0dd9a7e46b5/haxe/haxecontext.go (about)

     1  package haxe
     2  
     3  import (
     4  	"go/types"
     5  
     6  	"github.com/tardisgo/tardisgo/pogo"
     7  	"github.com/tardisgo/tardisgo/tgossa"
     8  	"golang.org/x/tools/go/ssa"
     9  	"golang.org/x/tools/go/types/typeutil"
    10  )
    11  
    12  // haxeContext contains the context of a haxe code generation run
    13  type haxeContext struct {
    14  	pogoComp *pogo.Compilation // the host compilation context
    15  
    16  	useRegisterArray bool // should we use an array rather than individual register vars
    17  
    18  	nextReturnAddress       int           // what number is the next pseudo block return address?
    19  	hadReturn               bool          // has there been a return statement in this function?
    20  	hadBlockReturn          bool          // has there been a return in this block?
    21  	pseudoNextReturnAddress int           // what is the next pseudo block to emit/or limit of what's been emitted
    22  	pseudoBlockNext         int           // what is the next pseudo block we should have emitted?
    23  	currentfn               *ssa.Function // what we are currently working on
    24  	currentfnName           string        // the Haxe name of what we are currently working on
    25  	fnUsesGr                bool          // does the current function use Goroutines?
    26  	fnTracksPhi             bool          // does the current function track Phi?
    27  
    28  	funcNamesUsed     map[string]bool
    29  	fnCanOptMap       map[string]bool
    30  	reconstructInstrs []tgossa.BlockFormat
    31  	elseStack         []string
    32  
    33  	map1usePtr map[ssa.Value]oneUsePtr
    34  
    35  	localFunctionMap map[int]string
    36  	thisBlock        int
    37  
    38  	rangeChecks map[string]struct{}
    39  
    40  	inMustSplitSubFn bool
    41  	deDupRHS         map[string]string
    42  	subFnInstrs      []ssa.Instruction
    43  
    44  	tempVarList []regToFree
    45  
    46  	typesByID []types.Type
    47  	pte       typeutil.Map
    48  	pteKeys   []types.Type
    49  
    50  	langEntry *pogo.LanguageEntry
    51  }
    52  
    53  type langType struct {
    54  	hc *haxeContext
    55  }
    56  
    57  func (l langType) InitLang(comp *pogo.Compilation, langEnt *pogo.LanguageEntry) pogo.Language {
    58  	ret := langType{hc: &haxeContext{
    59  		pogoComp:  comp,
    60  		langEntry: langEnt,
    61  	}}
    62  	ret.hc.funcNamesUsed = make(map[string]bool)
    63  	return ret
    64  }
    65  func (l langType) PogoComp() *pogo.Compilation {
    66  	return l.hc.pogoComp
    67  }