예제 #1
0
파일: irgen.go 프로젝트: mewmew/uc
// emitInst emits to b the given unnamed value instruction.
func (b *BasicBlock) emitInst(inst instruction.ValueInst) value.Value {
	v, err := instruction.NewLocalVarDef("", inst)
	if err != nil {
		panic(fmt.Sprintf("unable to create local variable definition; %v", err))
	}
	b.AppendInst(v)
	return v
}
예제 #2
0
파일: irx.go 프로젝트: llir/llvm
// NewLocalVarDef returns a new local variable definition based on the given
// local identifier name and value instruction.
func NewLocalVarDef(lname, valInst interface{}) (*instruction.LocalVarDef, error) {
	if valInst, ok := valInst.(instruction.ValueInst); ok {
		name, err := getLocalName(lname)
		if err != nil {
			return nil, errutil.Err(err)
		}
		return instruction.NewLocalVarDef(name, valInst)
	}
	return nil, errutil.Newf("invalid value instruction type; expected instruction.ValueInst, got %T", valInst)
}
예제 #3
0
파일: irgen.go 프로젝트: mewmew/uc
// emitLocal emits to b the given named value instruction.
func (b *BasicBlock) emitLocal(ident *ast.Ident, inst instruction.ValueInst) value.Value {
	name := b.parent.genUnique(ident)
	v, err := instruction.NewLocalVarDef(name, inst)
	if err != nil {
		panic(fmt.Sprintf("unable to create local variable definition; %v", err))
	}
	b.AppendInst(v)
	b.parent.setIdentValue(ident, v)
	return v
}
예제 #4
0
파일: fix.go 프로젝트: llir/llvm
// fixLocalVarDefInst replaces dummy values within the given LocalVarDef
// instruction with their corresponding local variables.
func (m dummyMap) fixLocalVarDefInst(oldInst *instruction.LocalVarDef) *instruction.LocalVarDef {
	name := oldInst.Name()
	oldValInst := oldInst.ValInst()
	valInst := m.fixValueInst(oldValInst)
	inst, err := instruction.NewLocalVarDef(name, valInst)
	if err != nil {
		panic(errutil.Err(err))
	}
	m.set(name, inst)
	return inst
}