Example #1
0
File: irgen.go Project: 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
}
Example #2
0
File: irx.go Project: 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)
}
Example #3
0
File: irgen.go Project: 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
}
Example #4
0
File: fix.go Project: 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
}