示例#1
0
文件: comp.go 项目: enex/RUN
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)
}
示例#2
0
文件: type.go 项目: enex/RUN
func typeOfBasic(b *ast.BasicLit) *ast.Ident {
	switch b.Kind {
	case token.INTEGER:
		return &ast.Ident{Name: "int", NamePos: b.Pos()}
	default:
		return nil
	}
}
示例#3
0
文件: constant.go 项目: aylusltd/calc
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,
	}
}