ballerina/bir module

Module Detail

Records

Record Description
AsyncCall
BArrayType
BAttachedFunction
BErrorType
BFutureType
BInvokableType
BMapType
BObjectField
BObjectType
BRecordField
BRecordType
BTupleType
BUnionType
BasicBlock
BinaryOp
Branch
Call
ConstPool
ConstantLoad
DiagnosticPos
ErrorEntry
FPLoad
FieldAccess
Function
GOTO
GlobalVariableDcl
ImportModule
Instruction
IsLike
ModuleID
Move
Name
NewArray
NewError
NewInstance
NewMap
Package
Panic
Return
Self
Terminator
TypeCast
TypeDef
TypeTest
VarRef
VariableDcl
Wait

Objects

Object Description
BIRContext

TODO Docs

BirChannelReader
BirEmitter
ChannelReader
ConstPoolParser
FuncBodyParser
PackageParser
TypeParser

Functions

Function Description
parseDiagnosticPos
parseVarKind
parseVarScope
parseVisibility
serialize

Type Definitions

Type Values Description
ArgVarKind VAR_KIND_ARG
ArrayState ARRAY_STATE_UNSEALED | ARRAY_STATE_OPEN_SEALED | ARRAY_STATE_CLOSED_SEALED
BJSONType TYPE_JSON
BType Self | BUnionType | BTypeString | BTypeNone | BTypeNil | BTypeInt | BTypeFloat | BTypeByte | BTypeBoolean | BTypeAnyData | BTypeAny | BTupleType | BRecordType | BObjectType | BMapType | BJSONType | BInvokableType | BFutureType | BErrorType | BArrayType
BTypeAny TYPE_ANY
BTypeAnyData TYPE_ANYDATA
BTypeBoolean TYPE_BOOLEAN
BTypeByte TYPE_BYTE
BTypeFloat TYPE_FLOAT
BTypeInt TYPE_INT
BTypeNil TYPE_NIL
BTypeNone TYPE_NONE
BTypeString TYPE_STRING
BinaryOpInstructionKind BINARY_SUB | BINARY_OR | BINARY_NOT_EQUAL | BINARY_MUL | BINARY_LESS_THAN | BINARY_LESS_EQUAL | BINARY_GREATER_THAN | BINARY_GREATER_EQUAL | BINARY_EQUAL | BINARY_DIV | BINARY_AND | BINARY_ADD
GlobalVarKind VAR_KIND_GLOBAL
InstructionKind INS_KIND_TYPE_TEST | INS_KIND_TYPE_CAST | INS_KIND_OBJECT_STORE | INS_KIND_OBJECT_LOAD | INS_KIND_NEW_MAP | INS_KIND_NEW_INST | INS_KIND_NEW_ERROR | INS_KIND_NEW_ARRAY | INS_KIND_MOVE | INS_KIND_MAP_STORE | INS_KIND_MAP_LOAD | INS_KIND_IS_LIKE | INS_KIND_FP_LOAD | INS_KIND_CONST_LOAD | INS_KIND_ARRAY_STORE | INS_KIND_ARRAY_LOAD | BinaryOpInstructionKind
LocalVarKind VAR_KIND_LOCAL
ReturnVarKind VAR_KIND_RETURN
SelfVarKind VAR_KIND_SELF
TempVarKind VAR_KIND_TEMP
TerminatorKind TERMINATOR_WAIT | TERMINATOR_RETURN | TERMINATOR_PANIC | TERMINATOR_GOTO | TERMINATOR_CALL | TERMINATOR_BRANCH | TERMINATOR_ASYNC_CALL
VarKind TempVarKind | SelfVarKind | ReturnVarKind | LocalVarKind | GlobalVarKind | ArgVarKind
VarScope VAR_SCOPE_GLOBAL | VAR_SCOPE_FUNCTION
Visibility VISIBILITY_PUBLIC | VISIBILITY_PRIVATE | VISIBILITY_PACKAGE_PRIVATE

public type AsyncCall

Field Name Data Type Default Value Description
pos bir:DiagnosticPos
args bir:VarRef?[]
kind GOTO|CALL|BRANCH|RETURN|ASYNC_CALL|PANIC|WAIT
lhsOp bir:VarRef?
pkgID bir:ModuleID
name bir:Name
thenBB bir:BasicBlock

public type BAttachedFunction

Field Name Data Type Default Value Description
name bir:Name {}
funcType bir:BInvokableType
visibility PACKAGE_PRIVATE|PRIVATE|PUBLIC

