SourceFile

class SourceFile

Maintains metadata (for example, file path) about an input stream and gives access to its contents.

Parameters

path

Description of where the source file came from (e.g. a file path, "stdin", etc.).

contents

File contents.

Types

Companion
Link copied to clipboard
object Companion

Functions

createReader
Link copied to clipboard
fun createReader(): Reader

Returns a new Reader for accessing the contents of the file.

Properties

length
Link copied to clipboard
val length: Int

Number of Chars (unicode code units) in the file.

numberOfLines
Link copied to clipboard
val numberOfLines: Int

Number of lines in the file.

path
Link copied to clipboard
val path: String

Extensions

compile
Link copied to clipboard
fun SourceFile.compile(backend: Backend, costRegime: SimpleCostRegime = SimpleCostRegime.WAN, saveLabelConstraintGraph: (graphWriter: (Writer) -> Unit) -> Unit? = null, saveInferredLabels: File? = null, saveEstimatedCost: File? = null, saveProtocolAssignment: File? = null): ProgramNode

Similar to SourceFile.compileToKotlin, but returns a program for the interpreter.

compileToKotlin
Link copied to clipboard
fun SourceFile.compileToKotlin(fileName: String, packageName: String, backend: Backend, costRegime: SimpleCostRegime = SimpleCostRegime.WAN, saveLabelConstraintGraph: (graphWriter: (Writer) -> Unit) -> Unit? = null, saveInferredLabels: File? = null, saveEstimatedCost: File? = null, saveProtocolAssignment: File? = null): FileSpec

Compile this source file to a Kotlin program.

parse
Link copied to clipboard
fun SourceFile.parse(protocolParsers: Map<ProtocolName, ProtocolParser<Protocol>> = defaultProtocolParsers): ProgramNode

Parses this source file and returns the AST.

parseLabel
Link copied to clipboard
fun SourceFile.parseLabel(): LabelExpression

Parses this source file as a security label.