本文整理匯總了Golang中subc/compile/arch.LV.Size方法的典型用法代碼示例。如果您正苦於以下問題:Golang LV.Size方法的具體用法?Golang LV.Size怎麽用?Golang LV.Size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類subc/compile/arch.LV
的用法示例。
在下文中一共展示了LV.Size方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: indexExpr
// indexExpr generates code for array accesses (a[x], etc).
func (c *compiler) indexExpr(e *ast.IndexExpr, lv *arch.LV) *node {
var lv2 arch.LV
n := c.exprInternal(e.X, lv)
lv.Type = lv.Type.Underlying()
n = c.indirection(e, n, lv)
m := c.exprInternal(e.Index, &lv2)
m = c.rvalue(m, &lv2)
record, isRecord := lv.Type.(*types.Record)
if !isRecord && lv.Type != types.Typ[types.Char] {
// if it is not a record, we just need to scale
// it by the sizeof of the type
m = newNode(opScale, nil, nil, m, nil)
} else if isRecord {
// if it is a struct, we use sizeof to figure
// out the size to multiply by to get to the index
lv2.Size = c.cg.Sizeof(record)
m = newNode(opScaleBy, &lv2, nil, m, nil)
}
lv.Ident = false
lv.Addressable = true
return newNode(opAdd, lv, &lv2, n, m)
}
示例2: callExpr
// call expression generates code for calling functions (f(x), fact(1), etc).
func (c *compiler) callExpr(e *ast.CallExpr, lv *arch.LV) *node {
c.exprInternal(e.Fun, lv)
n := c.fnArgs(e.Args)
if sig, ok := lv.Type.(*types.Signature); ok {
lv.Size = len(e.Args)
lv.Type = sig.Result().Type().Underlying()
if !lv.Addressable {
// regular function calls
n = newNode(opCall, lv, nil, n, nil)
} else {
// function pointer calls
n = newNode(opCalr, lv, nil, n, nil)
}
}
lv.Addressable = false
return n
}