public type BObjectType

Field Name Data Type Default Value Description
name bir:Name {}
isAbstract boolean false
fields bir:BObjectField?[] []
attachedFunctions bir:BAttachedFunction?[] []

public type BasicBlock

Field Name Data Type Default Value Description
id bir:Name {}
instructions bir:Instruction?[] []
terminator bir:Terminator {pos: {},kind: RETURN}

public type Branch

Field Name Data Type Default Value Description
pos bir:DiagnosticPos
falseBB bir:BasicBlock
kind GOTO|CALL|BRANCH|RETURN|ASYNC_CALL|PANIC|WAIT
op bir:VarRef
trueBB bir:BasicBlock

public type Call

Field Name Data Type Default Value Description
pos bir:DiagnosticPos
args bir:VarRef?[]
kind GOTO|CALL|BRANCH|RETURN|ASYNC_CALL|PANIC|WAIT
lhsOp bir:VarRef?
pkgID bir:ModuleID
name bir:Name
isVirtual boolean
thenBB bir:BasicBlock

public type ConstPool

Field Name Data Type Default Value Description
packages bir:ModuleID[] []
strings string[] []
ints int[] []
floats float[] []

public type DiagnosticPos

Field Name Data Type Default Value Description
sLine int -1
eLine int -1
sCol int -1
eCol int -1
sourceFileName string

public type ErrorEntry

Field Name Data Type Default Value Description
trapBB bir:BasicBlock
errorOp bir:VarRef

public type Function

Field Name Data Type Default Value Description
pos bir:DiagnosticPos
argsCount int 0
basicBlocks bir:BasicBlock?[] []
errorEntries bir:ErrorEntry?[] []
isDeclaration boolean false
isInterface boolean false
localVars bir:VariableDcl?[] []
name bir:Name {}
typeValue bir:BInvokableType {}
visibility PACKAGE_PRIVATE|PRIVATE|PUBLIC PACKAGE_PRIVATE

public type GOTO

Field Name Data Type Default Value Description
pos bir:DiagnosticPos
kind GOTO|CALL|BRANCH|RETURN|ASYNC_CALL|PANIC|WAIT
targetBB bir:BasicBlock

public type ImportModule

Field Name Data Type Default Value Description
modOrg bir:Name
modName bir:Name
modVersion bir:Name

public type ModuleID

Field Name Data Type Default Value Description
org string
name string
modVersion string
isUnnamed boolean false
sourceFilename string

public type Name

Field Name Data Type Default Value Description
value string

public type Panic

Field Name Data Type Default Value Description
pos bir:DiagnosticPos
kind GOTO|CALL|BRANCH|RETURN|ASYNC_CALL|PANIC|WAIT
errorOp bir:VarRef

public type Return

Field Name Data Type Default Value Description
pos bir:DiagnosticPos
kind GOTO|CALL|BRANCH|RETURN|ASYNC_CALL|PANIC|WAIT

public type Terminator

Field Name Data Type Default Value Description
pos bir:DiagnosticPos
kind GOTO|CALL|BRANCH|RETURN|ASYNC_CALL|PANIC|WAIT

public type Wait

Field Name Data Type Default Value Description
pos bir:DiagnosticPos
kind GOTO|CALL|BRANCH|RETURN|ASYNC_CALL|PANIC|WAIT
lhsOp bir:VarRef
exprList bir:VarRef?[]

public function parseDiagnosticPos(bir:BirChannelReader reader) returns (DiagnosticPos)

Parameter Name Data Type Default Value Description
reader bir:BirChannelReader
Return Type Description
DiagnosticPos

public function parseVarKind(bir:BirChannelReader reader) returns (VarKind)

Parameter Name Data Type Default Value Description
reader bir:BirChannelReader
Return Type Description
VarKind

public function parseVarScope(bir:BirChannelReader reader) returns (VarScope)

Parameter Name Data Type Default Value Description
reader bir:BirChannelReader
Return Type Description
VarScope

public function parseVisibility(bir:BirChannelReader reader) returns (Visibility)

Parameter Name Data Type Default Value Description
reader bir:BirChannelReader
Return Type Description
Visibility

public function serialize(int|boolean|any|()|byte|float|string|bir:BUnionType|bir:BTupleType|bir:BInvokableType|bir:BArrayType|bir:BRecordType|bir:BObjectType|bir:BMapType|bir:BErrorType|anydata|none|bir:BFutureType|json|bir:Self? bType) returns (string)

