func (c *compiler) compInt(n *ast.BasicLit, reg string) { i, err := strconv.Atoi(n.Lit) if err != nil { c.Error(n.Pos(), "bad conversion:", err) } fmt.Fprintf(c.fp, "setl(%d, %s);\n", i, reg) }
func typeOfBasic(b *ast.BasicLit) *ast.Ident { switch b.Kind { case token.INTEGER: return &ast.Ident{Name: "int", NamePos: b.Pos()} default: return nil } }
func makeConstant(b *ast.BasicLit) *Constant { var v Value switch b.Kind { case token.BOOL: v, _ = makeBool(b.Lit) // TODO handle error case token.INTEGER: v, _ = makeInt(b.Lit) // TODO handle error } return &Constant{ object: object{name: v.String(), pos: b.Pos(), typ: v.Type()}, value: v, } }