stdlib

package
v0.3.0-beta2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const BlockIDSize = 32
View Source
const HashSize = 32

Variables

View Source
var AccountCodeUpdatedEventType = newFlowEventType(
	"AccountCodeUpdated",
	AccountEventAddressParameter,
	AccountEventCodeHashParameter,
	AccountEventContractsParameter,
)
View Source
var AccountCreatedEventType = newFlowEventType(
	"AccountCreated",
	AccountEventAddressParameter,
	AccountEventCodeHashParameter,
	AccountEventContractsParameter,
)
View Source
var AccountEventAddressParameter = &sema.Parameter{
	Identifier:     "address",
	TypeAnnotation: sema.NewTypeAnnotation(&sema.AddressType{}),
}
View Source
var AccountEventCodeHashParameter = &sema.Parameter{
	Identifier:     "codeHash",
	TypeAnnotation: sema.NewTypeAnnotation(HashType),
}
View Source
var AccountEventContractsParameter = &sema.Parameter{
	Identifier:     "contracts",
	TypeAnnotation: sema.NewTypeAnnotation(TypeIDsType),
}
View Source
var AccountEventPublicKeyParameter = &sema.Parameter{
	Identifier: "publicKey",
	TypeAnnotation: sema.NewTypeAnnotation(
		&sema.VariableSizedType{
			Type: &sema.UInt8Type{},
		},
	),
}
View Source
var AccountKeyAddedEventType = newFlowEventType(
	"AccountKeyAdded",
	AccountEventAddressParameter,
	AccountEventPublicKeyParameter,
)
View Source
var AccountKeyRemovedEventType = newFlowEventType(
	"AccountKeyRemoved",
	AccountEventAddressParameter,
	AccountEventPublicKeyParameter,
)
View Source
var AssertFunction = NewStandardLibraryFunction(
	"assert",
	&sema.FunctionType{
		Parameters: []*sema.Parameter{
			{
				Label:          sema.ArgumentLabelNotRequired,
				Identifier:     "condition",
				TypeAnnotation: sema.NewTypeAnnotation(&sema.BoolType{}),
			},
			{
				Identifier:     "message",
				TypeAnnotation: sema.NewTypeAnnotation(&sema.StringType{}),
			},
		},
		ReturnTypeAnnotation: sema.NewTypeAnnotation(
			&sema.VoidType{},
		),
		RequiredArgumentCount: (func() *int {
			var count = 1
			return &count
		})(),
	},
	func(invocation interpreter.Invocation) trampoline.Trampoline {
		result := invocation.Arguments[0].(interpreter.BoolValue)
		if !result {
			var message string
			if len(invocation.Arguments) > 1 {
				message = invocation.Arguments[1].(*interpreter.StringValue).Str
			}
			panic(AssertionError{
				Message:       message,
				LocationRange: invocation.LocationRange,
			})
		}
		return trampoline.Done{}
	},
	[]string{
		sema.ArgumentLabelNotRequired,
		"message",
	},
)
View Source
var BuiltinTypes = StandardLibraryTypes{}
View Source
var FlowBuiltInTypes = StandardLibraryTypes{
	StandardLibraryType{
		Name: "Block",
		Type: &BlockType{},
		Kind: common.DeclarationKindType,
	},
}
View Source
var HashType = &sema.ConstantSizedType{
	Size: HashSize,
	Type: &sema.UInt8Type{},
}
View Source
var LogFunction = NewStandardLibraryFunction(
	"log",
	&sema.FunctionType{
		Parameters: []*sema.Parameter{
			{
				Label:          sema.ArgumentLabelNotRequired,
				Identifier:     "value",
				TypeAnnotation: sema.NewTypeAnnotation(&sema.AnyStructType{}),
			},
		},
		ReturnTypeAnnotation: sema.NewTypeAnnotation(
			&sema.VoidType{},
		),
	},
	func(invocation interpreter.Invocation) trampoline.Trampoline {
		fmt.Printf("%v\n", invocation.Arguments[0])
		result := interpreter.VoidValue{}
		return trampoline.Done{Result: result}
	},
	nil,
)
View Source
var PanicFunction = NewStandardLibraryFunction(
	"panic",
	&sema.FunctionType{
		Parameters: []*sema.Parameter{
			{
				Label:          sema.ArgumentLabelNotRequired,
				Identifier:     "message",
				TypeAnnotation: sema.NewTypeAnnotation(&sema.StringType{}),
			},
		},
		ReturnTypeAnnotation: sema.NewTypeAnnotation(
			&sema.NeverType{},
		),
	},
	func(invocation interpreter.Invocation) trampoline.Trampoline {
		message := invocation.Arguments[0].(*interpreter.StringValue)
		panic(PanicError{
			Message:       message.Str,
			LocationRange: invocation.LocationRange,
		})
	},
	nil,
)
View Source
var TypeIDsType = &sema.VariableSizedType{
	Type: &sema.StringType{},
}

Functions

This section is empty.

Types

type AssertionError

type AssertionError struct {
	Message string
	interpreter.LocationRange
}

func (AssertionError) Error

func (e AssertionError) Error() string

type BlockType

type BlockType struct{}

func (*BlockType) CanHaveMembers

func (*BlockType) CanHaveMembers() bool

func (*BlockType) ContainsFirstLevelInterfaceType