Parameter Name Data Type Default Value Description
bType int|boolean|any|()|byte|float|string|bir:BUnionType|bir:BTupleType|bir:BInvokableType|bir:BArrayType|bir:BRecordType|bir:BObjectType|bir:BMapType|bir:BErrorType|anydata|none|bir:BFutureType|json|bir:Self?
Return Type Description
string

public type BIRContext object

TODO Docs

  • <BIRContext> lookupBIRModule(bir:ModuleID modId) returns (Package)

    Parameter Name Data Type Default Value Description
    modId bir:ModuleID
    Return Type Description
    Package

public type BirChannelReader object

  • <BirChannelReader> __init(bir:ChannelReader reader, bir:ConstPool cp)

    Parameter Name Data Type Default Value Description
    reader bir:ChannelReader
    cp bir:ConstPool
  • <BirChannelReader> readBType() returns (BType)

    Return Type Description
    BType
  • <BirChannelReader> readStringCpRef() returns (string)

    Return Type Description
    string
  • <BirChannelReader> readIntCpRef() returns (int)

    Return Type Description
    int
  • <BirChannelReader> readFloatCpRef() returns (float)

    Return Type Description
    float
  • <BirChannelReader> readModuleIDCpRef() returns (ModuleID)

    Return Type Description
    ModuleID
  • <BirChannelReader> readBoolean() returns (boolean)

    Return Type Description
    boolean
  • <BirChannelReader> readInt8() returns (int)

    Return Type Description
    int
  • <BirChannelReader> readInt32() returns (int)

    Return Type Description
    int
  • <BirChannelReader> readInt64() returns (int)

    Return Type Description
    int
  • <BirChannelReader> readString() returns (string)

    Return Type Description
    string
  • <BirChannelReader> readByteArray(int len) returns (byte[])

    Parameter Name Data Type Default Value Description
    len int
    Return Type Description
    byte[]

public type BirEmitter object

  • <BirEmitter> __init(bir:Package pkg)

    Parameter Name Data Type Default Value Description
    pkg bir:Package
  • <BirEmitter> emitPackage()

public type ChannelReader object

  • <ChannelReader> __init(io:ReadableByteChannel byteChannel)

    Parameter Name Data Type Default Value Description
    byteChannel io:ReadableByteChannel
  • <ChannelReader> readBoolean() returns (boolean)

    Return Type Description
    boolean
  • <ChannelReader> readInt8() returns (int)

    Return Type Description
    int
  • <ChannelReader> readInt32() returns (int)

    Return Type Description
    int
  • <ChannelReader> readInt64() returns (int)

    Return Type Description
    int
  • <ChannelReader> readFloat64() returns (float)

    Return Type Description
    float
  • <ChannelReader> readString() returns (string)

    Return Type Description
    string
  • <ChannelReader> readByteArray(int len) returns (byte[])

    Parameter Name Data Type Default Value Description
    len int
    Return Type Description
    byte[]

public type ConstPoolParser object

  • <ConstPoolParser> __init(bir:ChannelReader reader)

    Parameter Name Data Type Default Value Description
    reader bir:ChannelReader
  • <ConstPoolParser> parse() returns (ConstPool)

    Return Type Description
    ConstPool
  • <ConstPoolParser> parseConstPoolEntry()

public type FuncBodyParser object

  • <FuncBodyParser> __init(bir:BirChannelReader reader, bir:TypeParser typeParser, map<bir:VariableDcl> globalVarMap, map<bir:VariableDcl> localVarMap, bir:TypeDef?[] typeDefs)

    Parameter Name Data Type Default Value Description
    reader bir:BirChannelReader
    typeParser bir:TypeParser
    globalVarMap map
    localVarMap map
    typeDefs bir:TypeDef?[]
  • <FuncBodyParser> parseBB() returns (BasicBlock)

    Return Type Description
    BasicBlock
  • <FuncBodyParser> parseEE() returns (ErrorEntry)

    Return Type Description
    ErrorEntry
  • <FuncBodyParser> parseInstruction() returns (Instruction)

    Return Type Description
    Instruction
  • <FuncBodyParser> parseTerminator() returns (Terminator)

    Return Type Description
    Terminator
  • <FuncBodyParser> parseVarRef() returns (VarRef)

    Return Type Description
    VarRef
  • <FuncBodyParser> parseBBRef() returns (BasicBlock)

    Return Type Description
    BasicBlock
  • <FuncBodyParser> parseBinaryOpInstruction(int kindTag, bir:DiagnosticPos pos) returns (BinaryOp)

    Parameter Name Data Type Default Value Description
    kindTag int
    pos bir:DiagnosticPos
    Return Type Description
    BinaryOp

