本文整理匯總了Golang中subc/compile/arch.LV.Btype方法的典型用法代碼示例。如果您正苦於以下問題:Golang LV.Btype方法的具體用法?Golang LV.Btype怎麽用?Golang LV.Btype使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類subc/compile/arch.LV
的用法示例。
在下文中一共展示了LV.Btype方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: binaryExpr
// binaryExpr generates code for binary operators.
func (c *compiler) binaryExpr(e *ast.BinaryExpr, lv *arch.LV) *node {
op := e.Op.Type
if op == scan.Land || op == scan.Lor {
return c.logical(op, e, lv)
}
var lv2 arch.LV
n := c.exprInternal(e.X, lv)
m := c.rvalue(c.exprInternal(e.Y, &lv2), &lv2)
bop := binOp(op)
aop := arithOp(op)
switch {
// regular binary operators (+, -, *, /, etc)
case bop != 0:
tv, found := c.typAndValue(e)
if !found {
return nil
}
n = c.rvalue(n, lv)
lv.Btype = tv.Type
return newNode(bop, lv, &lv2, n, m)
// binary assignment operator such as (+=, -=, *=, /=, etc)
case aop != 0:
lvs := *lv
src := c.rvalue(n, &lvs)
m = newNode(aop, lv, &lv2, src, m)
n = newNode(opAssign, lv, &lv2, n, m)
lv.Addressable = false
// assignment operator (=)
case op == scan.Assign:
n = newNode(opAssign, lv, &lv2, n, m)
lv.Addressable = false
// comma operator (,)
case op == scan.Comma:
n = c.rvalue(n, lv)
n = newNode(opComma, &lv2, nil, n, m)
default:
c.errorf(e.Span().Start, "unknown binary op: %s\n", e.Op.Text)
}
return n
}