func (*BlockType) ContainsFirstLevelInterfaceType() bool

func (*BlockType) Equal

func (*BlockType) Equal(other sema.Type) bool

func (*BlockType) GetMember

func (t *BlockType) GetMember(identifier string, _ ast.Range, _ func(error)) *sema.Member

func (*BlockType) ID

func (*BlockType) ID() sema.TypeID

func (*BlockType) IsInvalidType

func (*BlockType) IsInvalidType() bool

func (*BlockType) IsResourceType

func (*BlockType) IsResourceType() bool

func (*BlockType) IsType

func (*BlockType) IsType()

func (*BlockType) QualifiedString

func (*BlockType) QualifiedString() string

func (*BlockType) Resolve

func (t *BlockType) Resolve(_ map[*sema.TypeParameter]sema.Type) sema.Type

func (*BlockType) String

func (*BlockType) String() string

func (*BlockType) TypeAnnotationState

func (*BlockType) TypeAnnotationState() sema.TypeAnnotationState

func (*BlockType) Unify

func (t *BlockType) Unify(_ sema.Type, _ map[*sema.TypeParameter]sema.Type, _ func(err error), _ ast.Range) bool

type FlowBuiltinImpls

type FlowBuiltinImpls struct {
	CreateAccount   interpreter.HostFunction
	GetAccount      interpreter.HostFunction
	Log             interpreter.HostFunction
	GetCurrentBlock interpreter.HostFunction
	GetBlock        interpreter.HostFunction
}

FlowBuiltinImpls defines the set of functions needed to implement the Flow built-in functions.

type PanicError

type PanicError struct {
	Message string
	interpreter.LocationRange
}

func (PanicError) Error

func (e PanicError) Error() string

type StandardLibraryFunction

type StandardLibraryFunction struct {
	Name           string
	Type           sema.InvokableType
	Function       interpreter.HostFunctionValue
	ArgumentLabels []string
}

func NewStandardLibraryFunction

func NewStandardLibraryFunction(
	name string,
	functionType sema.InvokableType,
	function interpreter.HostFunction,
	argumentLabels []string,
) StandardLibraryFunction

func (StandardLibraryFunction) ValueDeclarationArgumentLabels

func (f StandardLibraryFunction) ValueDeclarationArgumentLabels() []string

func (StandardLibraryFunction) ValueDeclarationIsConstant

func (StandardLibraryFunction) ValueDeclarationIsConstant() bool

func (StandardLibraryFunction) ValueDeclarationKind

func (StandardLibraryFunction) ValueDeclarationKind() common.DeclarationKind

func (StandardLibraryFunction) ValueDeclarationPosition

func (StandardLibraryFunction) ValueDeclarationPosition() ast.Position

func (StandardLibraryFunction) ValueDeclarationType

func (f StandardLibraryFunction) ValueDeclarationType() sema.Type

type StandardLibraryFunctions

type StandardLibraryFunctions []StandardLibraryFunction

func FlowBuiltInFunctions

func FlowBuiltInFunctions(impls FlowBuiltinImpls) StandardLibraryFunctions

FlowBuiltInFunctions returns a list of standard library functions, bound to the provided implementation.

func (StandardLibraryFunctions) ToValueDeclarations

func (functions StandardLibraryFunctions) ToValueDeclarations() map[string]sema.ValueDeclaration

func (StandardLibraryFunctions) ToValues

func (functions StandardLibraryFunctions) ToValues() map[string]interpreter.Value

type StandardLibraryType

type StandardLibraryType struct {
	Name string
	Type sema.Type
	Kind common.DeclarationKind
}

func (StandardLibraryType) TypeDeclarationKind

func (t StandardLibraryType) TypeDeclarationKind() common.DeclarationKind

func (StandardLibraryType) TypeDeclarationPosition

func (StandardLibraryType) TypeDeclarationPosition() ast.Position

func (StandardLibraryType) TypeDeclarationType

func (t StandardLibraryType) TypeDeclarationType() sema.Type

type StandardLibraryTypes

type StandardLibraryTypes []StandardLibraryType

func (StandardLibraryTypes) ToTypeDeclarations

func (types StandardLibraryTypes) ToTypeDeclarations() map[string]sema.TypeDeclaration

type StandardLibraryValue

type StandardLibraryValue struct {
	Name       string
	Type       sema.Type
	Kind       common.DeclarationKind
	IsConstant bool
}

func (StandardLibraryValue) ValueDeclarationArgumentLabels

func (StandardLibraryValue) ValueDeclarationArgumentLabels() []string

func (StandardLibraryValue) ValueDeclarationIsConstant

func (v StandardLibraryValue) ValueDeclarationIsConstant() bool

func (StandardLibraryValue) ValueDeclarationKind

func (v StandardLibraryValue) ValueDeclarationKind() common.DeclarationKind

func (StandardLibraryValue) ValueDeclarationPosition

func (StandardLibraryValue) ValueDeclarationPosition() ast.Position

func (StandardLibraryValue) ValueDeclarationType

func (v StandardLibraryValue) ValueDeclarationType() sema.Type

type StandardLibraryValues

type StandardLibraryValues []StandardLibraryValue

func (StandardLibraryValues) ToValueDeclarations

func (functions StandardLibraryValues) ToValueDeclarations() map[string]sema.ValueDeclaration

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL