Пример #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
}