preprocessor

package
v0.0.0-...-05bc493 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: MIT, Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeType  = "code"
	ClassType = "class"
)
View Source
const (
	TemplateDirectory = "templates"
)

Variables

This section is empty.

Functions

func GenerateInitializationList

func GenerateInitializationList(out io.Writer, contracts ContractList) error

func GetRealApplicationDir

func GetRealApplicationDir(dir string) (string, error)

GetRealApplicationDir return application dir path

func GetRealContractsNames

func GetRealContractsNames() ([]string, error)

GetRealContractsNames returns names of all real smart contracts

Types

type ContractList

type ContractList []ContractListEntry

type ContractListEntry

type ContractListEntry struct {
	Name       string
	Path       string
	Parsed     *ParsedFile
	ImportPath string
	Version    int
}

type ParsedFile

type ParsedFile struct {
	// contains filtered or unexported fields
}

ParsedFile struct with prepared info we extract from source code

func ParseFile

func ParseFile(fileName string, machineType machinetype.Type) (*ParsedFile, error)

ParseFile parses a file as Go source code of a smart contract and returns it as `ParsedFile`

func (*ParsedFile) ChangePackageToMain

func (pf *ParsedFile) ChangePackageToMain()

ChangePackageToMain changes package of the parsed code to "main"

func (*ParsedFile) ContractName

func (pf *ParsedFile) ContractName() string

ContractName returns name of the contract

func (*ParsedFile) ProxyPackageName

func (pf *ParsedFile) ProxyPackageName() (string, error)

ProxyPackageName guesses user friendly contract "name" from file name and/or package in the file

func (*ParsedFile) SetPanicIsLogicalError

func (pf *ParsedFile) SetPanicIsLogicalError()

func (*ParsedFile) Write

func (pf *ParsedFile) Write(out io.Writer) error

Write prints `out` contract's code, it could be changed with a few methods

func (*ParsedFile) WriteProxy

func (pf *ParsedFile) WriteProxy(classReference string, out io.Writer) error

WriteProxy generates and writes into `out` source code of contract's proxy

func (*ParsedFile) WriteWrapper

func (pf *ParsedFile) WriteWrapper(out io.Writer, packageName string) error

WriteWrapper generates and writes into `out` source code of wrapper for the contract

type SagaInfo

type SagaInfo struct {
	IsSaga             bool
	RollbackMethodName string
	// we have to duplicate argument list here because it's not always used in templates
	Arguments    string
	NumArguments int
}

SagaInfo stores sagas-related information for given contract method. If a method is marked with //ins:saga(Rollback) SagaInfo stores `IsSaga: true, RollbackMethodName: "Rollback"`. Also Arguments always stores a comma separated list of arguments and NumArguments always stores the number of arguments.

Jump to

Keyboard shortcuts

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