public type PackageParser object

  • <PackageParser> __init(bir:BirChannelReader reader, bir:TypeParser typeParser)

    Parameter Name Data Type Default Value Description
    reader bir:BirChannelReader
    typeParser bir:TypeParser
  • <PackageParser> parseVariableDcl() returns (VariableDcl)

    Return Type Description
    VariableDcl
  • <PackageParser> parseFunction(bir:TypeDef?[] typeDefs) returns (Function)

    Parameter Name Data Type Default Value Description
    typeDefs bir:TypeDef?[]
    Return Type Description
    Function
  • <PackageParser> parsePackage() returns (Package)

    Return Type Description
    Package
  • <PackageParser> parseSig(string sig) returns (BInvokableType)

    Parameter Name Data Type Default Value Description
    sig string
    Return Type Description
    BInvokableType

public type TypeParser object

Field Name Data Type Default Value Description
TYPE_TAG_INT int 1
TYPE_TAG_BYTE int TYPE_TAG_INT + 1
TYPE_TAG_FLOAT int TYPE_TAG_BYTE + 1
TYPE_TAG_DECIMAL int TYPE_TAG_FLOAT + 1
TYPE_TAG_STRING int TYPE_TAG_DECIMAL + 1
TYPE_TAG_BOOLEAN int TYPE_TAG_STRING + 1
TYPE_TAG_JSON int TYPE_TAG_BOOLEAN + 1
TYPE_TAG_XML int TYPE_TAG_JSON + 1
TYPE_TAG_TABLE int TYPE_TAG_XML + 1
TYPE_TAG_NIL int TYPE_TAG_TABLE + 1
TYPE_TAG_ANYDATA int TYPE_TAG_NIL + 1
TYPE_TAG_RECORD int TYPE_TAG_ANYDATA + 1
TYPE_TAG_TYPEDESC int TYPE_TAG_RECORD + 1
TYPE_TAG_STREAM int TYPE_TAG_TYPEDESC + 1
TYPE_TAG_MAP int TYPE_TAG_STREAM + 1
TYPE_TAG_INVOKABLE int TYPE_TAG_MAP + 1
TYPE_TAG_ANY int TYPE_TAG_INVOKABLE + 1
TYPE_TAG_ENDPOINT int TYPE_TAG_ANY + 1
TYPE_TAG_ARRAY int TYPE_TAG_ENDPOINT + 1
TYPE_TAG_UNION int TYPE_TAG_ARRAY + 1
TYPE_TAG_PACKAGE int TYPE_TAG_UNION + 1
TYPE_TAG_NONE int TYPE_TAG_PACKAGE + 1
TYPE_TAG_VOID int TYPE_TAG_NONE + 1
TYPE_TAG_XMLNS int TYPE_TAG_VOID + 1
TYPE_TAG_ANNOTATION int TYPE_TAG_XMLNS + 1
TYPE_TAG_XML_ATTRIBUTES int TYPE_TAG_ANNOTATION + 1
TYPE_TAG_SEMANTIC_ERROR int TYPE_TAG_XML_ATTRIBUTES + 1
TYPE_TAG_ERROR int TYPE_TAG_SEMANTIC_ERROR + 1
TYPE_TAG_ITERATOR int TYPE_TAG_ERROR + 1
TYPE_TAG_TUPLE int TYPE_TAG_ITERATOR + 1
TYPE_TAG_FUTURE int TYPE_TAG_TUPLE + 1
TYPE_TAG_INTERMEDIATE_COLLECTION int TYPE_TAG_FUTURE + 1
TYPE_TAG_FINITE int TYPE_TAG_INTERMEDIATE_COLLECTION + 1
TYPE_TAG_OBJECT int TYPE_TAG_FINITE + 1
TYPE_TAG_BYTE_ARRAY int TYPE_TAG_OBJECT + 1
TYPE_TAG_FUNCTION_POINTER int TYPE_TAG_BYTE_ARRAY + 1
TYPE_TAG_CHANNEL int TYPE_TAG_BYTE_ARRAY + 1
TYPE_TAG_SERVICE int TYPE_TAG_OBJECT
TYPE_TAG_SELF int 50
  • <TypeParser> __init(bir:BirChannelReader reader)

    Parameter Name Data Type Default Value Description
    reader bir:BirChannelReader
  • <TypeParser> parseType() returns (BType)

    Return Type Description
    BType