本文整理汇总了Golang中code/google/com/p/go/tools/ssa.Value.String方法的典型用法代码示例。如果您正苦于以下问题:Golang Value.String方法的具体用法?Golang Value.String怎么用?Golang Value.String使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类code/google/com/p/go/tools/ssa.Value
的用法示例。
在下文中一共展示了Value.String方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: valueNode
// valueNode returns the id of the value node for v, creating it (and
// the association) as needed. It may return zero for uninteresting
// values containing no pointers.
//
func (a *analysis) valueNode(v ssa.Value) nodeid {
// Value nodes for locals are created en masse by genFunc.
if id, ok := a.localval[v]; ok {
return id
}
// Value nodes for globals are created on demand.
id, ok := a.globalval[v]
if !ok {
var comment string
if a.log != nil {
comment = v.String()
}
id = a.addOneNode(v.Type(), comment, nil)
if obj := a.objectNode(nil, v); obj != 0 {
a.addressOf(id, obj)
}
a.setValueNode(v, id, nil)
}
return id
}
示例2: value
func (fr *frame) value(v ssa.Value) (result *LLVMValue) {
switch v := v.(type) {
case nil:
return nil
case *ssa.Function:
result, ok := fr.funcvals[v]
if ok {
return result
}
// fr.globals[v] has the function in raw pointer form;
// we must convert it to <f,ctx> form. If the function
// does not have a receiver, then create a wrapper
// function that has an additional "context" parameter.
f := fr.resolveFunction(v)
if v.Signature.Recv() == nil && len(v.FreeVars) == 0 {
f = contextFunction(fr.compiler, f)
}
pair := llvm.ConstNull(fr.llvmtypes.ToLLVM(f.Type()))
fnptr := llvm.ConstBitCast(f.LLVMValue(), pair.Type().StructElementTypes()[0])
pair = llvm.ConstInsertValue(pair, fnptr, []uint32{0})
result = fr.NewValue(pair, f.Type())
fr.funcvals[v] = result
return result
case *ssa.Const:
return fr.NewConstValue(v.Value, v.Type())
case *ssa.Global:
if g, ok := fr.globals[v]; ok {
return g
}
// Create an external global. Globals for this package are defined
// on entry to translatePackage, and have initialisers.
llelemtyp := fr.llvmtypes.ToLLVM(deref(v.Type()))
llglobal := llvm.AddGlobal(fr.module.Module, llelemtyp, v.String())
global := fr.NewValue(llglobal, v.Type())
fr.globals[v] = global
return global
}
if value, ok := fr.env[v]; ok {
return value
}
// Instructions are not necessarily visited before they are used (e.g. Phi
// edges) so we must "backpatch": create a value with the resultant type,
// and then replace it when we visit the instruction.
if b, ok := fr.backpatch[v]; ok {
return b
}
if fr.backpatch == nil {
fr.backpatch = make(map[ssa.Value]*LLVMValue)
}
// Note: we must not create a constant here (e.g. Undef/ConstNull), as
// it is not permissible to replace a constant with a non-constant.
// We must create the value in its own standalone basic block, so we can
// dispose of it after replacing.
currBlock := fr.builder.GetInsertBlock()
fr.builder.SetInsertPointAtEnd(llvm.AddBasicBlock(currBlock.Parent(), ""))
placeholder := fr.compiler.builder.CreatePHI(fr.llvmtypes.ToLLVM(v.Type()), "")
fr.builder.SetInsertPointAtEnd(currBlock)
value := fr.NewValue(placeholder, v.Type())
fr.backpatch[v] = value
return value
}