HsParrot-0.0.2: Haskell integration with Parrot virtual machineContentsIndex
Language.PIR
Contents
Generated by DrIFT : Look, but Don't Touch. *
Description

Parrot PIR syntax tree.

   All that is gold does not glitter,
   Not all those who wander are lost;
   The old that is strong does not wither,
   Deep roots are not reached by the frost.
Synopsis
type PIR = [Decl]
data Decl
= DeclSub {
dsName :: !SubName
dsFlags :: ![SubFlag]
dsBody :: ![Stmt]
}
| DeclNS {
dnPackage :: !PkgName
dnBody :: ![Decl]
}
| DeclInc {
diFile :: !FilePath
}
| DeclHLL {
dhLang :: !String
dhGroup :: !String
}
data Stmt
= StmtComment !String
| StmtLine !FilePath !Int
| StmtPad ![(VarName, Expression)] ![Stmt]
| StmtRaw !Doc
| StmtIns !Ins
| StmtSub !SubName ![Stmt]
data Ins
= InsLocal !RegType !VarName
| InsNew !LValue !ObjType
| InsBind !LValue !Expression
| InsAssign !LValue !Expression
| InsPrim !(Maybe LValue) !PrimName ![Expression]
| InsFun ![Sig] !Expression ![Expression]
| InsTailFun !Expression ![Expression]
| InsLabel !LabelName
| InsComment !String !(Maybe Ins)
| InsExp !Expression
| InsConst !LValue !ObjType !Expression
data Expression
= ExpLV !LValue
| ExpLit !Literal
data LValue
= VAR !VarName
| PMC !Int
| STR !Int
| INT !Int
| NUM !Int
| KEYED !LValue !Expression
data Literal
= LitStr !String
| LitInt !Integer
| LitNum !Double
data SubFlag
= SubMAIN
| SubLOAD
| SubANON
| SubMETHOD
| SubMULTI ![ObjType]
| SubOUTER !SubName
data RegType
= RegInt
| RegNum
| RegStr
| RegPMC
data ObjType
= PerlScalar
| PerlArray
| PerlHash
| PerlInt
| PerlPair
| PerlRef
| PerlEnv
| Sub
| Closure
| Continuation
| BareType String
type LabelName = String
type SubName = String
type VarName = String
type PrimName = String
type PkgName = String
type CallConv = String
emitStmts :: [Stmt] -> Doc
curPad :: Int
emitRets :: [Sig] -> Doc
emitFun :: (Emit b, Emit c) => CallConv -> b -> [c] -> [Sig] -> Doc
emitArgs :: Emit a => [a] -> Doc
emitFunName :: Emit b => CallConv -> String -> [b] -> [Sig] -> Doc
noArgs :: [Expression]
expKeyed :: LValue -> Expression -> Expression
quoted :: String -> String
include :: PkgName -> Decl
hll :: String -> String -> Decl
(<:=) :: LValue -> Expression -> Ins
(<==) :: LValue -> Expression -> Ins
(<--) :: LValue -> PrimName -> [Expression] -> Ins
(.-) :: PrimName -> [Expression] -> Ins
(<-&) :: [Sig] -> Expression -> [Expression] -> Ins
(.&) :: Expression -> [Expression] -> Ins
lit0 :: Expression
nullPMC :: RegClass a => a
funPMC :: RegClass a => a
rv :: RegClass a => a
arg0 :: RegClass a => a
arg1 :: RegClass a => a
arg2 :: RegClass a => a
arg3 :: RegClass a => a
tempPMC :: RegClass a => a
tempPMC2 :: RegClass a => a
tempSTR :: RegClass a => a
tempSTR2 :: RegClass a => a
tempSTR3 :: RegClass a => a
tempINT :: RegClass a => a
tempINT2 :: RegClass a => a
tempINT3 :: RegClass a => a
tempINT4 :: RegClass a => a
tempNUM :: RegClass a => a
tempNUM2 :: RegClass a => a
class RegClass y where
reg :: LValue -> y
class LiteralClass x where
lit :: x -> Expression
sub :: SubName -> [Sig] -> [Ins] -> Decl
sigList :: [Sig] -> [Expression]
data Sig = MkSig {
sigFlags :: [ArgFlag]
sigIdent :: Expression
}
data ArgFlag
= MkArgFlatten
| MkArgSlurpyArray
| MkArgMaybeFlatten
| MkArgOptional
argVal :: ArgFlag -> Int
maybeFlatten :: Doc
slurpy :: Expression -> Sig
(-->) :: Decl -> [Expression] -> Decl
retSigList :: [Expression] -> [Expression]
vop1 :: SubName -> PrimName -> Decl
vop2 :: SubName -> PrimName -> Decl
vop2keyed :: SubName -> LValue -> Decl
vop1x :: SubName -> PrimName -> (forall a. RegClass a => a) -> (forall b. RegClass b => b) -> Decl
vop1coerce :: SubName -> (forall a. RegClass a => a) -> Decl
vop2x :: SubName -> PrimName -> (forall a. RegClass a => a) -> (forall b. RegClass b => b) -> (forall c. RegClass c => c) -> Decl
vop1ii :: SubName -> PrimName -> Decl
vop1nn :: SubName -> PrimName -> Decl
vop1ss :: SubName -> PrimName -> Decl
vop1si :: SubName -> PrimName -> Decl
vop1is :: SubName -> PrimName -> Decl
vop1ip :: SubName -> PrimName -> Decl
vop2iii :: SubName -> PrimName -> Decl
vop2nnn :: SubName -> PrimName -> Decl
vop2iss :: SubName -> PrimName -> Decl
bare :: VarName -> Expression
collectCC :: [Ins]
callThunkCC :: Expression -> [Ins]
stmtControlLoop :: VarName -> PrimName -> Decl
stmtControlCond :: VarName -> PrimName -> Decl
op2Logical :: VarName -> PrimName -> Decl
escaped :: String -> String
preludePIR :: Doc
class Show x => Emit x where
emit :: x -> Doc
nested :: Emit x => x -> Doc
eqSep :: (Emit a, Emit b, Emit c) => a -> b -> [c] -> Doc
commaSep :: Emit x => [x] -> Doc
Documentation
type PIR = [Decl]
PIR code consists of declarations.
data Decl
Constructors
DeclSubSubroutine declaration
dsName :: !SubName
dsFlags :: ![SubFlag]
dsBody :: ![Stmt]
DeclNSNamespace declaration
dnPackage :: !PkgName
dnBody :: ![Decl]
DeclInc.include directive
diFile :: !FilePath
DeclHLLHLL directive
dhLang :: !String
dhGroup :: !String
show/hide Instances
Eq Decl
Show Decl
Typeable Decl
YAML Decl
Emit DeclEmits PIR code for declarations (namespace, include, or sub declarations).
data Stmt
Constructors
StmtComment !StringComment
StmtLine !FilePath !Int#line directive
StmtPad ![(VarName, Expression)] ![Stmt]Lexical Pad
StmtRaw !DocBackdoor into raw Doc
StmtIns !InsGeneric instructions
StmtSub !SubName ![Stmt]Inner subroutine
show/hide Instances
data Ins
Constructors
InsLocal !RegType !VarName.local directive
InsNew !LValue !ObjTypenew opcode
InsBind !LValue !Expressionset opcode
InsAssign !LValue !Expressionassign opcode
InsPrim !(Maybe LValue) !PrimName ![Expression]Other opcodes
InsFun ![Sig] !Expression ![Expression]Function call
InsTailFun !Expression ![Expression]Tail call
InsLabel !LabelNameLabel
InsComment !String !(Maybe Ins)Comment
InsExp !ExpressionGeneric expressions
InsConst !LValue !ObjType !ExpressionConstant
show/hide Instances
data Expression
Constructors
ExpLV !LValueVariables
ExpLit !LiteralLiterals
show/hide Instances
data LValue
Constructors
VAR !VarNameA variable declared by .local
PMC !IntPMC register n
STR !IntString register n
INT !IntInteger register n
NUM !IntNumber register n
KEYED !LValue !Expression
show/hide Instances
data Literal
Constructors
LitStr !StringA literal string
LitInt !IntegerA literal integer
LitNum !DoubleA literal number
show/hide Instances
Eq Literal
Show Literal
Typeable Literal
YAML Literal
Emit LiteralEmits a literal (a LitStr, LitInt, or LitNum), and escapes if necessary.
data SubFlag
Tags a PIR subroutine definition with @MAIN, @LOAD, @ANON, @METHOD, or @MULTI.
Constructors
SubMAIN
SubLOAD
SubANON
SubMETHOD
SubMULTI ![ObjType]
SubOUTER !SubName
show/hide Instances
Eq SubFlag
Show SubFlag
Typeable SubFlag
YAML SubFlag
Emit SubFlagEmits PIR code for a SubFlag (e.g. :main, :anon, etc.).
data RegType
Constructors
RegIntI (Integer) register
RegNumN (Number) register
RegStrS (String) register
RegPMCP (PMC) register
show/hide Instances
data ObjType
A PMC type, which, for example, can be given as an argument to the new opcode (e.g. new .PerlScalar).
Constructors
PerlScalar
PerlArray
PerlHash
PerlInt
PerlPair
PerlRef
PerlEnv
Sub
Closure
Continuation
BareType String
show/hide Instances
type LabelName = String
type SubName = String
type VarName = String
type PrimName = String
type PkgName = String
type CallConv = String
emitStmts :: [Stmt] -> Doc
curPad :: Int
emitRets :: [Sig] -> Doc
emitFun :: (Emit b, Emit c) => CallConv -> b -> [c] -> [Sig] -> Doc
emitArgs :: Emit a => [a] -> Doc
emitFunName :: Emit b => CallConv -> String -> [b] -> [Sig] -> Doc
noArgs :: [Expression]
expKeyed :: LValue -> Expression -> Expression
quoted :: String -> String
include :: PkgName -> Decl
.include directive.
hll :: String -> String -> Decl
.HLL directive.
(<:=) :: LValue -> Expression -> Ins
Short for InsBind (binding).
(<==) :: LValue -> Expression -> Ins
Short for InsAssign.
(<--) :: LValue -> PrimName -> [Expression] -> Ins
Calls an opcode which returns a value.
(.-) :: PrimName -> [Expression] -> Ins
Calls an opcode, ignoring any return values.
(<-&) :: [Sig] -> Expression -> [Expression] -> Ins
Calls an user-defined sub which returns a list of values.
(.&) :: Expression -> [Expression] -> Ins
Calls an user-defined sub, ignoring any return values.
lit0 :: Expression
Literal zero
nullPMC :: RegClass a => a
$P0 register
funPMC :: RegClass a => a
$P1 register
rv :: RegClass a => a
$P2 register
arg0 :: RegClass a => a
$P10 register
arg1 :: RegClass a => a
$P11 register
arg2 :: RegClass a => a
$P12 register
arg3 :: RegClass a => a
$P13 register
tempPMC :: RegClass a => a
$P8 register
tempPMC2 :: RegClass a => a
$P9 register
tempSTR :: RegClass a => a
$S8 register
tempSTR2 :: RegClass a => a
$S9 register
tempSTR3 :: RegClass a => a
$S10 register
tempINT :: RegClass a => a
$I8 register
tempINT2 :: RegClass a => a
$I9 register
tempINT3 :: RegClass a => a
$I10 register
tempINT4 :: RegClass a => a
$I11 register
tempNUM :: RegClass a => a
$N8 register
tempNUM2 :: RegClass a => a
$N9 register
class RegClass y where
Methods
reg :: LValue -> y
show/hide Instances
class LiteralClass x where
Methods
lit :: x -> Expression
show/hide Instances
sub
:: SubNameName of the subroutine
-> [Sig]Signature
-> [Ins]Subroutine body
-> DeclThe final subroutine declaration
Subroutine declaration.
sigList :: [Sig] -> [Expression]
data Sig
Constructors
MkSig
sigFlags :: [ArgFlag]
sigIdent :: Expression
show/hide Instances
data ArgFlag
Constructors
MkArgFlatten
MkArgSlurpyArray
MkArgMaybeFlatten
MkArgOptional
show/hide Instances
argVal :: ArgFlag -> Int
maybeFlatten :: Doc
slurpy :: Expression -> Sig
Marks a parameter as slurpy.
(-->) :: Decl -> [Expression] -> Decl
Returns from a sub.
retSigList :: [Expression] -> [Expression]
vop1
:: SubNamePerl 6 name of the opcode to wrap
-> PrimNamePIR opcode
-> DeclFinal subroutine declaration
In the case a Perl 6 builtin corresponds exactly to a PIR opcode, you can use vop1 to create an appropriate wrapper for an opcode expecting one argument.
vop2
:: SubNamePerl 6 name of the opcode to wrap
-> PrimNamePIR opcode
-> DeclFinal subroutine declaration
In the case a Perl 6 builtin corresponds exactly to a PIR opcode, you can use vop2 to create an appropriate wrapper for an opcode expecting two arguments.
vop2keyed
:: SubNamePerl 6 name of the sub to create
-> LValueIntermediate register to convert the index to (e.g. tempINT or tempSTR)
-> DeclFinal subroutine declaration
Creates a sub which accepts a thing which allows keyed access (for example aggregates) and an index.
vop1x
:: SubNamePerl 6 name of the sub to create
-> PrimNameOpcode to wrap
-> (forall a. RegClass a => a)Register to use for the return value of the op
-> (forall b. RegClass b => b)Register type to convert the parameter to
-> DeclFinal subroutine declaration
Generic wrapper for unary opcodes.
vop1coerce
:: SubNamePerl 6 name of the sub to create
-> (forall a. RegClass a => a)Register type to convert the parameter to
-> DeclFinal subroutine declaration
Generic wrapper for coercion/context forcing (used by &prefix:<+>, &prefix:<~>, etc.)
vop2x
:: SubNamePerl 6 name of the sub to create
-> PrimNameOpcode to wrap
-> (forall a. RegClass a => a)Register to use for the return value of the op
-> (forall b. RegClass b => b)Register type to convert the first parameter to
-> (forall c. RegClass c => c)Register type to convert the second parameter to
-> DeclFinal subroutine declaration
Generic wrapper for two-ary opcodes.
vop1ii :: SubName -> PrimName -> Decl
Wrapper for an opcode which accepts and returns an I register.
vop1nn :: SubName -> PrimName -> Decl
Wrapper for an opcode which accepts and returns a N register.
vop1ss :: SubName -> PrimName -> Decl
Wrapper for an opcode which accepts and returns a S register.
vop1si :: SubName -> PrimName -> Decl
Wrapper for an opcode which returns a S register and accepts a I register.
vop1is :: SubName -> PrimName -> Decl
Wrapper for an opcode which returns a I register and accepts a S register.
vop1ip :: SubName -> PrimName -> Decl
Wrapper for an opcode which returns a I register and accepts a P register.
vop2iii :: SubName -> PrimName -> Decl
Wrapper for an opcode which accepts and returns I registers.
vop2nnn :: SubName -> PrimName -> Decl
Wrapper for an opcode which accepts and returns N registers.
vop2iss :: SubName -> PrimName -> Decl
Wrapper for an opcode which accepts two S registers and returns a native integer (I register).
bare :: VarName -> Expression
collectCC :: [Ins]
callThunkCC :: Expression -> [Ins]
stmtControlLoop
:: VarNamePerl 6 name of the new sub
-> PrimNamePIR opcode to use for branching
-> DeclFinal declaration of the sub
Creates appropriate &statement_control:foo subroutines.
stmtControlCond
:: VarNamePerl 6 name of the new sub
-> PrimNamePIR opcode to use for branching
-> DeclFinal declaration of the sub
Creates appropriate &statement_control:foo subroutines.
op2Logical
:: VarNamePerl 6 name of the sub to create
-> PrimNamePIR opcode to use (if, unless)
-> DeclFinal declaration of the sub
Creates appropriate &infix:foo subs for logical operators (||, &&, etc.).
escaped :: String -> String
Escapes characters which have a special meaning in PIR.
preludePIR :: Doc
The Prelude, defining primitives like &say, &infix:+, etc.
Generated by DrIFT : Look, but Don't Touch. *
class Show x => Emit x where
Methods
emit :: x -> Doc
show/hide Instances
Emit Int
Emit String
Emit Doc
Emit ObjTypeEmits PIR code for an ObjType (e.g. .PerlScalar).
Emit RegType
Emit SubFlagEmits PIR code for a SubFlag (e.g. :main, :anon, etc.).
Emit LiteralEmits a literal (a LitStr, LitInt, or LitNum), and escapes if necessary.
Emit LValue
Emit Expression
Emit Ins
Emit Stmt
Emit DeclEmits PIR code for declarations (namespace, include, or sub declarations).
Emit a => Emit [a]
Emit [ArgFlag]
Emit a => Emit (Maybe a)
nested :: Emit x => x -> Doc
eqSep :: (Emit a, Emit b, Emit c) => a -> b -> [c] -> Doc
commaSep :: Emit x => [x] -> Doc
Produced by Haddock version 2.7.2