示例#1
0
func composeFloat32(expr *ast.Expr) (funcs.Float32, error) {
	uniq, err := prep(expr, types.SINGLE_FLOAT)
	if err != nil {
		return nil, err
	}
	if expr.Terminal != nil {
		if expr.GetTerminal().Variable != nil {
			return funcs.NewFloat32Variable(), nil
		} else {
			return funcs.NewConstFloat32(expr.GetTerminal().GetFloatValue()), nil
		}
	}
	values, err := newValues(expr.GetFunction().GetParams())
	if err != nil {
		return nil, err
	}
	return funcs.NewFloat32Func(uniq, values...)
}
示例#2
0
文件: compose.go 项目: katydid/v0.1
func composeVariable(v *ast.Variable) funcs.Variable {
	switch v.Type {
	case types.SINGLE_DOUBLE:
		return funcs.NewFloat64Variable()
	case types.SINGLE_FLOAT:
		return funcs.NewFloat32Variable()
	case types.SINGLE_INT64:
		return funcs.NewInt64Variable()
	case types.SINGLE_UINT64:
		return funcs.NewUint64Variable()
	case types.SINGLE_INT32:
		return funcs.NewInt32Variable()
	case types.SINGLE_BOOL:
		return funcs.NewBoolVariable()
	case types.SINGLE_STRING:
		return funcs.NewStringVariable()
	case types.SINGLE_BYTES:
		return funcs.NewBytesVariable()
	case types.SINGLE_UINT32:
		return funcs.NewUint32Variable()
	}
	panic("unreachable")
}