repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
hyperledger/burrow
storage/kvstore.go
CompareKeys
func CompareKeys(k1, k2 []byte) int { ko1 := KeyOrder(k1) ko2 := KeyOrder(k2) if ko1 < ko2 { return -1 } if ko1 > ko2 { return 1 } return bytes.Compare(k1, k2) }
go
func CompareKeys(k1, k2 []byte) int { ko1 := KeyOrder(k1) ko2 := KeyOrder(k2) if ko1 < ko2 { return -1 } if ko1 > ko2 { return 1 } return bytes.Compare(k1, k2) }
[ "func", "CompareKeys", "(", "k1", ",", "k2", "[", "]", "byte", ")", "int", "{", "ko1", ":=", "KeyOrder", "(", "k1", ")", "\n", "ko2", ":=", "KeyOrder", "(", "k2", ")", "\n", "if", "ko1", "<", "ko2", "{", "return", "-", "1", "\n", "}", "\n", "...
// Sorts the keys as if they were compared lexicographically with their KeyOrder prepended
[ "Sorts", "the", "keys", "as", "if", "they", "were", "compared", "lexicographically", "with", "their", "KeyOrder", "prepended" ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/storage/kvstore.go#L106-L116
train
hyperledger/burrow
execution/evm/vm.go
delegateCall
func (vm *VM) delegateCall(callState Interface, eventSink EventSink, caller, callee crypto.Address, code, input []byte, value uint64, gas *uint64, callType exec.CallType) (output []byte, err errors.CodedError) { // fire the post call event (including exception if applicable) and make sure we return the accumulated ...
go
func (vm *VM) delegateCall(callState Interface, eventSink EventSink, caller, callee crypto.Address, code, input []byte, value uint64, gas *uint64, callType exec.CallType) (output []byte, err errors.CodedError) { // fire the post call event (including exception if applicable) and make sure we return the accumulated ...
[ "func", "(", "vm", "*", "VM", ")", "delegateCall", "(", "callState", "Interface", ",", "eventSink", "EventSink", ",", "caller", ",", "callee", "crypto", ".", "Address", ",", "code", ",", "input", "[", "]", "byte", ",", "value", "uint64", ",", "gas", "*...
// DelegateCall is executed by the DELEGATECALL opcode, introduced as off Ethereum Homestead. // The intent of delegate call is to run the code of the callee in the storage context of the caller; // while preserving the original caller to the previous callee. // Different to the normal CALL or CALLCODE, the value does ...
[ "DelegateCall", "is", "executed", "by", "the", "DELEGATECALL", "opcode", "introduced", "as", "off", "Ethereum", "Homestead", ".", "The", "intent", "of", "delegate", "call", "is", "to", "run", "the", "code", "of", "the", "callee", "in", "the", "storage", "con...
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/execution/evm/vm.go#L188-L213
train
hyperledger/burrow
execution/evm/vm.go
useGasNegative
func useGasNegative(gasLeft *uint64, gasToUse uint64, err errors.Sink) { if *gasLeft >= gasToUse { *gasLeft -= gasToUse } else { err.PushError(errors.ErrorCodeInsufficientGas) } }
go
func useGasNegative(gasLeft *uint64, gasToUse uint64, err errors.Sink) { if *gasLeft >= gasToUse { *gasLeft -= gasToUse } else { err.PushError(errors.ErrorCodeInsufficientGas) } }
[ "func", "useGasNegative", "(", "gasLeft", "*", "uint64", ",", "gasToUse", "uint64", ",", "err", "errors", ".", "Sink", ")", "{", "if", "*", "gasLeft", ">=", "gasToUse", "{", "*", "gasLeft", "-=", "gasToUse", "\n", "}", "else", "{", "err", ".", "PushErr...
// Try to deduct gasToUse from gasLeft. If ok return false, otherwise // set err and return true.
[ "Try", "to", "deduct", "gasToUse", "from", "gasLeft", ".", "If", "ok", "return", "false", "otherwise", "set", "err", "and", "return", "true", "." ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/execution/evm/vm.go#L217-L223
train
hyperledger/burrow
execution/evm/vm.go
dumpTokens
func dumpTokens(nonce []byte, caller, callee crypto.Address, code []byte) { var tokensString string tokens, err := acm.Bytecode(code).Tokens() if err != nil { tokensString = fmt.Sprintf("error generating tokens from bytecode: %v", err) } else { tokensString = strings.Join(tokens, "\n") } txHashString := "nil-...
go
func dumpTokens(nonce []byte, caller, callee crypto.Address, code []byte) { var tokensString string tokens, err := acm.Bytecode(code).Tokens() if err != nil { tokensString = fmt.Sprintf("error generating tokens from bytecode: %v", err) } else { tokensString = strings.Join(tokens, "\n") } txHashString := "nil-...
[ "func", "dumpTokens", "(", "nonce", "[", "]", "byte", ",", "caller", ",", "callee", "crypto", ".", "Address", ",", "code", "[", "]", "byte", ")", "{", "var", "tokensString", "string", "\n", "tokens", ",", "err", ":=", "acm", ".", "Bytecode", "(", "co...
// Dump the bytecode being sent to the EVM in the current working directory
[ "Dump", "the", "bytecode", "being", "sent", "to", "the", "EVM", "in", "the", "current", "working", "directory" ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/execution/evm/vm.go#L1064-L1086
train
hyperledger/burrow
integration/integration.go
MakePrivateAccounts
func MakePrivateAccounts(n int) []*acm.PrivateAccount { accounts := make([]*acm.PrivateAccount, n) for i := 0; i < n; i++ { accounts[i] = acm.GeneratePrivateAccountFromSecret("mysecret" + strconv.Itoa(i)) } return accounts }
go
func MakePrivateAccounts(n int) []*acm.PrivateAccount { accounts := make([]*acm.PrivateAccount, n) for i := 0; i < n; i++ { accounts[i] = acm.GeneratePrivateAccountFromSecret("mysecret" + strconv.Itoa(i)) } return accounts }
[ "func", "MakePrivateAccounts", "(", "n", "int", ")", "[", "]", "*", "acm", ".", "PrivateAccount", "{", "accounts", ":=", "make", "(", "[", "]", "*", "acm", ".", "PrivateAccount", ",", "n", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "n", ";"...
// Deterministic account generation helper. Pass number of accounts to make
[ "Deterministic", "account", "generation", "helper", ".", "Pass", "number", "of", "accounts", "to", "make" ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/integration/integration.go#L190-L196
train
hyperledger/burrow
vent/sqldb/adapters/postgres_adapter.go
NewPostgresAdapter
func NewPostgresAdapter(schema string, log *logger.Logger) *PostgresAdapter { return &PostgresAdapter{ Log: log, Schema: schema, } }
go
func NewPostgresAdapter(schema string, log *logger.Logger) *PostgresAdapter { return &PostgresAdapter{ Log: log, Schema: schema, } }
[ "func", "NewPostgresAdapter", "(", "schema", "string", ",", "log", "*", "logger", ".", "Logger", ")", "*", "PostgresAdapter", "{", "return", "&", "PostgresAdapter", "{", "Log", ":", "log", ",", "Schema", ":", "schema", ",", "}", "\n", "}" ]
// NewPostgresAdapter constructs a new db adapter
[ "NewPostgresAdapter", "constructs", "a", "new", "db", "adapter" ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/vent/sqldb/adapters/postgres_adapter.go#L33-L38
train
hyperledger/burrow
vent/sqldb/adapters/postgres_adapter.go
Open
func (adapter *PostgresAdapter) Open(dbURL string) (*sql.DB, error) { db, err := sql.Open("postgres", dbURL) if err != nil { adapter.Log.Info("msg", "Error creating database connection", "err", err) return nil, err } // if there is a supplied Schema if adapter.Schema != "" { if err = db.Ping(); err != nil {...
go
func (adapter *PostgresAdapter) Open(dbURL string) (*sql.DB, error) { db, err := sql.Open("postgres", dbURL) if err != nil { adapter.Log.Info("msg", "Error creating database connection", "err", err) return nil, err } // if there is a supplied Schema if adapter.Schema != "" { if err = db.Ping(); err != nil {...
[ "func", "(", "adapter", "*", "PostgresAdapter", ")", "Open", "(", "dbURL", "string", ")", "(", "*", "sql", ".", "DB", ",", "error", ")", "{", "db", ",", "err", ":=", "sql", ".", "Open", "(", "\"", "\"", ",", "dbURL", ")", "\n", "if", "err", "!=...
// Open connects to a PostgreSQL database, opens it & create default schema if provided
[ "Open", "connects", "to", "a", "PostgreSQL", "database", "opens", "it", "&", "create", "default", "schema", "if", "provided" ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/vent/sqldb/adapters/postgres_adapter.go#L41-L84
train
hyperledger/burrow
vent/sqldb/adapters/postgres_adapter.go
CreateTableQuery
func (adapter *PostgresAdapter) CreateTableQuery(tableName string, columns []*types.SQLTableColumn) (string, string) { // build query columnsDef := "" primaryKey := "" dictionaryValues := "" for i, column := range columns { secureColumn := adapter.SecureName(column.Name) sqlType, _ := adapter.TypeMapping(colu...
go
func (adapter *PostgresAdapter) CreateTableQuery(tableName string, columns []*types.SQLTableColumn) (string, string) { // build query columnsDef := "" primaryKey := "" dictionaryValues := "" for i, column := range columns { secureColumn := adapter.SecureName(column.Name) sqlType, _ := adapter.TypeMapping(colu...
[ "func", "(", "adapter", "*", "PostgresAdapter", ")", "CreateTableQuery", "(", "tableName", "string", ",", "columns", "[", "]", "*", "types", ".", "SQLTableColumn", ")", "(", "string", ",", "string", ")", "{", "// build query", "columnsDef", ":=", "\"", "\"",...
// CreateTableQuery builds query for creating a new table
[ "CreateTableQuery", "builds", "query", "for", "creating", "a", "new", "table" ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/vent/sqldb/adapters/postgres_adapter.go#L101-L155
train
hyperledger/burrow
vent/sqldb/adapters/postgres_adapter.go
TableDefinitionQuery
func (adapter *PostgresAdapter) TableDefinitionQuery() string { query := ` SELECT %s,%s,%s,%s FROM %s.%s WHERE %s = $1 ORDER BY %s;` return Cleanf(query, types.SQLColumnLabelColumnName, types.SQLColumnLabelColumnType, // select types.SQLColumnLabelColumnLength, types.SQLColumnLabelPrimaryKey,...
go
func (adapter *PostgresAdapter) TableDefinitionQuery() string { query := ` SELECT %s,%s,%s,%s FROM %s.%s WHERE %s = $1 ORDER BY %s;` return Cleanf(query, types.SQLColumnLabelColumnName, types.SQLColumnLabelColumnType, // select types.SQLColumnLabelColumnLength, types.SQLColumnLabelPrimaryKey,...
[ "func", "(", "adapter", "*", "PostgresAdapter", ")", "TableDefinitionQuery", "(", ")", "string", "{", "query", ":=", "`\n\t\tSELECT\n\t\t\t%s,%s,%s,%s\n\t\tFROM\n\t\t\t%s.%s\n\t\tWHERE\n\t\t\t%s = $1\n\t\tORDER BY\n\t\t\t%s;`", "\n\n", "return", "Cleanf", "(", "query", ",", "...
// TableDefinitionQuery returns a query with table structure
[ "TableDefinitionQuery", "returns", "a", "query", "with", "table", "structure" ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/vent/sqldb/adapters/postgres_adapter.go#L187-L205
train
hyperledger/burrow
vent/sqldb/adapters/postgres_adapter.go
InsertLogQuery
func (adapter *PostgresAdapter) InsertLogQuery() string { query := ` INSERT INTO %s.%s (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) VALUES (CURRENT_TIMESTAMP, $1, $2, $3, $4, $5, $6 ,$7, $8, $9);` return Cleanf(query, adapter.Schema, types.SQLLogTableName, // insert //fields types.SQLColumnLabelTimeStamp, types.SQLColu...
go
func (adapter *PostgresAdapter) InsertLogQuery() string { query := ` INSERT INTO %s.%s (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) VALUES (CURRENT_TIMESTAMP, $1, $2, $3, $4, $5, $6 ,$7, $8, $9);` return Cleanf(query, adapter.Schema, types.SQLLogTableName, // insert //fields types.SQLColumnLabelTimeStamp, types.SQLColu...
[ "func", "(", "adapter", "*", "PostgresAdapter", ")", "InsertLogQuery", "(", ")", "string", "{", "query", ":=", "`\n\t\tINSERT INTO %s.%s (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)\n\t\tVALUES (CURRENT_TIMESTAMP, $1, $2, $3, $4, $5, $6 ,$7, $8, $9);`", "\n\n", "return", "Cleanf", "(", "query...
// InsertLogQuery returns a query to insert a row in log table
[ "InsertLogQuery", "returns", "a", "query", "to", "insert", "a", "row", "in", "log", "table" ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/vent/sqldb/adapters/postgres_adapter.go#L256-L267
train
hyperledger/burrow
consensus/abci/process.go
NewProcess
func NewProcess(committer execution.BatchCommitter, blockchain *bcm.Blockchain, txDecoder txs.Decoder, commitInterval time.Duration, panicFunc func(error)) *Process { p := &Process{ committer: committer, blockchain: blockchain, done: make(chan struct{}), txDecoder: txDecoder, panic: panicFunc,...
go
func NewProcess(committer execution.BatchCommitter, blockchain *bcm.Blockchain, txDecoder txs.Decoder, commitInterval time.Duration, panicFunc func(error)) *Process { p := &Process{ committer: committer, blockchain: blockchain, done: make(chan struct{}), txDecoder: txDecoder, panic: panicFunc,...
[ "func", "NewProcess", "(", "committer", "execution", ".", "BatchCommitter", ",", "blockchain", "*", "bcm", ".", "Blockchain", ",", "txDecoder", "txs", ".", "Decoder", ",", "commitInterval", "time", ".", "Duration", ",", "panicFunc", "func", "(", "error", ")", ...
// NewProcess returns a no-consensus ABCI process suitable for running a single node without Tendermint. // The CheckTx function can be used to submit transactions which are processed according
[ "NewProcess", "returns", "a", "no", "-", "consensus", "ABCI", "process", "suitable", "for", "running", "a", "single", "node", "without", "Tendermint", ".", "The", "CheckTx", "function", "can", "be", "used", "to", "submit", "transactions", "which", "are", "proc...
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/consensus/abci/process.go#L31-L48
train
hyperledger/burrow
txs/tx.go
Sign
func (tx *Tx) Sign(signingAccounts ...acm.AddressableSigner) (*Envelope, error) { env := tx.Enclose() err := env.Sign(signingAccounts...) if err != nil { return nil, err } tx.Rehash() return env, nil }
go
func (tx *Tx) Sign(signingAccounts ...acm.AddressableSigner) (*Envelope, error) { env := tx.Enclose() err := env.Sign(signingAccounts...) if err != nil { return nil, err } tx.Rehash() return env, nil }
[ "func", "(", "tx", "*", "Tx", ")", "Sign", "(", "signingAccounts", "...", "acm", ".", "AddressableSigner", ")", "(", "*", "Envelope", ",", "error", ")", "{", "env", ":=", "tx", ".", "Enclose", "(", ")", "\n", "err", ":=", "env", ".", "Sign", "(", ...
// Encloses in Envelope and signs envelope
[ "Encloses", "in", "Envelope", "and", "signs", "envelope" ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/txs/tx.go#L56-L64
train
hyperledger/burrow
txs/tx.go
MustSignBytes
func (tx *Tx) MustSignBytes() []byte { bs, err := tx.SignBytes() if err != nil { panic(err) } return bs }
go
func (tx *Tx) MustSignBytes() []byte { bs, err := tx.SignBytes() if err != nil { panic(err) } return bs }
[ "func", "(", "tx", "*", "Tx", ")", "MustSignBytes", "(", ")", "[", "]", "byte", "{", "bs", ",", "err", ":=", "tx", ".", "SignBytes", "(", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "return", "bs", "\n...
// Generate SignBytes, panicking on any failure
[ "Generate", "SignBytes", "panicking", "on", "any", "failure" ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/txs/tx.go#L67-L73
train
hyperledger/burrow
txs/tx.go
GenerateReceipt
func (tx *Tx) GenerateReceipt() *Receipt { receipt := &Receipt{ TxType: tx.Type(), TxHash: tx.Hash(), } if callTx, ok := tx.Payload.(*payload.CallTx); ok { receipt.CreatesContract = callTx.Address == nil if receipt.CreatesContract { receipt.ContractAddress = crypto.NewContractAddress(callTx.Input.Address,...
go
func (tx *Tx) GenerateReceipt() *Receipt { receipt := &Receipt{ TxType: tx.Type(), TxHash: tx.Hash(), } if callTx, ok := tx.Payload.(*payload.CallTx); ok { receipt.CreatesContract = callTx.Address == nil if receipt.CreatesContract { receipt.ContractAddress = crypto.NewContractAddress(callTx.Input.Address,...
[ "func", "(", "tx", "*", "Tx", ")", "GenerateReceipt", "(", ")", "*", "Receipt", "{", "receipt", ":=", "&", "Receipt", "{", "TxType", ":", "tx", ".", "Type", "(", ")", ",", "TxHash", ":", "tx", ".", "Hash", "(", ")", ",", "}", "\n", "if", "callT...
// Generate a transaction Receipt containing the Tx hash and other information if the Tx is call. // Returned by ABCI methods.
[ "Generate", "a", "transaction", "Receipt", "containing", "the", "Tx", "hash", "and", "other", "information", "if", "the", "Tx", "is", "call", ".", "Returned", "by", "ABCI", "methods", "." ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/txs/tx.go#L184-L198
train
hyperledger/burrow
logging/loggers/filter_logger.go
FilterLogger
func FilterLogger(outputLogger log.Logger, predicate func(keyvals []interface{}) bool) log.Logger { return log.LoggerFunc(func(keyvals ...interface{}) error { // Always forward signals if structure.Signal(keyvals) != "" || !predicate(keyvals) { return outputLogger.Log(keyvals...) } return nil }) }
go
func FilterLogger(outputLogger log.Logger, predicate func(keyvals []interface{}) bool) log.Logger { return log.LoggerFunc(func(keyvals ...interface{}) error { // Always forward signals if structure.Signal(keyvals) != "" || !predicate(keyvals) { return outputLogger.Log(keyvals...) } return nil }) }
[ "func", "FilterLogger", "(", "outputLogger", "log", ".", "Logger", ",", "predicate", "func", "(", "keyvals", "[", "]", "interface", "{", "}", ")", "bool", ")", "log", ".", "Logger", "{", "return", "log", ".", "LoggerFunc", "(", "func", "(", "keyvals", ...
// Filter logger allows us to filter lines logged to it before passing on to underlying // output logger // Creates a logger that removes lines from output when the predicate evaluates true
[ "Filter", "logger", "allows", "us", "to", "filter", "lines", "logged", "to", "it", "before", "passing", "on", "to", "underlying", "output", "logger", "Creates", "a", "logger", "that", "removes", "lines", "from", "output", "when", "the", "predicate", "evaluates...
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/logging/loggers/filter_logger.go#L11-L19
train
hyperledger/burrow
deploy/def/client.go
dial
func (c *Client) dial(logger *logging.Logger) error { if c.transactClient == nil { conn, err := grpc.Dial(c.ChainAddress, grpc.WithInsecure()) if err != nil { return err } c.transactClient = rpctransact.NewTransactClient(conn) c.queryClient = rpcquery.NewQueryClient(conn) c.executionEventsClient = rpcev...
go
func (c *Client) dial(logger *logging.Logger) error { if c.transactClient == nil { conn, err := grpc.Dial(c.ChainAddress, grpc.WithInsecure()) if err != nil { return err } c.transactClient = rpctransact.NewTransactClient(conn) c.queryClient = rpcquery.NewQueryClient(conn) c.executionEventsClient = rpcev...
[ "func", "(", "c", "*", "Client", ")", "dial", "(", "logger", "*", "logging", ".", "Logger", ")", "error", "{", "if", "c", ".", "transactClient", "==", "nil", "{", "conn", ",", "err", ":=", "grpc", ".", "Dial", "(", "c", ".", "ChainAddress", ",", ...
// Connect GRPC clients using ChainURL
[ "Connect", "GRPC", "clients", "using", "ChainURL" ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/deploy/def/client.go#L58-L89
train
hyperledger/burrow
deploy/def/client.go
CreateKey
func (c *Client) CreateKey(keyName, curveTypeString string, logger *logging.Logger) (crypto.PublicKey, error) { err := c.dial(logger) if err != nil { return crypto.PublicKey{}, err } if c.keyClient == nil { return crypto.PublicKey{}, fmt.Errorf("could not create key pair since no keys service is attached, " + ...
go
func (c *Client) CreateKey(keyName, curveTypeString string, logger *logging.Logger) (crypto.PublicKey, error) { err := c.dial(logger) if err != nil { return crypto.PublicKey{}, err } if c.keyClient == nil { return crypto.PublicKey{}, fmt.Errorf("could not create key pair since no keys service is attached, " + ...
[ "func", "(", "c", "*", "Client", ")", "CreateKey", "(", "keyName", ",", "curveTypeString", "string", ",", "logger", "*", "logging", ".", "Logger", ")", "(", "crypto", ".", "PublicKey", ",", "error", ")", "{", "err", ":=", "c", ".", "dial", "(", "logg...
// Creates a keypair using attached keys service
[ "Creates", "a", "keypair", "using", "attached", "keys", "service" ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/deploy/def/client.go#L238-L259
train
hyperledger/burrow
deploy/def/client.go
Broadcast
func (c *Client) Broadcast(tx payload.Payload, logger *logging.Logger) (*exec.TxExecution, error) { err := c.dial(logger) if err != nil { return nil, err } ctx, cancel := context.WithTimeout(context.Background(), c.timeout) defer cancel() return c.transactClient.BroadcastTxSync(ctx, &rpctransact.TxEnvelopeParam...
go
func (c *Client) Broadcast(tx payload.Payload, logger *logging.Logger) (*exec.TxExecution, error) { err := c.dial(logger) if err != nil { return nil, err } ctx, cancel := context.WithTimeout(context.Background(), c.timeout) defer cancel() return c.transactClient.BroadcastTxSync(ctx, &rpctransact.TxEnvelopeParam...
[ "func", "(", "c", "*", "Client", ")", "Broadcast", "(", "tx", "payload", ".", "Payload", ",", "logger", "*", "logging", ".", "Logger", ")", "(", "*", "exec", ".", "TxExecution", ",", "error", ")", "{", "err", ":=", "c", ".", "dial", "(", "logger", ...
// Broadcast payload for remote signing
[ "Broadcast", "payload", "for", "remote", "signing" ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/deploy/def/client.go#L262-L270
train
hyperledger/burrow
deploy/def/client.go
BroadcastEnvelope
func (c *Client) BroadcastEnvelope(txEnv *txs.Envelope, logger *logging.Logger) (*exec.TxExecution, error) { err := c.dial(logger) if err != nil { return nil, err } ctx, cancel := context.WithTimeout(context.Background(), c.timeout) defer cancel() return c.transactClient.BroadcastTxSync(ctx, &rpctransact.TxEnv...
go
func (c *Client) BroadcastEnvelope(txEnv *txs.Envelope, logger *logging.Logger) (*exec.TxExecution, error) { err := c.dial(logger) if err != nil { return nil, err } ctx, cancel := context.WithTimeout(context.Background(), c.timeout) defer cancel() return c.transactClient.BroadcastTxSync(ctx, &rpctransact.TxEnv...
[ "func", "(", "c", "*", "Client", ")", "BroadcastEnvelope", "(", "txEnv", "*", "txs", ".", "Envelope", ",", "logger", "*", "logging", ".", "Logger", ")", "(", "*", "exec", ".", "TxExecution", ",", "error", ")", "{", "err", ":=", "c", ".", "dial", "(...
// Broadcast envelope - can be locally signed or remote signing will be attempted
[ "Broadcast", "envelope", "-", "can", "be", "locally", "signed", "or", "remote", "signing", "will", "be", "attempted" ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/deploy/def/client.go#L273-L282
train
hyperledger/burrow
core/processes.go
NoConsensusLauncher
func NoConsensusLauncher(kern *Kernel) process.Launcher { return process.Launcher{ Name: NoConsensusProcessName, Enabled: kern.Node == nil, Launch: func() (process.Process, error) { accountState := kern.State nameRegState := kern.State kern.Service = rpc.NewService(accountState, nameRegState, kern.Bl...
go
func NoConsensusLauncher(kern *Kernel) process.Launcher { return process.Launcher{ Name: NoConsensusProcessName, Enabled: kern.Node == nil, Launch: func() (process.Process, error) { accountState := kern.State nameRegState := kern.State kern.Service = rpc.NewService(accountState, nameRegState, kern.Bl...
[ "func", "NoConsensusLauncher", "(", "kern", "*", "Kernel", ")", "process", ".", "Launcher", "{", "return", "process", ".", "Launcher", "{", "Name", ":", "NoConsensusProcessName", ",", "Enabled", ":", "kern", ".", "Node", "==", "nil", ",", "Launch", ":", "f...
// Run a single uncoordinated local state
[ "Run", "a", "single", "uncoordinated", "local", "state" ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/core/processes.go#L87-L107
train
hyperledger/burrow
acm/private_account.go
SigningAccounts
func SigningAccounts(concretePrivateAccounts []*PrivateAccount) []AddressableSigner { signingAccounts := make([]AddressableSigner, len(concretePrivateAccounts)) for i, cpa := range concretePrivateAccounts { signingAccounts[i] = cpa } return signingAccounts }
go
func SigningAccounts(concretePrivateAccounts []*PrivateAccount) []AddressableSigner { signingAccounts := make([]AddressableSigner, len(concretePrivateAccounts)) for i, cpa := range concretePrivateAccounts { signingAccounts[i] = cpa } return signingAccounts }
[ "func", "SigningAccounts", "(", "concretePrivateAccounts", "[", "]", "*", "PrivateAccount", ")", "[", "]", "AddressableSigner", "{", "signingAccounts", ":=", "make", "(", "[", "]", "AddressableSigner", ",", "len", "(", "concretePrivateAccounts", ")", ")", "\n", ...
// Convert slice of ConcretePrivateAccounts to slice of SigningAccounts
[ "Convert", "slice", "of", "ConcretePrivateAccounts", "to", "slice", "of", "SigningAccounts" ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/acm/private_account.go#L99-L105
train
hyperledger/burrow
acm/private_account.go
GeneratePrivateAccount
func GeneratePrivateAccount() (*PrivateAccount, error) { privateKey, err := crypto.GeneratePrivateKey(nil, crypto.CurveTypeEd25519) if err != nil { return nil, err } publicKey := privateKey.GetPublicKey() return ConcretePrivateAccount{ Address: publicKey.GetAddress(), PublicKey: publicKey, PrivateKey: ...
go
func GeneratePrivateAccount() (*PrivateAccount, error) { privateKey, err := crypto.GeneratePrivateKey(nil, crypto.CurveTypeEd25519) if err != nil { return nil, err } publicKey := privateKey.GetPublicKey() return ConcretePrivateAccount{ Address: publicKey.GetAddress(), PublicKey: publicKey, PrivateKey: ...
[ "func", "GeneratePrivateAccount", "(", ")", "(", "*", "PrivateAccount", ",", "error", ")", "{", "privateKey", ",", "err", ":=", "crypto", ".", "GeneratePrivateKey", "(", "nil", ",", "crypto", ".", "CurveTypeEd25519", ")", "\n", "if", "err", "!=", "nil", "{...
// Generates a new account with private key.
[ "Generates", "a", "new", "account", "with", "private", "key", "." ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/acm/private_account.go#L108-L119
train
hyperledger/burrow
acm/private_account.go
GeneratePrivateAccountFromSecret
func GeneratePrivateAccountFromSecret(secret string) *PrivateAccount { privateKey := crypto.PrivateKeyFromSecret(secret, crypto.CurveTypeEd25519) publicKey := privateKey.GetPublicKey() return ConcretePrivateAccount{ Address: publicKey.GetAddress(), PublicKey: publicKey, PrivateKey: privateKey, }.PrivateAc...
go
func GeneratePrivateAccountFromSecret(secret string) *PrivateAccount { privateKey := crypto.PrivateKeyFromSecret(secret, crypto.CurveTypeEd25519) publicKey := privateKey.GetPublicKey() return ConcretePrivateAccount{ Address: publicKey.GetAddress(), PublicKey: publicKey, PrivateKey: privateKey, }.PrivateAc...
[ "func", "GeneratePrivateAccountFromSecret", "(", "secret", "string", ")", "*", "PrivateAccount", "{", "privateKey", ":=", "crypto", ".", "PrivateKeyFromSecret", "(", "secret", ",", "crypto", ".", "CurveTypeEd25519", ")", "\n", "publicKey", ":=", "privateKey", ".", ...
// Generates a new account with private key from SHA256 hash of a secret
[ "Generates", "a", "new", "account", "with", "private", "key", "from", "SHA256", "hash", "of", "a", "secret" ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/acm/private_account.go#L122-L130
train
hyperledger/burrow
cmd/burrow/commands/snatives.go
Snatives
func Snatives(output Output) func(cmd *cli.Cmd) { return func(cmd *cli.Cmd) { contractsOpt := cmd.StringsOpt("c contracts", nil, "Contracts to generate") cmd.Action = func() { contracts := evm.SNativeContracts() // Index of next contract i := 1 for _, contract := range contracts { if len(*contracts...
go
func Snatives(output Output) func(cmd *cli.Cmd) { return func(cmd *cli.Cmd) { contractsOpt := cmd.StringsOpt("c contracts", nil, "Contracts to generate") cmd.Action = func() { contracts := evm.SNativeContracts() // Index of next contract i := 1 for _, contract := range contracts { if len(*contracts...
[ "func", "Snatives", "(", "output", "Output", ")", "func", "(", "cmd", "*", "cli", ".", "Cmd", ")", "{", "return", "func", "(", "cmd", "*", "cli", ".", "Cmd", ")", "{", "contractsOpt", ":=", "cmd", ".", "StringsOpt", "(", "\"", "\"", ",", "nil", "...
// Dump SNative contracts
[ "Dump", "SNative", "contracts" ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/cmd/burrow/commands/snatives.go#L27-L62
train
hyperledger/burrow
storage/rwtree.go
Save
func (rwt *RWTree) Save() ([]byte, int64, error) { // save state at a new version may still be orphaned before we save the version against the hash hash, version, err := rwt.tree.SaveVersion() if err != nil { return nil, 0, fmt.Errorf("could not save RWTree: %v", err) } // Take an immutable reference to the tree...
go
func (rwt *RWTree) Save() ([]byte, int64, error) { // save state at a new version may still be orphaned before we save the version against the hash hash, version, err := rwt.tree.SaveVersion() if err != nil { return nil, 0, fmt.Errorf("could not save RWTree: %v", err) } // Take an immutable reference to the tree...
[ "func", "(", "rwt", "*", "RWTree", ")", "Save", "(", ")", "(", "[", "]", "byte", ",", "int64", ",", "error", ")", "{", "// save state at a new version may still be orphaned before we save the version against the hash", "hash", ",", "version", ",", "err", ":=", "rw...
// Save the current write tree making writes accessible from read tree.
[ "Save", "the", "current", "write", "tree", "making", "writes", "accessible", "from", "read", "tree", "." ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/storage/rwtree.go#L50-L63
train
hyperledger/burrow
execution/evm/stack.go
PushBytes
func (st *Stack) PushBytes(bz []byte) { if len(bz) != 32 { panic("Invalid bytes size: expected 32") } st.Push(LeftPadWord256(bz)) }
go
func (st *Stack) PushBytes(bz []byte) { if len(bz) != 32 { panic("Invalid bytes size: expected 32") } st.Push(LeftPadWord256(bz)) }
[ "func", "(", "st", "*", "Stack", ")", "PushBytes", "(", "bz", "[", "]", "byte", ")", "{", "if", "len", "(", "bz", ")", "!=", "32", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "st", ".", "Push", "(", "LeftPadWord256", "(", "bz", ")", ...
// currently only called after sha3.Sha3
[ "currently", "only", "called", "after", "sha3", ".", "Sha3" ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/execution/evm/stack.go#L74-L79
train
hyperledger/burrow
execution/evm/stack.go
PushBigInt
func (st *Stack) PushBigInt(bigInt *big.Int) Word256 { word := LeftPadWord256(U256(bigInt).Bytes()) st.Push(word) return word }
go
func (st *Stack) PushBigInt(bigInt *big.Int) Word256 { word := LeftPadWord256(U256(bigInt).Bytes()) st.Push(word) return word }
[ "func", "(", "st", "*", "Stack", ")", "PushBigInt", "(", "bigInt", "*", "big", ".", "Int", ")", "Word256", "{", "word", ":=", "LeftPadWord256", "(", "U256", "(", "bigInt", ")", ".", "Bytes", "(", ")", ")", "\n", "st", ".", "Push", "(", "word", ")...
// Pushes the bigInt as a Word256 encoding negative values in 32-byte twos complement and returns the encoded result
[ "Pushes", "the", "bigInt", "as", "a", "Word256", "encoding", "negative", "values", "in", "32", "-", "byte", "twos", "complement", "and", "returns", "the", "encoded", "result" ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/execution/evm/stack.go#L94-L98
train
hyperledger/burrow
execution/evm/stack.go
Peek
func (st *Stack) Peek() Word256 { if st.ptr == 0 { st.pushErr(errors.ErrorCodeDataStackUnderflow) return Zero256 } return st.slice[st.ptr-1] }
go
func (st *Stack) Peek() Word256 { if st.ptr == 0 { st.pushErr(errors.ErrorCodeDataStackUnderflow) return Zero256 } return st.slice[st.ptr-1] }
[ "func", "(", "st", "*", "Stack", ")", "Peek", "(", ")", "Word256", "{", "if", "st", ".", "ptr", "==", "0", "{", "st", ".", "pushErr", "(", "errors", ".", "ErrorCodeDataStackUnderflow", ")", "\n", "return", "Zero256", "\n", "}", "\n", "return", "st", ...
// Not an opcode, costs no gas.
[ "Not", "an", "opcode", "costs", "no", "gas", "." ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/execution/evm/stack.go#L170-L176
train
hyperledger/burrow
acm/acmstate/state_cache.go
NewCache
func NewCache(backend Reader, options ...CacheOption) *Cache { cache := &Cache{ backend: backend, accounts: make(map[crypto.Address]*accountInfo), } for _, option := range options { option(cache) } return cache }
go
func NewCache(backend Reader, options ...CacheOption) *Cache { cache := &Cache{ backend: backend, accounts: make(map[crypto.Address]*accountInfo), } for _, option := range options { option(cache) } return cache }
[ "func", "NewCache", "(", "backend", "Reader", ",", "options", "...", "CacheOption", ")", "*", "Cache", "{", "cache", ":=", "&", "Cache", "{", "backend", ":", "backend", ",", "accounts", ":", "make", "(", "map", "[", "crypto", ".", "Address", "]", "*", ...
// Returns a Cache that wraps an underlying Reader to use on a cache miss, can write to an output Writer // via Sync. Goroutine safe for concurrent access.
[ "Returns", "a", "Cache", "that", "wraps", "an", "underlying", "Reader", "to", "use", "on", "a", "cache", "miss", "can", "write", "to", "an", "output", "Writer", "via", "Sync", ".", "Goroutine", "safe", "for", "concurrent", "access", "." ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/acm/acmstate/state_cache.go#L49-L58
train
hyperledger/burrow
acm/acmstate/state_cache.go
IterateCachedAccount
func (cache *Cache) IterateCachedAccount(consumer func(*acm.Account) (stop bool)) (stopped bool, err error) { // Try cache first for early exit cache.RLock() for _, info := range cache.accounts { if consumer(info.account) { cache.RUnlock() return true, nil } } cache.RUnlock() return false, nil }
go
func (cache *Cache) IterateCachedAccount(consumer func(*acm.Account) (stop bool)) (stopped bool, err error) { // Try cache first for early exit cache.RLock() for _, info := range cache.accounts { if consumer(info.account) { cache.RUnlock() return true, nil } } cache.RUnlock() return false, nil }
[ "func", "(", "cache", "*", "Cache", ")", "IterateCachedAccount", "(", "consumer", "func", "(", "*", "acm", ".", "Account", ")", "(", "stop", "bool", ")", ")", "(", "stopped", "bool", ",", "err", "error", ")", "{", "// Try cache first for early exit", "cach...
// Iterates over all cached accounts first in cache and then in backend until consumer returns true for 'stop'
[ "Iterates", "over", "all", "cached", "accounts", "first", "in", "cache", "and", "then", "in", "backend", "until", "consumer", "returns", "true", "for", "stop" ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/acm/acmstate/state_cache.go#L125-L136
train
hyperledger/burrow
acm/acmstate/state_cache.go
IterateCachedStorage
func (cache *Cache) IterateCachedStorage(address crypto.Address, consumer func(key, value binary.Word256) error) error { accInfo, err := cache.get(address) if err != nil { return err } accInfo.RLock() // Try cache first for early exit for key, value := range accInfo.storage { if err := consumer(key, value); ...
go
func (cache *Cache) IterateCachedStorage(address crypto.Address, consumer func(key, value binary.Word256) error) error { accInfo, err := cache.get(address) if err != nil { return err } accInfo.RLock() // Try cache first for early exit for key, value := range accInfo.storage { if err := consumer(key, value); ...
[ "func", "(", "cache", "*", "Cache", ")", "IterateCachedStorage", "(", "address", "crypto", ".", "Address", ",", "consumer", "func", "(", "key", ",", "value", "binary", ".", "Word256", ")", "error", ")", "error", "{", "accInfo", ",", "err", ":=", "cache",...
// Iterates over all cached storage items first in cache and then in backend until consumer returns true for 'stop'
[ "Iterates", "over", "all", "cached", "storage", "items", "first", "in", "cache", "and", "then", "in", "backend", "until", "consumer", "returns", "true", "for", "stop" ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/acm/acmstate/state_cache.go#L188-L204
train
hyperledger/burrow
acm/acmstate/state_cache.go
Sync
func (cache *Cache) Sync(st Writer) error { if cache.readonly { // Sync is (should be) a no-op for read-only - any modifications should have been caught in respective methods return nil } cache.Lock() defer cache.Unlock() var addresses crypto.Addresses for address := range cache.accounts { addresses = appen...
go
func (cache *Cache) Sync(st Writer) error { if cache.readonly { // Sync is (should be) a no-op for read-only - any modifications should have been caught in respective methods return nil } cache.Lock() defer cache.Unlock() var addresses crypto.Addresses for address := range cache.accounts { addresses = appen...
[ "func", "(", "cache", "*", "Cache", ")", "Sync", "(", "st", "Writer", ")", "error", "{", "if", "cache", ".", "readonly", "{", "// Sync is (should be) a no-op for read-only - any modifications should have been caught in respective methods", "return", "nil", "\n", "}", "\...
// Syncs changes to the backend in deterministic order. Sends storage updates before updating // the account they belong so that storage values can be taken account of in the update.
[ "Syncs", "changes", "to", "the", "backend", "in", "deterministic", "order", ".", "Sends", "storage", "updates", "before", "updating", "the", "account", "they", "belong", "so", "that", "storage", "values", "can", "be", "taken", "account", "of", "in", "the", "...
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/acm/acmstate/state_cache.go#L208-L254
train
hyperledger/burrow
logging/logconfig/filter.go
matchLogLine
func matchLogLine(keyvals []interface{}, keyRegexes, valueRegexes []*regexp.Regexp, matchAll bool) bool { all := matchAll // We should be passed an aligned list of keyRegexes and valueRegexes, but since we can't error here we'll guard // against a failure of the caller to pass valid arguments length := len(keyRegex...
go
func matchLogLine(keyvals []interface{}, keyRegexes, valueRegexes []*regexp.Regexp, matchAll bool) bool { all := matchAll // We should be passed an aligned list of keyRegexes and valueRegexes, but since we can't error here we'll guard // against a failure of the caller to pass valid arguments length := len(keyRegex...
[ "func", "matchLogLine", "(", "keyvals", "[", "]", "interface", "{", "}", ",", "keyRegexes", ",", "valueRegexes", "[", "]", "*", "regexp", ".", "Regexp", ",", "matchAll", "bool", ")", "bool", "{", "all", ":=", "matchAll", "\n", "// We should be passed an alig...
// matchLogLine tries to match a log line by trying to match each key value pair with each pair of key value regexes // if matchAll is true then matchLogLine returns true iff every key value regexes finds a match or the line or regexes // are empty
[ "matchLogLine", "tries", "to", "match", "a", "log", "line", "by", "trying", "to", "match", "each", "key", "value", "pair", "with", "each", "pair", "of", "key", "value", "regexes", "if", "matchAll", "is", "true", "then", "matchLogLine", "returns", "true", "...
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/logging/logconfig/filter.go#L54-L71
train
hyperledger/burrow
genesis/genesis.go
JSONBytes
func (genesisDoc *GenesisDoc) JSONBytes() ([]byte, error) { // Just in case genesisDoc.GenesisTime = genesisDoc.GenesisTime.UTC() return json.MarshalIndent(genesisDoc, "", "\t") }
go
func (genesisDoc *GenesisDoc) JSONBytes() ([]byte, error) { // Just in case genesisDoc.GenesisTime = genesisDoc.GenesisTime.UTC() return json.MarshalIndent(genesisDoc, "", "\t") }
[ "func", "(", "genesisDoc", "*", "GenesisDoc", ")", "JSONBytes", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "// Just in case", "genesisDoc", ".", "GenesisTime", "=", "genesisDoc", ".", "GenesisTime", ".", "UTC", "(", ")", "\n", "return", "js...
// JSONBytes returns the JSON canonical bytes for a given GenesisDoc or an error.
[ "JSONBytes", "returns", "the", "JSON", "canonical", "bytes", "for", "a", "given", "GenesisDoc", "or", "an", "error", "." ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/genesis/genesis.go#L91-L95
train
hyperledger/burrow
genesis/genesis.go
Clone
func (genesisAccount *Account) Clone() Account { // clone the account permissions return Account{ BasicAccount: BasicAccount{ Address: genesisAccount.Address, Amount: genesisAccount.Amount, }, Name: genesisAccount.Name, Permissions: genesisAccount.Permissions.Clone(), } }
go
func (genesisAccount *Account) Clone() Account { // clone the account permissions return Account{ BasicAccount: BasicAccount{ Address: genesisAccount.Address, Amount: genesisAccount.Amount, }, Name: genesisAccount.Name, Permissions: genesisAccount.Permissions.Clone(), } }
[ "func", "(", "genesisAccount", "*", "Account", ")", "Clone", "(", ")", "Account", "{", "// clone the account permissions", "return", "Account", "{", "BasicAccount", ":", "BasicAccount", "{", "Address", ":", "genesisAccount", ".", "Address", ",", "Amount", ":", "...
// Clone clones the genesis account
[ "Clone", "clones", "the", "genesis", "account" ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/genesis/genesis.go#L151-L161
train
hyperledger/burrow
genesis/genesis.go
Clone
func (gv *Validator) Clone() Validator { // clone the addresses to unbond to unbondToClone := make([]BasicAccount, len(gv.UnbondTo)) for i, basicAccount := range gv.UnbondTo { unbondToClone[i] = basicAccount.Clone() } return Validator{ BasicAccount: BasicAccount{ PublicKey: gv.PublicKey, Amount: gv.Am...
go
func (gv *Validator) Clone() Validator { // clone the addresses to unbond to unbondToClone := make([]BasicAccount, len(gv.UnbondTo)) for i, basicAccount := range gv.UnbondTo { unbondToClone[i] = basicAccount.Clone() } return Validator{ BasicAccount: BasicAccount{ PublicKey: gv.PublicKey, Amount: gv.Am...
[ "func", "(", "gv", "*", "Validator", ")", "Clone", "(", ")", "Validator", "{", "// clone the addresses to unbond to", "unbondToClone", ":=", "make", "(", "[", "]", "BasicAccount", ",", "len", "(", "gv", ".", "UnbondTo", ")", ")", "\n", "for", "i", ",", "...
// Clone clones the genesis validator
[ "Clone", "clones", "the", "genesis", "validator" ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/genesis/genesis.go#L185-L200
train
hyperledger/burrow
genesis/genesis.go
MakeGenesisDocFromAccounts
func MakeGenesisDocFromAccounts(chainName string, salt []byte, genesisTime time.Time, accounts map[string]*acm.Account, validators map[string]*validator.Validator) *GenesisDoc { // Establish deterministic order of accounts by name so we obtain identical GenesisDoc // from identical input names := make([]string, 0,...
go
func MakeGenesisDocFromAccounts(chainName string, salt []byte, genesisTime time.Time, accounts map[string]*acm.Account, validators map[string]*validator.Validator) *GenesisDoc { // Establish deterministic order of accounts by name so we obtain identical GenesisDoc // from identical input names := make([]string, 0,...
[ "func", "MakeGenesisDocFromAccounts", "(", "chainName", "string", ",", "salt", "[", "]", "byte", ",", "genesisTime", "time", ".", "Time", ",", "accounts", "map", "[", "string", "]", "*", "acm", ".", "Account", ",", "validators", "map", "[", "string", "]", ...
// MakeGenesisDocFromAccounts takes a chainName and a slice of pointers to Account, // and a slice of pointers to Validator to construct a GenesisDoc, or returns an error on // failure. In particular MakeGenesisDocFromAccount uses the local time as a // timestamp for the GenesisDoc.
[ "MakeGenesisDocFromAccounts", "takes", "a", "chainName", "and", "a", "slice", "of", "pointers", "to", "Account", "and", "a", "slice", "of", "pointers", "to", "Validator", "to", "construct", "a", "GenesisDoc", "or", "returns", "an", "error", "on", "failure", "....
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/genesis/genesis.go#L217-L266
train
hyperledger/burrow
acm/bytecode.go
Tokens
func (bc Bytecode) Tokens() ([]string, error) { // Overestimate of capacity in the presence of pushes tokens := make([]string, 0, len(bc)) for i := 0; i < len(bc); i++ { op, ok := asm.GetOpCode(bc[i]) if !ok { return tokens, fmt.Errorf("did not recognise byte %#x at position %v as an OpCode:\n %s", bc[i]...
go
func (bc Bytecode) Tokens() ([]string, error) { // Overestimate of capacity in the presence of pushes tokens := make([]string, 0, len(bc)) for i := 0; i < len(bc); i++ { op, ok := asm.GetOpCode(bc[i]) if !ok { return tokens, fmt.Errorf("did not recognise byte %#x at position %v as an OpCode:\n %s", bc[i]...
[ "func", "(", "bc", "Bytecode", ")", "Tokens", "(", ")", "(", "[", "]", "string", ",", "error", ")", "{", "// Overestimate of capacity in the presence of pushes", "tokens", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "bc", ")", ")", ...
// Tokenises the bytecode into opcodes and values
[ "Tokenises", "the", "bytecode", "into", "opcodes", "and", "values" ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/acm/bytecode.go#L94-L118
train
hyperledger/burrow
event/query/builder.go
NewBuilder
func NewBuilder(queries ...string) *Builder { qb := new(Builder) qb.queryString = qb.and(stringIterator(queries...)) return qb }
go
func NewBuilder(queries ...string) *Builder { qb := new(Builder) qb.queryString = qb.and(stringIterator(queries...)) return qb }
[ "func", "NewBuilder", "(", "queries", "...", "string", ")", "*", "Builder", "{", "qb", ":=", "new", "(", "Builder", ")", "\n", "qb", ".", "queryString", "=", "qb", ".", "and", "(", "stringIterator", "(", "queries", "...", ")", ")", "\n", "return", "q...
// Creates a new query builder with a base query that is the conjunction of all queries passed
[ "Creates", "a", "new", "query", "builder", "with", "a", "base", "query", "that", "is", "the", "conjunction", "of", "all", "queries", "passed" ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/event/query/builder.go#L95-L99
train
hyperledger/burrow
event/query/builder.go
And
func (qb *Builder) And(queryBuilders ...*Builder) *Builder { return NewBuilder(qb.and(queryBuilderIterator(queryBuilders...))) }
go
func (qb *Builder) And(queryBuilders ...*Builder) *Builder { return NewBuilder(qb.and(queryBuilderIterator(queryBuilders...))) }
[ "func", "(", "qb", "*", "Builder", ")", "And", "(", "queryBuilders", "...", "*", "Builder", ")", "*", "Builder", "{", "return", "NewBuilder", "(", "qb", ".", "and", "(", "queryBuilderIterator", "(", "queryBuilders", "...", ")", ")", ")", "\n", "}" ]
// Creates the conjunction of Builder and rightQuery
[ "Creates", "the", "conjunction", "of", "Builder", "and", "rightQuery" ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/event/query/builder.go#L120-L122
train
hyperledger/burrow
event/query/builder.go
AndEquals
func (qb *Builder) AndEquals(tag string, operand interface{}) *Builder { qb.condition.Tag = tag qb.condition.Op = equalString qb.condition.Operand = operandString(operand) return NewBuilder(qb.and(stringIterator(qb.conditionString()))) }
go
func (qb *Builder) AndEquals(tag string, operand interface{}) *Builder { qb.condition.Tag = tag qb.condition.Op = equalString qb.condition.Operand = operandString(operand) return NewBuilder(qb.and(stringIterator(qb.conditionString()))) }
[ "func", "(", "qb", "*", "Builder", ")", "AndEquals", "(", "tag", "string", ",", "operand", "interface", "{", "}", ")", "*", "Builder", "{", "qb", ".", "condition", ".", "Tag", "=", "tag", "\n", "qb", ".", "condition", ".", "Op", "=", "equalString", ...
// Creates the conjunction of Builder and tag = operand
[ "Creates", "the", "conjunction", "of", "Builder", "and", "tag", "=", "operand" ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/event/query/builder.go#L125-L130
train
hyperledger/burrow
event/query/builder.go
stringIterator
func stringIterator(strs ...string) func(func(string)) { return func(callback func(string)) { for _, s := range strs { callback(s) } } }
go
func stringIterator(strs ...string) func(func(string)) { return func(callback func(string)) { for _, s := range strs { callback(s) } } }
[ "func", "stringIterator", "(", "strs", "...", "string", ")", "func", "(", "func", "(", "string", ")", ")", "{", "return", "func", "(", "callback", "func", "(", "string", ")", ")", "{", "for", "_", ",", "s", ":=", "range", "strs", "{", "callback", "...
// Iterators over some strings
[ "Iterators", "over", "some", "strings" ]
59993f5aad71a8e16ab6ed4e57e138e2398eae4e
https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/event/query/builder.go#L260-L266
train
mvdan/sh
syntax/parser.go
NewParser
func NewParser(options ...func(*Parser)) *Parser { p := &Parser{helperBuf: new(bytes.Buffer)} for _, opt := range options { opt(p) } return p }
go
func NewParser(options ...func(*Parser)) *Parser { p := &Parser{helperBuf: new(bytes.Buffer)} for _, opt := range options { opt(p) } return p }
[ "func", "NewParser", "(", "options", "...", "func", "(", "*", "Parser", ")", ")", "*", "Parser", "{", "p", ":=", "&", "Parser", "{", "helperBuf", ":", "new", "(", "bytes", ".", "Buffer", ")", "}", "\n", "for", "_", ",", "opt", ":=", "range", "opt...
// NewParser allocates a new Parser and applies any number of options.
[ "NewParser", "allocates", "a", "new", "Parser", "and", "applies", "any", "number", "of", "options", "." ]
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/syntax/parser.go#L69-L75
train
mvdan/sh
syntax/parser.go
Parse
func (p *Parser) Parse(r io.Reader, name string) (*File, error) { p.reset() p.f = &File{Name: name} p.src = r p.rune() p.next() p.f.Stmts, p.f.Last = p.stmtList() if p.err == nil { // EOF immediately after heredoc word so no newline to // trigger it p.doHeredocs() } return p.f, p.err }
go
func (p *Parser) Parse(r io.Reader, name string) (*File, error) { p.reset() p.f = &File{Name: name} p.src = r p.rune() p.next() p.f.Stmts, p.f.Last = p.stmtList() if p.err == nil { // EOF immediately after heredoc word so no newline to // trigger it p.doHeredocs() } return p.f, p.err }
[ "func", "(", "p", "*", "Parser", ")", "Parse", "(", "r", "io", ".", "Reader", ",", "name", "string", ")", "(", "*", "File", ",", "error", ")", "{", "p", ".", "reset", "(", ")", "\n", "p", ".", "f", "=", "&", "File", "{", "Name", ":", "name"...
// Parse reads and parses a shell program with an optional name. It // returns the parsed program if no issues were encountered. Otherwise, // an error is returned. Reads from r are buffered. // // Parse can be called more than once, but not concurrently. That is, a // Parser can be reused once it is done working.
[ "Parse", "reads", "and", "parses", "a", "shell", "program", "with", "an", "optional", "name", ".", "It", "returns", "the", "parsed", "program", "if", "no", "issues", "were", "encountered", ".", "Otherwise", "an", "error", "is", "returned", ".", "Reads", "f...
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/syntax/parser.go#L83-L96
train
mvdan/sh
syntax/parser.go
Stmts
func (p *Parser) Stmts(r io.Reader, fn func(*Stmt) bool) error { p.reset() p.f = &File{} p.src = r p.rune() p.next() p.stmts(fn) if p.err == nil { // EOF immediately after heredoc word so no newline to // trigger it p.doHeredocs() } return p.err }
go
func (p *Parser) Stmts(r io.Reader, fn func(*Stmt) bool) error { p.reset() p.f = &File{} p.src = r p.rune() p.next() p.stmts(fn) if p.err == nil { // EOF immediately after heredoc word so no newline to // trigger it p.doHeredocs() } return p.err }
[ "func", "(", "p", "*", "Parser", ")", "Stmts", "(", "r", "io", ".", "Reader", ",", "fn", "func", "(", "*", "Stmt", ")", "bool", ")", "error", "{", "p", ".", "reset", "(", ")", "\n", "p", ".", "f", "=", "&", "File", "{", "}", "\n", "p", "....
// Stmts reads and parses statements one at a time, calling a function // each time one is parsed. If the function returns false, parsing is // stopped and the function is not called again.
[ "Stmts", "reads", "and", "parses", "statements", "one", "at", "a", "time", "calling", "a", "function", "each", "time", "one", "is", "parsed", ".", "If", "the", "function", "returns", "false", "parsing", "is", "stopped", "and", "the", "function", "is", "not...
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/syntax/parser.go#L101-L114
train
mvdan/sh
syntax/parser.go
Words
func (p *Parser) Words(r io.Reader, fn func(*Word) bool) error { p.reset() p.f = &File{} p.src = r p.rune() p.next() for { p.got(_Newl) w := p.getWord() if w == nil { if p.tok != _EOF { p.curErr("%s is not a valid word", p.tok) } return p.err } if !fn(w) { return nil } } }
go
func (p *Parser) Words(r io.Reader, fn func(*Word) bool) error { p.reset() p.f = &File{} p.src = r p.rune() p.next() for { p.got(_Newl) w := p.getWord() if w == nil { if p.tok != _EOF { p.curErr("%s is not a valid word", p.tok) } return p.err } if !fn(w) { return nil } } }
[ "func", "(", "p", "*", "Parser", ")", "Words", "(", "r", "io", ".", "Reader", ",", "fn", "func", "(", "*", "Word", ")", "bool", ")", "error", "{", "p", ".", "reset", "(", ")", "\n", "p", ".", "f", "=", "&", "File", "{", "}", "\n", "p", "....
// Words reads and parses words one at a time, calling a function each time one // is parsed. If the function returns false, parsing is stopped and the function // is not called again. // // Newlines are skipped, meaning that multi-line input will work fine. If the // parser encounters a token that isn't a word, such a...
[ "Words", "reads", "and", "parses", "words", "one", "at", "a", "time", "calling", "a", "function", "each", "time", "one", "is", "parsed", ".", "If", "the", "function", "returns", "false", "parsing", "is", "stopped", "and", "the", "function", "is", "not", ...
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/syntax/parser.go#L204-L223
train
mvdan/sh
syntax/parser.go
Document
func (p *Parser) Document(r io.Reader) (*Word, error) { p.reset() p.f = &File{} p.src = r p.rune() p.quote = hdocBody p.hdocStop = []byte("MVDAN_CC_SH_SYNTAX_EOF") p.parsingDoc = true p.next() w := p.getWord() return w, p.err }
go
func (p *Parser) Document(r io.Reader) (*Word, error) { p.reset() p.f = &File{} p.src = r p.rune() p.quote = hdocBody p.hdocStop = []byte("MVDAN_CC_SH_SYNTAX_EOF") p.parsingDoc = true p.next() w := p.getWord() return w, p.err }
[ "func", "(", "p", "*", "Parser", ")", "Document", "(", "r", "io", ".", "Reader", ")", "(", "*", "Word", ",", "error", ")", "{", "p", ".", "reset", "(", ")", "\n", "p", ".", "f", "=", "&", "File", "{", "}", "\n", "p", ".", "src", "=", "r",...
// Document parses a single here-document word. That is, it parses the input as // if they were lines following a <<EOF redirection. // // In practice, this is the same as parsing the input as if it were within // double quotes, but without having to escape all double quote characters. // Similarly, the here-document w...
[ "Document", "parses", "a", "single", "here", "-", "document", "word", ".", "That", "is", "it", "parses", "the", "input", "as", "if", "they", "were", "lines", "following", "a", "<<EOF", "redirection", ".", "In", "practice", "this", "is", "the", "same", "a...
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/syntax/parser.go#L232-L243
train
mvdan/sh
syntax/parser.go
Incomplete
func (p *Parser) Incomplete() bool { // If we're in a quote state other than noState, we're parsing a node // such as a double-quoted string. // If there are any open statements, we need to finish them. // If we're constructing a literal, we need to finish it. return p.quote != noState || p.openStmts > 0 || p.litB...
go
func (p *Parser) Incomplete() bool { // If we're in a quote state other than noState, we're parsing a node // such as a double-quoted string. // If there are any open statements, we need to finish them. // If we're constructing a literal, we need to finish it. return p.quote != noState || p.openStmts > 0 || p.litB...
[ "func", "(", "p", "*", "Parser", ")", "Incomplete", "(", ")", "bool", "{", "// If we're in a quote state other than noState, we're parsing a node", "// such as a double-quoted string.", "// If there are any open statements, we need to finish them.", "// If we're constructing a literal, w...
// Incomplete reports whether the parser is waiting to read more bytes because // it needs to finish properly parsing a statement. // // It is only safe to call while the parser is blocked on a read. For an example // use case, see the documentation for Parser.Interactive.
[ "Incomplete", "reports", "whether", "the", "parser", "is", "waiting", "to", "read", "more", "bytes", "because", "it", "needs", "to", "finish", "properly", "parsing", "a", "statement", ".", "It", "is", "only", "safe", "to", "call", "while", "the", "parser", ...
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/syntax/parser.go#L322-L328
train
mvdan/sh
syntax/parser.go
IsIncomplete
func IsIncomplete(err error) bool { perr, ok := err.(ParseError) return ok && perr.Incomplete }
go
func IsIncomplete(err error) bool { perr, ok := err.(ParseError) return ok && perr.Incomplete }
[ "func", "IsIncomplete", "(", "err", "error", ")", "bool", "{", "perr", ",", "ok", ":=", "err", ".", "(", "ParseError", ")", "\n", "return", "ok", "&&", "perr", ".", "Incomplete", "\n", "}" ]
// IsIncomplete reports whether a Parser error could have been avoided with // extra input bytes. For example, if an io.EOF was encountered while there was // an unclosed quote or parenthesis.
[ "IsIncomplete", "reports", "whether", "a", "Parser", "error", "could", "have", "been", "avoided", "with", "extra", "input", "bytes", ".", "For", "example", "if", "an", "io", ".", "EOF", "was", "encountered", "while", "there", "was", "an", "unclosed", "quote"...
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/syntax/parser.go#L653-L656
train
mvdan/sh
syntax/parser.go
ValidName
func ValidName(val string) bool { if val == "" { return false } for i, r := range val { switch { case 'a' <= r && r <= 'z': case 'A' <= r && r <= 'Z': case r == '_': case i > 0 && '0' <= r && r <= '9': default: return false } } return true }
go
func ValidName(val string) bool { if val == "" { return false } for i, r := range val { switch { case 'a' <= r && r <= 'z': case 'A' <= r && r <= 'Z': case r == '_': case i > 0 && '0' <= r && r <= '9': default: return false } } return true }
[ "func", "ValidName", "(", "val", "string", ")", "bool", "{", "if", "val", "==", "\"", "\"", "{", "return", "false", "\n", "}", "\n", "for", "i", ",", "r", ":=", "range", "val", "{", "switch", "{", "case", "'a'", "<=", "r", "&&", "r", "<=", "'z'...
// ValidName returns whether val is a valid name as per the POSIX spec.
[ "ValidName", "returns", "whether", "val", "is", "a", "valid", "name", "as", "per", "the", "POSIX", "spec", "." ]
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/syntax/parser.go#L1499-L1514
train
mvdan/sh
expand/environ.go
String
func (v Variable) String() string { switch v.Kind { case String: return v.Str case Indexed: if len(v.List) > 0 { return v.List[0] } case Associative: // nothing to do } return "" }
go
func (v Variable) String() string { switch v.Kind { case String: return v.Str case Indexed: if len(v.List) > 0 { return v.List[0] } case Associative: // nothing to do } return "" }
[ "func", "(", "v", "Variable", ")", "String", "(", ")", "string", "{", "switch", "v", ".", "Kind", "{", "case", "String", ":", "return", "v", ".", "Str", "\n", "case", "Indexed", ":", "if", "len", "(", "v", ".", "List", ")", ">", "0", "{", "retu...
// String returns the variable's value as a string. In general, this only makes // sense if the variable has a string value or no value at all.
[ "String", "returns", "the", "variable", "s", "value", "as", "a", "string", ".", "In", "general", "this", "only", "makes", "sense", "if", "the", "variable", "has", "a", "string", "value", "or", "no", "value", "at", "all", "." ]
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/expand/environ.go#L88-L100
train
mvdan/sh
expand/environ.go
Resolve
func (v Variable) Resolve(env Environ) (string, Variable) { name := "" for i := 0; i < maxNameRefDepth; i++ { if v.Kind != NameRef { return name, v } name = v.Str // keep name for the next iteration v = env.Get(name) } return name, Variable{} }
go
func (v Variable) Resolve(env Environ) (string, Variable) { name := "" for i := 0; i < maxNameRefDepth; i++ { if v.Kind != NameRef { return name, v } name = v.Str // keep name for the next iteration v = env.Get(name) } return name, Variable{} }
[ "func", "(", "v", "Variable", ")", "Resolve", "(", "env", "Environ", ")", "(", "string", ",", "Variable", ")", "{", "name", ":=", "\"", "\"", "\n", "for", "i", ":=", "0", ";", "i", "<", "maxNameRefDepth", ";", "i", "++", "{", "if", "v", ".", "K...
// Resolve follows a number of nameref variables, returning the last reference // name that was followed and the variable that it points to.
[ "Resolve", "follows", "a", "number", "of", "nameref", "variables", "returning", "the", "last", "reference", "name", "that", "was", "followed", "and", "the", "variable", "that", "it", "points", "to", "." ]
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/expand/environ.go#L109-L119
train
mvdan/sh
expand/environ.go
listEnvironWithUpper
func listEnvironWithUpper(upper bool, pairs ...string) Environ { list := append([]string{}, pairs...) if upper { // Uppercase before sorting, so that we can remove duplicates // without the need for linear search nor a map. for i, s := range list { if sep := strings.IndexByte(s, '='); sep > 0 { list[i] =...
go
func listEnvironWithUpper(upper bool, pairs ...string) Environ { list := append([]string{}, pairs...) if upper { // Uppercase before sorting, so that we can remove duplicates // without the need for linear search nor a map. for i, s := range list { if sep := strings.IndexByte(s, '='); sep > 0 { list[i] =...
[ "func", "listEnvironWithUpper", "(", "upper", "bool", ",", "pairs", "...", "string", ")", "Environ", "{", "list", ":=", "append", "(", "[", "]", "string", "{", "}", ",", "pairs", "...", ")", "\n", "if", "upper", "{", "// Uppercase before sorting, so that we ...
// listEnvironWithUpper implements ListEnviron, but letting the tests specify // whether to uppercase all names or not.
[ "listEnvironWithUpper", "implements", "ListEnviron", "but", "letting", "the", "tests", "specify", "whether", "to", "uppercase", "all", "names", "or", "not", "." ]
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/expand/environ.go#L153-L184
train
mvdan/sh
interp/perm_unix.go
hasPermissionToDir
func hasPermissionToDir(info os.FileInfo) bool { user, err := user.Current() if err != nil { return true } uid, _ := strconv.Atoi(user.Uid) // super-user if uid == 0 { return true } st, _ := info.Sys().(*syscall.Stat_t) if st == nil { return true } perm := info.Mode().Perm() // user (u) if perm&0100...
go
func hasPermissionToDir(info os.FileInfo) bool { user, err := user.Current() if err != nil { return true } uid, _ := strconv.Atoi(user.Uid) // super-user if uid == 0 { return true } st, _ := info.Sys().(*syscall.Stat_t) if st == nil { return true } perm := info.Mode().Perm() // user (u) if perm&0100...
[ "func", "hasPermissionToDir", "(", "info", "os", ".", "FileInfo", ")", "bool", "{", "user", ",", "err", ":=", "user", ".", "Current", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "true", "\n", "}", "\n", "uid", ",", "_", ":=", "strconv"...
// hasPermissionToDir returns if the OS current user has execute permission // to the given directory
[ "hasPermissionToDir", "returns", "if", "the", "OS", "current", "user", "has", "execute", "permission", "to", "the", "given", "directory" ]
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/interp/perm_unix.go#L17-L49
train
mvdan/sh
shell/source.go
SourceFile
func SourceFile(ctx context.Context, path string) (map[string]expand.Variable, error) { f, err := os.Open(path) if err != nil { return nil, fmt.Errorf("could not open: %v", err) } defer f.Close() file, err := syntax.NewParser().Parse(f, path) if err != nil { return nil, fmt.Errorf("could not parse: %v", err) ...
go
func SourceFile(ctx context.Context, path string) (map[string]expand.Variable, error) { f, err := os.Open(path) if err != nil { return nil, fmt.Errorf("could not open: %v", err) } defer f.Close() file, err := syntax.NewParser().Parse(f, path) if err != nil { return nil, fmt.Errorf("could not parse: %v", err) ...
[ "func", "SourceFile", "(", "ctx", "context", ".", "Context", ",", "path", "string", ")", "(", "map", "[", "string", "]", "expand", ".", "Variable", ",", "error", ")", "{", "f", ",", "err", ":=", "os", ".", "Open", "(", "path", ")", "\n", "if", "e...
// SourceFile sources a shell file from disk and returns the variables // declared in it. It is a convenience function that uses a default shell // parser, parses a file from disk, and calls SourceNode. // // This function should be used with caution, as it can interpret arbitrary // code. Untrusted shell programs shou...
[ "SourceFile", "sources", "a", "shell", "file", "from", "disk", "and", "returns", "the", "variables", "declared", "in", "it", ".", "It", "is", "a", "convenience", "function", "that", "uses", "a", "default", "shell", "parser", "parses", "a", "file", "from", ...
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/shell/source.go#L23-L34
train
mvdan/sh
interp/interp.go
New
func New(opts ...func(*Runner) error) (*Runner, error) { r := &Runner{usedNew: true} r.dirStack = r.dirBootstrap[:0] for _, opt := range opts { if err := opt(r); err != nil { return nil, err } } // Set the default fallbacks, if necessary. if r.Env == nil { Env(nil)(r) } if r.Dir == "" { if err := Dir...
go
func New(opts ...func(*Runner) error) (*Runner, error) { r := &Runner{usedNew: true} r.dirStack = r.dirBootstrap[:0] for _, opt := range opts { if err := opt(r); err != nil { return nil, err } } // Set the default fallbacks, if necessary. if r.Env == nil { Env(nil)(r) } if r.Dir == "" { if err := Dir...
[ "func", "New", "(", "opts", "...", "func", "(", "*", "Runner", ")", "error", ")", "(", "*", "Runner", ",", "error", ")", "{", "r", ":=", "&", "Runner", "{", "usedNew", ":", "true", "}", "\n", "r", ".", "dirStack", "=", "r", ".", "dirBootstrap", ...
// New creates a new Runner, applying a number of options. If applying any of // the options results in an error, it is returned. // // Any unset options fall back to their defaults. For example, not supplying the // environment falls back to the process's environment, and not supplying the // standard output writer me...
[ "New", "creates", "a", "new", "Runner", "applying", "a", "number", "of", "options", ".", "If", "applying", "any", "of", "the", "options", "results", "in", "an", "error", "it", "is", "returned", ".", "Any", "unset", "options", "fall", "back", "to", "their...
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/interp/interp.go#L34-L61
train
mvdan/sh
interp/interp.go
Env
func Env(env expand.Environ) func(*Runner) error { return func(r *Runner) error { if env == nil { env = expand.ListEnviron(os.Environ()...) } r.Env = env return nil } }
go
func Env(env expand.Environ) func(*Runner) error { return func(r *Runner) error { if env == nil { env = expand.ListEnviron(os.Environ()...) } r.Env = env return nil } }
[ "func", "Env", "(", "env", "expand", ".", "Environ", ")", "func", "(", "*", "Runner", ")", "error", "{", "return", "func", "(", "r", "*", "Runner", ")", "error", "{", "if", "env", "==", "nil", "{", "env", "=", "expand", ".", "ListEnviron", "(", "...
// Env sets the interpreter's environment. If nil, a copy of the current // process's environment is used.
[ "Env", "sets", "the", "interpreter", "s", "environment", ".", "If", "nil", "a", "copy", "of", "the", "current", "process", "s", "environment", "is", "used", "." ]
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/interp/interp.go#L181-L189
train
mvdan/sh
interp/interp.go
Dir
func Dir(path string) func(*Runner) error { return func(r *Runner) error { if path == "" { path, err := os.Getwd() if err != nil { return fmt.Errorf("could not get current dir: %v", err) } r.Dir = path return nil } path, err := filepath.Abs(path) if err != nil { return fmt.Errorf("could n...
go
func Dir(path string) func(*Runner) error { return func(r *Runner) error { if path == "" { path, err := os.Getwd() if err != nil { return fmt.Errorf("could not get current dir: %v", err) } r.Dir = path return nil } path, err := filepath.Abs(path) if err != nil { return fmt.Errorf("could n...
[ "func", "Dir", "(", "path", "string", ")", "func", "(", "*", "Runner", ")", "error", "{", "return", "func", "(", "r", "*", "Runner", ")", "error", "{", "if", "path", "==", "\"", "\"", "{", "path", ",", "err", ":=", "os", ".", "Getwd", "(", ")",...
// Dir sets the interpreter's working directory. If empty, the process's current // directory is used.
[ "Dir", "sets", "the", "interpreter", "s", "working", "directory", ".", "If", "empty", "the", "process", "s", "current", "directory", "is", "used", "." ]
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/interp/interp.go#L193-L217
train
mvdan/sh
interp/interp.go
Module
func Module(mod ModuleFunc) func(*Runner) error { return func(r *Runner) error { switch mod := mod.(type) { case ModuleExec: if mod == nil { mod = DefaultExec } r.Exec = mod case ModuleOpen: if mod == nil { mod = DefaultOpen } r.Open = mod default: return fmt.Errorf("unknown module...
go
func Module(mod ModuleFunc) func(*Runner) error { return func(r *Runner) error { switch mod := mod.(type) { case ModuleExec: if mod == nil { mod = DefaultExec } r.Exec = mod case ModuleOpen: if mod == nil { mod = DefaultOpen } r.Open = mod default: return fmt.Errorf("unknown module...
[ "func", "Module", "(", "mod", "ModuleFunc", ")", "func", "(", "*", "Runner", ")", "error", "{", "return", "func", "(", "r", "*", "Runner", ")", "error", "{", "switch", "mod", ":=", "mod", ".", "(", "type", ")", "{", "case", "ModuleExec", ":", "if",...
// Module sets an interpreter module, which can be ModuleExec or ModuleOpen. If // the value is nil, the default module implementation is used.
[ "Module", "sets", "an", "interpreter", "module", "which", "can", "be", "ModuleExec", "or", "ModuleOpen", ".", "If", "the", "value", "is", "nil", "the", "default", "module", "implementation", "is", "used", "." ]
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/interp/interp.go#L283-L301
train
mvdan/sh
interp/interp.go
StdIO
func StdIO(in io.Reader, out, err io.Writer) func(*Runner) error { return func(r *Runner) error { r.Stdin = in if out == nil { out = ioutil.Discard } r.Stdout = out if err == nil { err = ioutil.Discard } r.Stderr = err return nil } }
go
func StdIO(in io.Reader, out, err io.Writer) func(*Runner) error { return func(r *Runner) error { r.Stdin = in if out == nil { out = ioutil.Discard } r.Stdout = out if err == nil { err = ioutil.Discard } r.Stderr = err return nil } }
[ "func", "StdIO", "(", "in", "io", ".", "Reader", ",", "out", ",", "err", "io", ".", "Writer", ")", "func", "(", "*", "Runner", ")", "error", "{", "return", "func", "(", "r", "*", "Runner", ")", "error", "{", "r", ".", "Stdin", "=", "in", "\n", ...
// StdIO configures an interpreter's standard input, standard output, and // standard error. If out or err are nil, they default to a writer that discards // the output.
[ "StdIO", "configures", "an", "interpreter", "s", "standard", "input", "standard", "output", "and", "standard", "error", ".", "If", "out", "or", "err", "are", "nil", "they", "default", "to", "a", "writer", "that", "discards", "the", "output", "." ]
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/interp/interp.go#L306-L319
train
mvdan/sh
expand/expand.go
Literal
func Literal(cfg *Config, word *syntax.Word) (string, error) { if word == nil { return "", nil } cfg = prepareConfig(cfg) field, err := cfg.wordField(word.Parts, quoteNone) if err != nil { return "", err } return cfg.fieldJoin(field), nil }
go
func Literal(cfg *Config, word *syntax.Word) (string, error) { if word == nil { return "", nil } cfg = prepareConfig(cfg) field, err := cfg.wordField(word.Parts, quoteNone) if err != nil { return "", err } return cfg.fieldJoin(field), nil }
[ "func", "Literal", "(", "cfg", "*", "Config", ",", "word", "*", "syntax", ".", "Word", ")", "(", "string", ",", "error", ")", "{", "if", "word", "==", "nil", "{", "return", "\"", "\"", ",", "nil", "\n", "}", "\n", "cfg", "=", "prepareConfig", "("...
// Literal expands a single shell word. It is similar to Fields, but the result // is a single string. This is the behavior when a word is used as the value in // a shell variable assignment, for example. // // The config specifies shell expansion options; nil behaves the same as an // empty config.
[ "Literal", "expands", "a", "single", "shell", "word", ".", "It", "is", "similar", "to", "Fields", "but", "the", "result", "is", "a", "single", "string", ".", "This", "is", "the", "behavior", "when", "a", "word", "is", "used", "as", "the", "value", "in"...
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/expand/expand.go#L130-L140
train
mvdan/sh
expand/expand.go
Document
func Document(cfg *Config, word *syntax.Word) (string, error) { if word == nil { return "", nil } cfg = prepareConfig(cfg) field, err := cfg.wordField(word.Parts, quoteDouble) if err != nil { return "", err } return cfg.fieldJoin(field), nil }
go
func Document(cfg *Config, word *syntax.Word) (string, error) { if word == nil { return "", nil } cfg = prepareConfig(cfg) field, err := cfg.wordField(word.Parts, quoteDouble) if err != nil { return "", err } return cfg.fieldJoin(field), nil }
[ "func", "Document", "(", "cfg", "*", "Config", ",", "word", "*", "syntax", ".", "Word", ")", "(", "string", ",", "error", ")", "{", "if", "word", "==", "nil", "{", "return", "\"", "\"", ",", "nil", "\n", "}", "\n", "cfg", "=", "prepareConfig", "(...
// Document expands a single shell word as if it were within double quotes. It // is simlar to Literal, but without brace expansion, tilde expansion, and // globbing. // // The config specifies shell expansion options; nil behaves the same as an // empty config.
[ "Document", "expands", "a", "single", "shell", "word", "as", "if", "it", "were", "within", "double", "quotes", ".", "It", "is", "simlar", "to", "Literal", "but", "without", "brace", "expansion", "tilde", "expansion", "and", "globbing", ".", "The", "config", ...
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/expand/expand.go#L148-L158
train
mvdan/sh
expand/expand.go
Pattern
func Pattern(cfg *Config, word *syntax.Word) (string, error) { cfg = prepareConfig(cfg) field, err := cfg.wordField(word.Parts, quoteNone) if err != nil { return "", err } buf := cfg.strBuilder() for _, part := range field { if part.quote > quoteNone { buf.WriteString(syntax.QuotePattern(part.val)) } els...
go
func Pattern(cfg *Config, word *syntax.Word) (string, error) { cfg = prepareConfig(cfg) field, err := cfg.wordField(word.Parts, quoteNone) if err != nil { return "", err } buf := cfg.strBuilder() for _, part := range field { if part.quote > quoteNone { buf.WriteString(syntax.QuotePattern(part.val)) } els...
[ "func", "Pattern", "(", "cfg", "*", "Config", ",", "word", "*", "syntax", ".", "Word", ")", "(", "string", ",", "error", ")", "{", "cfg", "=", "prepareConfig", "(", "cfg", ")", "\n", "field", ",", "err", ":=", "cfg", ".", "wordField", "(", "word", ...
// Pattern expands a single shell word as a pattern, using syntax.QuotePattern // on any non-quoted parts of the input word. The result can be used on // syntax.TranslatePattern directly. // // The config specifies shell expansion options; nil behaves the same as an // empty config.
[ "Pattern", "expands", "a", "single", "shell", "word", "as", "a", "pattern", "using", "syntax", ".", "QuotePattern", "on", "any", "non", "-", "quoted", "parts", "of", "the", "input", "word", ".", "The", "result", "can", "be", "used", "on", "syntax", ".", ...
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/expand/expand.go#L166-L181
train
mvdan/sh
expand/expand.go
Fields
func Fields(cfg *Config, words ...*syntax.Word) ([]string, error) { cfg = prepareConfig(cfg) fields := make([]string, 0, len(words)) dir := cfg.envGet("PWD") for _, word := range words { afterBraces := []*syntax.Word{word} if w2 := syntax.SplitBraces(word); w2 != word { afterBraces = Braces(w2) } for _, ...
go
func Fields(cfg *Config, words ...*syntax.Word) ([]string, error) { cfg = prepareConfig(cfg) fields := make([]string, 0, len(words)) dir := cfg.envGet("PWD") for _, word := range words { afterBraces := []*syntax.Word{word} if w2 := syntax.SplitBraces(word); w2 != word { afterBraces = Braces(w2) } for _, ...
[ "func", "Fields", "(", "cfg", "*", "Config", ",", "words", "...", "*", "syntax", ".", "Word", ")", "(", "[", "]", "string", ",", "error", ")", "{", "cfg", "=", "prepareConfig", "(", "cfg", ")", "\n", "fields", ":=", "make", "(", "[", "]", "string...
// Fields expands a number of words as if they were arguments in a shell // command. This includes brace expansion, tilde expansion, parameter expansion, // command substitution, arithmetic expansion, and quote removal.
[ "Fields", "expands", "a", "number", "of", "words", "as", "if", "they", "were", "arguments", "in", "a", "shell", "command", ".", "This", "includes", "brace", "expansion", "tilde", "expansion", "parameter", "expansion", "command", "substitution", "arithmetic", "ex...
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/expand/expand.go#L363-L395
train
mvdan/sh
expand/expand.go
pathJoin2
func pathJoin2(elem1, elem2 string) string { if elem1 == "" { return elem2 } if strings.HasSuffix(elem1, string(filepath.Separator)) { return elem1 + elem2 } return elem1 + string(filepath.Separator) + elem2 }
go
func pathJoin2(elem1, elem2 string) string { if elem1 == "" { return elem2 } if strings.HasSuffix(elem1, string(filepath.Separator)) { return elem1 + elem2 } return elem1 + string(filepath.Separator) + elem2 }
[ "func", "pathJoin2", "(", "elem1", ",", "elem2", "string", ")", "string", "{", "if", "elem1", "==", "\"", "\"", "{", "return", "elem2", "\n", "}", "\n", "if", "strings", ".", "HasSuffix", "(", "elem1", ",", "string", "(", "filepath", ".", "Separator", ...
// pathJoin2 is a simpler version of filepath.Join without cleaning the result, // since that's needed for globbing.
[ "pathJoin2", "is", "a", "simpler", "version", "of", "filepath", ".", "Join", "without", "cleaning", "the", "result", "since", "that", "s", "needed", "for", "globbing", "." ]
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/expand/expand.go#L651-L659
train
mvdan/sh
expand/expand.go
pathSplit
func pathSplit(path string) []string { path = filepath.FromSlash(path) return strings.Split(path, string(filepath.Separator)) }
go
func pathSplit(path string) []string { path = filepath.FromSlash(path) return strings.Split(path, string(filepath.Separator)) }
[ "func", "pathSplit", "(", "path", "string", ")", "[", "]", "string", "{", "path", "=", "filepath", ".", "FromSlash", "(", "path", ")", "\n", "return", "strings", ".", "Split", "(", "path", ",", "string", "(", "filepath", ".", "Separator", ")", ")", "...
// pathSplit splits a file path into its elements, retaining empty ones. Before // splitting, slashes are replaced with filepath.Separator, so that splitting // Unix paths on Windows works as well.
[ "pathSplit", "splits", "a", "file", "path", "into", "its", "elements", "retaining", "empty", "ones", ".", "Before", "splitting", "slashes", "are", "replaced", "with", "filepath", ".", "Separator", "so", "that", "splitting", "Unix", "paths", "on", "Windows", "w...
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/expand/expand.go#L664-L667
train
mvdan/sh
fileutil/file.go
CouldBeScript
func CouldBeScript(info os.FileInfo) ScriptConfidence { name := info.Name() switch { case info.IsDir(), name[0] == '.': return ConfNotScript case info.Mode()&os.ModeSymlink != 0: return ConfNotScript case extRe.MatchString(name): return ConfIsScript case strings.IndexByte(name, '.') > 0: return ConfNotScr...
go
func CouldBeScript(info os.FileInfo) ScriptConfidence { name := info.Name() switch { case info.IsDir(), name[0] == '.': return ConfNotScript case info.Mode()&os.ModeSymlink != 0: return ConfNotScript case extRe.MatchString(name): return ConfIsScript case strings.IndexByte(name, '.') > 0: return ConfNotScr...
[ "func", "CouldBeScript", "(", "info", "os", ".", "FileInfo", ")", "ScriptConfidence", "{", "name", ":=", "info", ".", "Name", "(", ")", "\n", "switch", "{", "case", "info", ".", "IsDir", "(", ")", ",", "name", "[", "0", "]", "==", "'.'", ":", "retu...
// CouldBeScript reports how likely a file is to be a shell script. It // discards directories, symlinks, hidden files and files with non-shell // extensions.
[ "CouldBeScript", "reports", "how", "likely", "a", "file", "is", "to", "be", "a", "shell", "script", ".", "It", "discards", "directories", "symlinks", "hidden", "files", "and", "files", "with", "non", "-", "shell", "extensions", "." ]
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/fileutil/file.go#L39-L55
train
mvdan/sh
expand/arith.go
atoi
func atoi(s string) int { n, _ := strconv.Atoi(s) return n }
go
func atoi(s string) int { n, _ := strconv.Atoi(s) return n }
[ "func", "atoi", "(", "s", "string", ")", "int", "{", "n", ",", "_", ":=", "strconv", ".", "Atoi", "(", "s", ")", "\n", "return", "n", "\n", "}" ]
// atoi is just a shorthand for strconv.Atoi that ignores the error, // just like shells do.
[ "atoi", "is", "just", "a", "shorthand", "for", "strconv", ".", "Atoi", "that", "ignores", "the", "error", "just", "like", "shells", "do", "." ]
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/expand/arith.go#L110-L113
train
mvdan/sh
shell/expand.go
Fields
func Fields(s string, env func(string) string) ([]string, error) { p := syntax.NewParser() var words []*syntax.Word err := p.Words(strings.NewReader(s), func(w *syntax.Word) bool { words = append(words, w) return true }) if err != nil { return nil, err } if env == nil { env = os.Getenv } cfg := &expand...
go
func Fields(s string, env func(string) string) ([]string, error) { p := syntax.NewParser() var words []*syntax.Word err := p.Words(strings.NewReader(s), func(w *syntax.Word) bool { words = append(words, w) return true }) if err != nil { return nil, err } if env == nil { env = os.Getenv } cfg := &expand...
[ "func", "Fields", "(", "s", "string", ",", "env", "func", "(", "string", ")", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "p", ":=", "syntax", ".", "NewParser", "(", ")", "\n", "var", "words", "[", "]", "*", "syntax", ".", "...
// Fields performs shell expansion on s as if it were a command's arguments, // using env to resolve variables. It is similar to Expand, but includes brace // expansion, tilde expansion, and globbing. // // If env is nil, the current environment variables are used. Empty variables // are treated as unset; to support va...
[ "Fields", "performs", "shell", "expansion", "on", "s", "as", "if", "it", "were", "a", "command", "s", "arguments", "using", "env", "to", "resolve", "variables", ".", "It", "is", "similar", "to", "Expand", "but", "includes", "brace", "expansion", "tilde", "...
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/shell/expand.go#L48-L63
train
mvdan/sh
syntax/printer.go
KeepPadding
func KeepPadding(p *Printer) { p.keepPadding = true p.cols.Writer = p.bufWriter.(*bufio.Writer) p.bufWriter = &p.cols }
go
func KeepPadding(p *Printer) { p.keepPadding = true p.cols.Writer = p.bufWriter.(*bufio.Writer) p.bufWriter = &p.cols }
[ "func", "KeepPadding", "(", "p", "*", "Printer", ")", "{", "p", ".", "keepPadding", "=", "true", "\n", "p", ".", "cols", ".", "Writer", "=", "p", ".", "bufWriter", ".", "(", "*", "bufio", ".", "Writer", ")", "\n", "p", ".", "bufWriter", "=", "&",...
// KeepPadding will keep most nodes and tokens in the same column that // they were in the original source. This allows the user to decide how // to align and pad their code with spaces. // // Note that this feature is best-effort and will only keep the // alignment stable, so it may need some human help the first time...
[ "KeepPadding", "will", "keep", "most", "nodes", "and", "tokens", "in", "the", "same", "column", "that", "they", "were", "in", "the", "original", "source", ".", "This", "allows", "the", "user", "to", "decide", "how", "to", "align", "and", "pad", "their", ...
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/syntax/printer.go#L42-L46
train
mvdan/sh
syntax/printer.go
NewPrinter
func NewPrinter(options ...func(*Printer)) *Printer { p := &Printer{ bufWriter: bufio.NewWriter(nil), tabsPrinter: new(Printer), tabWriter: new(tabwriter.Writer), } for _, opt := range options { opt(p) } return p }
go
func NewPrinter(options ...func(*Printer)) *Printer { p := &Printer{ bufWriter: bufio.NewWriter(nil), tabsPrinter: new(Printer), tabWriter: new(tabwriter.Writer), } for _, opt := range options { opt(p) } return p }
[ "func", "NewPrinter", "(", "options", "...", "func", "(", "*", "Printer", ")", ")", "*", "Printer", "{", "p", ":=", "&", "Printer", "{", "bufWriter", ":", "bufio", ".", "NewWriter", "(", "nil", ")", ",", "tabsPrinter", ":", "new", "(", "Printer", ")"...
// NewPrinter allocates a new Printer and applies any number of options.
[ "NewPrinter", "allocates", "a", "new", "Printer", "and", "applies", "any", "number", "of", "options", "." ]
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/syntax/printer.go#L54-L64
train
mvdan/sh
interp/module.go
FromModuleContext
func FromModuleContext(ctx context.Context) (ModuleCtx, bool) { mc, ok := ctx.Value(moduleCtxKey{}).(ModuleCtx) return mc, ok }
go
func FromModuleContext(ctx context.Context) (ModuleCtx, bool) { mc, ok := ctx.Value(moduleCtxKey{}).(ModuleCtx) return mc, ok }
[ "func", "FromModuleContext", "(", "ctx", "context", ".", "Context", ")", "(", "ModuleCtx", ",", "bool", ")", "{", "mc", ",", "ok", ":=", "ctx", ".", "Value", "(", "moduleCtxKey", "{", "}", ")", ".", "(", "ModuleCtx", ")", "\n", "return", "mc", ",", ...
// FromModuleContext returns the ModuleCtx value stored in ctx, if any.
[ "FromModuleContext", "returns", "the", "ModuleCtx", "value", "stored", "in", "ctx", "if", "any", "." ]
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/interp/module.go#L21-L24
train
mvdan/sh
syntax/walk.go
DebugPrint
func DebugPrint(w io.Writer, node Node) error { p := debugPrinter{out: w} p.print(reflect.ValueOf(node)) return p.err }
go
func DebugPrint(w io.Writer, node Node) error { p := debugPrinter{out: w} p.print(reflect.ValueOf(node)) return p.err }
[ "func", "DebugPrint", "(", "w", "io", ".", "Writer", ",", "node", "Node", ")", "error", "{", "p", ":=", "debugPrinter", "{", "out", ":", "w", "}", "\n", "p", ".", "print", "(", "reflect", ".", "ValueOf", "(", "node", ")", ")", "\n", "return", "p"...
// DebugPrint prints the provided syntax tree, spanning multiple lines and with // indentation. Can be useful to investigate the content of a syntax tree.
[ "DebugPrint", "prints", "the", "provided", "syntax", "tree", "spanning", "multiple", "lines", "and", "with", "indentation", ".", "Can", "be", "useful", "to", "investigate", "the", "content", "of", "a", "syntax", "tree", "." ]
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/syntax/walk.go#L233-L237
train
mvdan/sh
syntax/lexer.go
fill
func (p *Parser) fill() { p.offs += p.bsp left := len(p.bs) - p.bsp copy(p.readBuf[:left], p.readBuf[p.bsp:]) readAgain: n, err := 0, p.readErr if err == nil { n, err = p.src.Read(p.readBuf[left:]) p.readErr = err } if n == 0 { if err == nil { goto readAgain } // don't use p.errPass as we don't want...
go
func (p *Parser) fill() { p.offs += p.bsp left := len(p.bs) - p.bsp copy(p.readBuf[:left], p.readBuf[p.bsp:]) readAgain: n, err := 0, p.readErr if err == nil { n, err = p.src.Read(p.readBuf[left:]) p.readErr = err } if n == 0 { if err == nil { goto readAgain } // don't use p.errPass as we don't want...
[ "func", "(", "p", "*", "Parser", ")", "fill", "(", ")", "{", "p", ".", "offs", "+=", "p", ".", "bsp", "\n", "left", ":=", "len", "(", "p", ".", "bs", ")", "-", "p", ".", "bsp", "\n", "copy", "(", "p", ".", "readBuf", "[", ":", "left", "]"...
// fill reads more bytes from the input src into readBuf. Any bytes that // had not yet been used at the end of the buffer are slid into the // beginning of the buffer.
[ "fill", "reads", "more", "bytes", "from", "the", "input", "src", "into", "readBuf", ".", "Any", "bytes", "that", "had", "not", "yet", "been", "used", "at", "the", "end", "of", "the", "buffer", "are", "slid", "into", "the", "beginning", "of", "the", "bu...
5700c68a35dc3882e646a5e41776e31bb2c078e3
https://github.com/mvdan/sh/blob/5700c68a35dc3882e646a5e41776e31bb2c078e3/syntax/lexer.go#L119-L146
train
robertkrimen/otto
file/file.go
AddFile
func (self *FileSet) AddFile(filename, src string) int { base := self.nextBase() file := &File{ name: filename, src: src, base: base, } self.files = append(self.files, file) self.last = file return base }
go
func (self *FileSet) AddFile(filename, src string) int { base := self.nextBase() file := &File{ name: filename, src: src, base: base, } self.files = append(self.files, file) self.last = file return base }
[ "func", "(", "self", "*", "FileSet", ")", "AddFile", "(", "filename", ",", "src", "string", ")", "int", "{", "base", ":=", "self", ".", "nextBase", "(", ")", "\n", "file", ":=", "&", "File", "{", "name", ":", "filename", ",", "src", ":", "src", "...
// AddFile adds a new file with the given filename and src. // // This an internal method, but exported for cross-package use.
[ "AddFile", "adds", "a", "new", "file", "with", "the", "given", "filename", "and", "src", ".", "This", "an", "internal", "method", "but", "exported", "for", "cross", "-", "package", "use", "." ]
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/file/file.go#L65-L75
train
robertkrimen/otto
global.go
newBoundFunction
func (runtime *_runtime) newBoundFunction(target *_object, this Value, argumentList []Value) *_object { self := runtime.newBoundFunctionObject(target, this, argumentList) self.prototype = runtime.global.FunctionPrototype prototype := runtime.newObject() self.defineProperty("prototype", toValue_object(prototype), 01...
go
func (runtime *_runtime) newBoundFunction(target *_object, this Value, argumentList []Value) *_object { self := runtime.newBoundFunctionObject(target, this, argumentList) self.prototype = runtime.global.FunctionPrototype prototype := runtime.newObject() self.defineProperty("prototype", toValue_object(prototype), 01...
[ "func", "(", "runtime", "*", "_runtime", ")", "newBoundFunction", "(", "target", "*", "_object", ",", "this", "Value", ",", "argumentList", "[", "]", "Value", ")", "*", "_object", "{", "self", ":=", "runtime", ".", "newBoundFunctionObject", "(", "target", ...
// FIXME Only in one place...
[ "FIXME", "Only", "in", "one", "place", "..." ]
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/global.go#L214-L221
train
robertkrimen/otto
script.go
CompileWithSourceMap
func (self *Otto) CompileWithSourceMap(filename string, src, sm interface{}) (*Script, error) { program, err := self.runtime.parse(filename, src, sm) if err != nil { return nil, err } cmpl_program := cmpl_parse(program) script := &Script{ version: scriptVersion, program: cmpl_program, filename: filenam...
go
func (self *Otto) CompileWithSourceMap(filename string, src, sm interface{}) (*Script, error) { program, err := self.runtime.parse(filename, src, sm) if err != nil { return nil, err } cmpl_program := cmpl_parse(program) script := &Script{ version: scriptVersion, program: cmpl_program, filename: filenam...
[ "func", "(", "self", "*", "Otto", ")", "CompileWithSourceMap", "(", "filename", "string", ",", "src", ",", "sm", "interface", "{", "}", ")", "(", "*", "Script", ",", "error", ")", "{", "program", ",", "err", ":=", "self", ".", "runtime", ".", "parse"...
// CompileWithSourceMap does the same thing as Compile, but with the obvious // difference of applying a source map.
[ "CompileWithSourceMap", "does", "the", "same", "thing", "as", "Compile", "but", "with", "the", "obvious", "difference", "of", "applying", "a", "source", "map", "." ]
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/script.go#L35-L51
train
robertkrimen/otto
script.go
marshalBinary
func (self *Script) marshalBinary() ([]byte, error) { var bfr bytes.Buffer encoder := gob.NewEncoder(&bfr) err := encoder.Encode(self.version) if err != nil { return nil, err } err = encoder.Encode(self.program) if err != nil { return nil, err } err = encoder.Encode(self.filename) if err != nil { return...
go
func (self *Script) marshalBinary() ([]byte, error) { var bfr bytes.Buffer encoder := gob.NewEncoder(&bfr) err := encoder.Encode(self.version) if err != nil { return nil, err } err = encoder.Encode(self.program) if err != nil { return nil, err } err = encoder.Encode(self.filename) if err != nil { return...
[ "func", "(", "self", "*", "Script", ")", "marshalBinary", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "bfr", "bytes", ".", "Buffer", "\n", "encoder", ":=", "gob", ".", "NewEncoder", "(", "&", "bfr", ")", "\n", "err", ":=", "en...
// MarshalBinary will marshal a script into a binary form. A marshalled script // that is later unmarshalled can be executed on the same version of the otto runtime. // // The binary format can change at any time and should be considered unspecified and opaque. //
[ "MarshalBinary", "will", "marshal", "a", "script", "into", "a", "binary", "form", ".", "A", "marshalled", "script", "that", "is", "later", "unmarshalled", "can", "be", "executed", "on", "the", "same", "version", "of", "the", "otto", "runtime", ".", "The", ...
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/script.go#L62-L82
train
robertkrimen/otto
script.go
unmarshalBinary
func (self *Script) unmarshalBinary(data []byte) error { decoder := gob.NewDecoder(bytes.NewReader(data)) err := decoder.Decode(&self.version) if err != nil { goto error } if self.version != scriptVersion { err = ErrVersion goto error } err = decoder.Decode(&self.program) if err != nil { goto error } ...
go
func (self *Script) unmarshalBinary(data []byte) error { decoder := gob.NewDecoder(bytes.NewReader(data)) err := decoder.Decode(&self.version) if err != nil { goto error } if self.version != scriptVersion { err = ErrVersion goto error } err = decoder.Decode(&self.program) if err != nil { goto error } ...
[ "func", "(", "self", "*", "Script", ")", "unmarshalBinary", "(", "data", "[", "]", "byte", ")", "error", "{", "decoder", ":=", "gob", ".", "NewDecoder", "(", "bytes", ".", "NewReader", "(", "data", ")", ")", "\n", "err", ":=", "decoder", ".", "Decode...
// UnmarshalBinary will vivify a marshalled script into something usable. If the script was // originally marshalled on a different version of the otto runtime, then this method // will return an error. // // The binary format can change at any time and should be considered unspecified and opaque. //
[ "UnmarshalBinary", "will", "vivify", "a", "marshalled", "script", "into", "something", "usable", ".", "If", "the", "script", "was", "originally", "marshalled", "on", "a", "different", "version", "of", "the", "otto", "runtime", "then", "this", "method", "will", ...
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/script.go#L90-L119
train
robertkrimen/otto
type_function.go
hasInstance
func (self *_object) hasInstance(of Value) bool { if !self.isCall() { // We should not have a hasInstance method panic(self.runtime.panicTypeError()) } if !of.IsObject() { return false } prototype := self.get("prototype") if !prototype.IsObject() { panic(self.runtime.panicTypeError()) } prototypeObject ...
go
func (self *_object) hasInstance(of Value) bool { if !self.isCall() { // We should not have a hasInstance method panic(self.runtime.panicTypeError()) } if !of.IsObject() { return false } prototype := self.get("prototype") if !prototype.IsObject() { panic(self.runtime.panicTypeError()) } prototypeObject ...
[ "func", "(", "self", "*", "_object", ")", "hasInstance", "(", "of", "Value", ")", "bool", "{", "if", "!", "self", ".", "isCall", "(", ")", "{", "// We should not have a hasInstance method", "panic", "(", "self", ".", "runtime", ".", "panicTypeError", "(", ...
// 15.3.5.3
[ "15", ".", "3", ".", "5", ".", "3" ]
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/type_function.go#L259-L281
train
robertkrimen/otto
type_function.go
Argument
func (self FunctionCall) Argument(index int) Value { return valueOfArrayIndex(self.ArgumentList, index) }
go
func (self FunctionCall) Argument(index int) Value { return valueOfArrayIndex(self.ArgumentList, index) }
[ "func", "(", "self", "FunctionCall", ")", "Argument", "(", "index", "int", ")", "Value", "{", "return", "valueOfArrayIndex", "(", "self", ".", "ArgumentList", ",", "index", ")", "\n", "}" ]
// Argument will return the value of the argument at the given index. // // If no such argument exists, undefined is returned.
[ "Argument", "will", "return", "the", "value", "of", "the", "argument", "at", "the", "given", "index", ".", "If", "no", "such", "argument", "exists", "undefined", "is", "returned", "." ]
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/type_function.go#L301-L303
train
robertkrimen/otto
otto_.go
valueToRangeIndex
func valueToRangeIndex(indexValue Value, length int64, negativeIsZero bool) int64 { index := indexValue.number().int64 if negativeIsZero { if index < 0 { index = 0 } // minimum(index, length) if index >= length { index = length } return index } if index < 0 { index += length if index < 0 { ...
go
func valueToRangeIndex(indexValue Value, length int64, negativeIsZero bool) int64 { index := indexValue.number().int64 if negativeIsZero { if index < 0 { index = 0 } // minimum(index, length) if index >= length { index = length } return index } if index < 0 { index += length if index < 0 { ...
[ "func", "valueToRangeIndex", "(", "indexValue", "Value", ",", "length", "int64", ",", "negativeIsZero", "bool", ")", "int64", "{", "index", ":=", "indexValue", ".", "number", "(", ")", ".", "int64", "\n", "if", "negativeIsZero", "{", "if", "index", "<", "0...
// A range index can be anything from 0 up to length. It is NOT safe to use as an index // to an array, but is useful for slicing and in some ECMA algorithms.
[ "A", "range", "index", "can", "be", "anything", "from", "0", "up", "to", "length", ".", "It", "is", "NOT", "safe", "to", "use", "as", "an", "index", "to", "an", "array", "but", "is", "useful", "for", "slicing", "and", "in", "some", "ECMA", "algorithm...
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/otto_.go#L75-L99
train
robertkrimen/otto
parser/error.go
Error
func (self Error) Error() string { filename := self.Position.Filename if filename == "" { filename = "(anonymous)" } return fmt.Sprintf("%s: Line %d:%d %s", filename, self.Position.Line, self.Position.Column, self.Message, ) }
go
func (self Error) Error() string { filename := self.Position.Filename if filename == "" { filename = "(anonymous)" } return fmt.Sprintf("%s: Line %d:%d %s", filename, self.Position.Line, self.Position.Column, self.Message, ) }
[ "func", "(", "self", "Error", ")", "Error", "(", ")", "string", "{", "filename", ":=", "self", ".", "Position", ".", "Filename", "\n", "if", "filename", "==", "\"", "\"", "{", "filename", "=", "\"", "\"", "\n", "}", "\n", "return", "fmt", ".", "Spr...
// FIXME Should this be "SyntaxError"?
[ "FIXME", "Should", "this", "be", "SyntaxError", "?" ]
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/parser/error.go#L59-L70
train
robertkrimen/otto
parser/error.go
Add
func (self *ErrorList) Add(position file.Position, msg string) { *self = append(*self, &Error{position, msg}) }
go
func (self *ErrorList) Add(position file.Position, msg string) { *self = append(*self, &Error{position, msg}) }
[ "func", "(", "self", "*", "ErrorList", ")", "Add", "(", "position", "file", ".", "Position", ",", "msg", "string", ")", "{", "*", "self", "=", "append", "(", "*", "self", ",", "&", "Error", "{", "position", ",", "msg", "}", ")", "\n", "}" ]
// Add adds an Error with given position and message to an ErrorList.
[ "Add", "adds", "an", "Error", "with", "given", "position", "and", "message", "to", "an", "ErrorList", "." ]
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/parser/error.go#L127-L129
train
robertkrimen/otto
object.go
getOwnProperty
func (self *_object) getOwnProperty(name string) *_property { return self.objectClass.getOwnProperty(self, name) }
go
func (self *_object) getOwnProperty(name string) *_property { return self.objectClass.getOwnProperty(self, name) }
[ "func", "(", "self", "*", "_object", ")", "getOwnProperty", "(", "name", "string", ")", "*", "_property", "{", "return", "self", ".", "objectClass", ".", "getOwnProperty", "(", "self", ",", "name", ")", "\n", "}" ]
// 8.12 // 8.12.1
[ "8", ".", "12", "8", ".", "12", ".", "1" ]
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/object.go#L31-L33
train
robertkrimen/otto
object.go
DefaultValue
func (self *_object) DefaultValue(hint _defaultValueHint) Value { if hint == defaultValueNoHint { if self.class == "Date" { // Date exception hint = defaultValueHintString } else { hint = defaultValueHintNumber } } methodSequence := []string{"valueOf", "toString"} if hint == defaultValueHintString { ...
go
func (self *_object) DefaultValue(hint _defaultValueHint) Value { if hint == defaultValueNoHint { if self.class == "Date" { // Date exception hint = defaultValueHintString } else { hint = defaultValueHintNumber } } methodSequence := []string{"valueOf", "toString"} if hint == defaultValueHintString { ...
[ "func", "(", "self", "*", "_object", ")", "DefaultValue", "(", "hint", "_defaultValueHint", ")", "Value", "{", "if", "hint", "==", "defaultValueNoHint", "{", "if", "self", ".", "class", "==", "\"", "\"", "{", "// Date exception", "hint", "=", "defaultValueHi...
// 8.12.8
[ "8", ".", "12", ".", "8" ]
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/object.go#L73-L98
train
robertkrimen/otto
terst/terst.go
decorate
func decorate(call _entry, s string) string { file, line := call.File, call.Line if call.PC > 0 { // Truncate file name at last file name separator. if index := strings.LastIndex(file, "/"); index >= 0 { file = file[index+1:] } else if index = strings.LastIndex(file, "\\"); index >= 0 { file = file[index...
go
func decorate(call _entry, s string) string { file, line := call.File, call.Line if call.PC > 0 { // Truncate file name at last file name separator. if index := strings.LastIndex(file, "/"); index >= 0 { file = file[index+1:] } else if index = strings.LastIndex(file, "\\"); index >= 0 { file = file[index...
[ "func", "decorate", "(", "call", "_entry", ",", "s", "string", ")", "string", "{", "file", ",", "line", ":=", "call", ".", "File", ",", "call", ".", "Line", "\n", "if", "call", ".", "PC", ">", "0", "{", "// Truncate file name at last file name separator.",...
// decorate prefixes the string with the file and line of the call site // and inserts the final newline if needed and indentation tabs for formascing.
[ "decorate", "prefixes", "the", "string", "with", "the", "file", "and", "line", "of", "the", "call", "site", "and", "inserts", "the", "final", "newline", "if", "needed", "and", "indentation", "tabs", "for", "formascing", "." ]
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/terst/terst.go#L502-L533
train
robertkrimen/otto
terst/terst.go
Caller
func Caller() *Call { scope, entry := findScope() if scope == nil { return nil } return &Call{ scope: scope, entry: entry, } }
go
func Caller() *Call { scope, entry := findScope() if scope == nil { return nil } return &Call{ scope: scope, entry: entry, } }
[ "func", "Caller", "(", ")", "*", "Call", "{", "scope", ",", "entry", ":=", "findScope", "(", ")", "\n", "if", "scope", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "&", "Call", "{", "scope", ":", "scope", ",", "entry", ":", "entr...
// Caller will search the stack, looking for a Terst testing scope. If a scope // is found, then Caller returns a Call for logging errors, accessing testing.T, etc. // If no scope is found, Caller returns nil.
[ "Caller", "will", "search", "the", "stack", "looking", "for", "a", "Terst", "testing", "scope", ".", "If", "a", "scope", "is", "found", "then", "Caller", "returns", "a", "Call", "for", "logging", "errors", "accessing", "testing", ".", "T", "etc", ".", "I...
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/terst/terst.go#L567-L576
train
robertkrimen/otto
terst/terst.go
Log
func (cl *Call) Log(arguments ...interface{}) { cl.scope.log(cl.entry, fmt.Sprintln(arguments...)) }
go
func (cl *Call) Log(arguments ...interface{}) { cl.scope.log(cl.entry, fmt.Sprintln(arguments...)) }
[ "func", "(", "cl", "*", "Call", ")", "Log", "(", "arguments", "...", "interface", "{", "}", ")", "{", "cl", ".", "scope", ".", "log", "(", "cl", ".", "entry", ",", "fmt", ".", "Sprintln", "(", "arguments", "...", ")", ")", "\n", "}" ]
// Log is the terst version of `testing.T.Log`
[ "Log", "is", "the", "terst", "version", "of", "testing", ".", "T", ".", "Log" ]
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/terst/terst.go#L590-L592
train
robertkrimen/otto
terst/terst.go
Logf
func (cl *Call) Logf(format string, arguments ...interface{}) { cl.scope.log(cl.entry, fmt.Sprintf(format, arguments...)) }
go
func (cl *Call) Logf(format string, arguments ...interface{}) { cl.scope.log(cl.entry, fmt.Sprintf(format, arguments...)) }
[ "func", "(", "cl", "*", "Call", ")", "Logf", "(", "format", "string", ",", "arguments", "...", "interface", "{", "}", ")", "{", "cl", ".", "scope", ".", "log", "(", "cl", ".", "entry", ",", "fmt", ".", "Sprintf", "(", "format", ",", "arguments", ...
// Logf is the terst version of `testing.T.Logf`
[ "Logf", "is", "the", "terst", "version", "of", "testing", ".", "T", ".", "Logf" ]
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/terst/terst.go#L595-L597
train
robertkrimen/otto
terst/terst.go
Error
func (cl *Call) Error(arguments ...interface{}) { cl.scope.log(cl.entry, fmt.Sprintln(arguments...)) cl.scope.t.Fail() }
go
func (cl *Call) Error(arguments ...interface{}) { cl.scope.log(cl.entry, fmt.Sprintln(arguments...)) cl.scope.t.Fail() }
[ "func", "(", "cl", "*", "Call", ")", "Error", "(", "arguments", "...", "interface", "{", "}", ")", "{", "cl", ".", "scope", ".", "log", "(", "cl", ".", "entry", ",", "fmt", ".", "Sprintln", "(", "arguments", "...", ")", ")", "\n", "cl", ".", "s...
// Error is the terst version of `testing.T.Error`
[ "Error", "is", "the", "terst", "version", "of", "testing", ".", "T", ".", "Error" ]
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/terst/terst.go#L600-L603
train
robertkrimen/otto
terst/terst.go
Errorf
func (cl *Call) Errorf(format string, arguments ...interface{}) { cl.scope.log(cl.entry, fmt.Sprintf(format, arguments...)) cl.scope.t.Fail() }
go
func (cl *Call) Errorf(format string, arguments ...interface{}) { cl.scope.log(cl.entry, fmt.Sprintf(format, arguments...)) cl.scope.t.Fail() }
[ "func", "(", "cl", "*", "Call", ")", "Errorf", "(", "format", "string", ",", "arguments", "...", "interface", "{", "}", ")", "{", "cl", ".", "scope", ".", "log", "(", "cl", ".", "entry", ",", "fmt", ".", "Sprintf", "(", "format", ",", "arguments", ...
// Errorf is the terst version of `testing.T.Errorf`
[ "Errorf", "is", "the", "terst", "version", "of", "testing", ".", "T", ".", "Errorf" ]
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/terst/terst.go#L606-L609
train
robertkrimen/otto
terst/terst.go
Skip
func (cl *Call) Skip(arguments ...interface{}) { cl.scope.log(cl.entry, fmt.Sprintln(arguments...)) cl.scope.t.SkipNow() }
go
func (cl *Call) Skip(arguments ...interface{}) { cl.scope.log(cl.entry, fmt.Sprintln(arguments...)) cl.scope.t.SkipNow() }
[ "func", "(", "cl", "*", "Call", ")", "Skip", "(", "arguments", "...", "interface", "{", "}", ")", "{", "cl", ".", "scope", ".", "log", "(", "cl", ".", "entry", ",", "fmt", ".", "Sprintln", "(", "arguments", "...", ")", ")", "\n", "cl", ".", "sc...
// Skip is the terst version of `testing.T.Skip`
[ "Skip", "is", "the", "terst", "version", "of", "testing", ".", "T", ".", "Skip" ]
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/terst/terst.go#L612-L615
train
robertkrimen/otto
terst/terst.go
Skipf
func (cl *Call) Skipf(format string, arguments ...interface{}) { cl.scope.log(cl.entry, fmt.Sprintf(format, arguments...)) cl.scope.t.SkipNow() }
go
func (cl *Call) Skipf(format string, arguments ...interface{}) { cl.scope.log(cl.entry, fmt.Sprintf(format, arguments...)) cl.scope.t.SkipNow() }
[ "func", "(", "cl", "*", "Call", ")", "Skipf", "(", "format", "string", ",", "arguments", "...", "interface", "{", "}", ")", "{", "cl", ".", "scope", ".", "log", "(", "cl", ".", "entry", ",", "fmt", ".", "Sprintf", "(", "format", ",", "arguments", ...
// Skipf is the terst version of `testing.T.Skipf`
[ "Skipf", "is", "the", "terst", "version", "of", "testing", ".", "T", ".", "Skipf" ]
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/terst/terst.go#L618-L621
train
robertkrimen/otto
value.go
IsFunction
func (value Value) IsFunction() bool { if value.kind != valueObject { return false } return value.value.(*_object).class == "Function" }
go
func (value Value) IsFunction() bool { if value.kind != valueObject { return false } return value.value.(*_object).class == "Function" }
[ "func", "(", "value", "Value", ")", "IsFunction", "(", ")", "bool", "{", "if", "value", ".", "kind", "!=", "valueObject", "{", "return", "false", "\n", "}", "\n", "return", "value", ".", "value", ".", "(", "*", "_object", ")", ".", "class", "==", "...
// IsFunction will return true if value is a function.
[ "IsFunction", "will", "return", "true", "if", "value", "is", "a", "function", "." ]
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/value.go#L192-L197
train
robertkrimen/otto
value.go
String
func (value Value) String() string { result := "" catchPanic(func() { result = value.string() }) return result }
go
func (value Value) String() string { result := "" catchPanic(func() { result = value.string() }) return result }
[ "func", "(", "value", "Value", ")", "String", "(", ")", "string", "{", "result", ":=", "\"", "\"", "\n", "catchPanic", "(", "func", "(", ")", "{", "result", "=", "value", ".", "string", "(", ")", "\n", "}", ")", "\n", "return", "result", "\n", "}...
// String will return the value as a string. // // This method will make return the empty string if there is an error.
[ "String", "will", "return", "the", "value", "as", "a", "string", ".", "This", "method", "will", "make", "return", "the", "empty", "string", "if", "there", "is", "an", "error", "." ]
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/value.go#L384-L390
train
robertkrimen/otto
value.go
Object
func (value Value) Object() *Object { switch object := value.value.(type) { case *_object: return _newObject(object, value) } return nil }
go
func (value Value) Object() *Object { switch object := value.value.(type) { case *_object: return _newObject(object, value) } return nil }
[ "func", "(", "value", "Value", ")", "Object", "(", ")", "*", "Object", "{", "switch", "object", ":=", "value", ".", "value", ".", "(", "type", ")", "{", "case", "*", "_object", ":", "return", "_newObject", "(", "object", ",", "value", ")", "\n", "}...
// Object will return the object of the value, or nil if value is not an object. // // This method will not do any implicit conversion. For example, calling this method on a string primitive value will not return a String object.
[ "Object", "will", "return", "the", "object", "of", "the", "value", "or", "nil", "if", "value", "is", "not", "an", "object", ".", "This", "method", "will", "not", "do", "any", "implicit", "conversion", ".", "For", "example", "calling", "this", "method", "...
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/value.go#L474-L480
train
robertkrimen/otto
repl/repl.go
DebuggerHandler
func DebuggerHandler(vm *otto.Otto) { i := atomic.AddUint32(&counter, 1) // purposefully ignoring the error here - we can't do anything useful with // it except panicking, and that'd be pretty rude. it'd be easy enough for a // consumer to define an equivalent function that _does_ panic if desired. _ = RunWithPro...
go
func DebuggerHandler(vm *otto.Otto) { i := atomic.AddUint32(&counter, 1) // purposefully ignoring the error here - we can't do anything useful with // it except panicking, and that'd be pretty rude. it'd be easy enough for a // consumer to define an equivalent function that _does_ panic if desired. _ = RunWithPro...
[ "func", "DebuggerHandler", "(", "vm", "*", "otto", ".", "Otto", ")", "{", "i", ":=", "atomic", ".", "AddUint32", "(", "&", "counter", ",", "1", ")", "\n\n", "// purposefully ignoring the error here - we can't do anything useful with", "// it except panicking, and that'd...
// DebuggerHandler implements otto's debugger handler signature, providing a // simple drop-in debugger implementation.
[ "DebuggerHandler", "implements", "otto", "s", "debugger", "handler", "signature", "providing", "a", "simple", "drop", "-", "in", "debugger", "implementation", "." ]
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/repl/repl.go#L18-L25
train
robertkrimen/otto
repl/repl.go
RunWithPrompt
func RunWithPrompt(vm *otto.Otto, prompt string) error { return RunWithOptions(vm, Options{ Prompt: prompt, }) }
go
func RunWithPrompt(vm *otto.Otto, prompt string) error { return RunWithOptions(vm, Options{ Prompt: prompt, }) }
[ "func", "RunWithPrompt", "(", "vm", "*", "otto", ".", "Otto", ",", "prompt", "string", ")", "error", "{", "return", "RunWithOptions", "(", "vm", ",", "Options", "{", "Prompt", ":", "prompt", ",", "}", ")", "\n", "}" ]
// RunWithPrompt runs a REPL with the given prompt and no prelude.
[ "RunWithPrompt", "runs", "a", "REPL", "with", "the", "given", "prompt", "and", "no", "prelude", "." ]
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/repl/repl.go#L33-L37
train
robertkrimen/otto
repl/repl.go
RunWithPrelude
func RunWithPrelude(vm *otto.Otto, prelude string) error { return RunWithOptions(vm, Options{ Prelude: prelude, }) }
go
func RunWithPrelude(vm *otto.Otto, prelude string) error { return RunWithOptions(vm, Options{ Prelude: prelude, }) }
[ "func", "RunWithPrelude", "(", "vm", "*", "otto", ".", "Otto", ",", "prelude", "string", ")", "error", "{", "return", "RunWithOptions", "(", "vm", ",", "Options", "{", "Prelude", ":", "prelude", ",", "}", ")", "\n", "}" ]
// RunWithPrelude runs a REPL with the default prompt and the given prelude.
[ "RunWithPrelude", "runs", "a", "REPL", "with", "the", "default", "prompt", "and", "the", "given", "prelude", "." ]
15f95af6e78dcd2030d8195a138bd88d4f403546
https://github.com/robertkrimen/otto/blob/15f95af6e78dcd2030d8195a138bd88d4f403546/repl/repl.go#L40-L44
train