Documentation
¶
Overview ¶
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compile ¶
func Compile(field field.Config, sourceFiles ...source.File, ) (ast.Program, source.Maps[any], []source.SyntaxError)
Compile takes a given set of source files and parses them and their dependencies into a given set of linked declarations. This includes performing various checks on the files, such as type checking, etc. Switch statements are lowered to a multiway-skip dispatch.
func Link ¶
func Link(unlinkedSourceFiles ...parser.UnlinkedSourceFile) (ast.Program, source.Maps[any], []source.SyntaxError)
Link a set of one or more source files together to produce a complete program (or one or more errors). Linking is the process of resolving external identifiers used within a source file, or generating errors when this fails. For example, if a function in one source file calls another function in a different source file, then this linkage needs to be resolved (i.e. checked). This can fail for various reasons: for example, if no function of the given name can be found in any source file; or, if a function with the correct name but incorrect arity (i.e. number of parameters/returns) is found.
Types ¶
type FileUpdate ¶
type FileUpdate struct {
// contains filtered or unexported fields
}
FileUpdate indicates that some change has been made to a given file (including, for example, that the file was removed altogether).
func ChangedFile ¶
func ChangedFile(filename, contents string) FileUpdate
ChangedFile constructs a FileUpdate describing a file that was added or whose contents have changed.
func RemovedFile ¶
func RemovedFile(filename string) FileUpdate
RemovedFile constructs a FileUpdate describing a file that has been deleted from the in-memory store.
type IncrementalCompiler ¶
type IncrementalCompiler struct {
// contains filtered or unexported fields
}
IncrementalCompiler maintains an in-memory view of a set of source files and recompiles them on demand as updates arrive. It is intended to back tools (such as the language server) which need to track the current state of an edited project without ever reading from disk: every file the compiler considers must first be supplied via Apply.
The compiler is not safe for concurrent use; callers are responsible for serialising access (e.g. through a single document-update goroutine).
func NewIncrementalCompiler ¶
func NewIncrementalCompiler() *IncrementalCompiler
NewIncrementalCompiler constructs an IncrementalCompiler with an empty in-memory file store and no compiled program. Source files must be introduced through Apply before any meaningful compilation can occur; calling Apply with no updates on a fresh compiler will simply produce an empty program.
func (*IncrementalCompiler) Apply ¶
func (p *IncrementalCompiler) Apply(updates ...FileUpdate) []source.SyntaxError
Apply a given set of updates to the internal state of this compiler.
func (*IncrementalCompiler) Program ¶
func (p *IncrementalCompiler) Program() ast.Program
Program returns the AST produced by the most recent call to Apply.
func (*IncrementalCompiler) Source ¶
func (p *IncrementalCompiler) Source(filename string) (string, bool)
Source returns the current contents of the file with the given filename from the in-memory store. The second return value is false when no such file is known to the compiler.
func (*IncrementalCompiler) SourceMaps ¶
func (p *IncrementalCompiler) SourceMaps() source.Maps[any]
SourceMaps returns the source-span map produced by the most recent call to Apply, allowing callers to translate AST nodes back to their originating file and span.
type Linker ¶
type Linker struct {
// contains filtered or unexported fields
}
Linker packages together data from the UnlinkedSourceFile's that Compile produced by parsing its input source files, as well as any and all dependencies obtained by following include declarations. As such it contains:
- srcmaps: the list of all srcmap's: these maps are kept disjoint since they each refer to distinct underlying source files;
- declarations: the concatenation of all declarations across all UnlinkedSourceFile's (save for include's) into one slice;
- names: records the names of the declarations; used to detect duplicates
Together these let the linker resolve every declaration's external identifiers (function, memories, constants, type aliases) into concrete indices, producing the fully linked ast.Program.
Note: includes were already followed up on in Compile.
func (*Linker) Join ¶
Join a source map into this linker. Join is just a wrapper for appending some UnlinkedSourceFile's srcmap to the Linker's srcmaps.
func (*Linker) Link ¶
func (p *Linker) Link() (ast.Program, []source.SyntaxError)
Link all components register with this linker
func (*Linker) Register ¶
func (p *Linker) Register(declaration decl.Unresolved)
Register a new declaration with this linker. Register saves the declaration's name and adds it to the linker's full slice of Declaration's
Directories
¶
| Path | Synopsis |
|---|---|
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. |
|
data
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. |
|
decl
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. |
|
symbol
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. |
|
variable
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. |
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. |