Language.PIR
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.
- type PIR = [Decl]
- data Decl
- data 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
- data LValue
- data Literal
- data SubFlag
- data RegType
- data ObjType
- 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
- class LiteralClass x where
- lit :: x -> Expression
- sub :: SubName -> [Sig] -> [Ins] -> Decl
- sigList :: [Sig] -> [Expression]
- data Sig = MkSig {
- sigFlags :: [ArgFlag]
- sigIdent :: Expression
- data ArgFlag
- 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
- nested :: Emit x => x -> Doc
- eqSep :: (Emit a, Emit b, Emit c) => a -> b -> [c] -> Doc
- commaSep :: Emit x => [x] -> Doc
Documentation
Constructors
| InsLocal !RegType !VarName |
|
| InsNew !LValue !ObjType |
|
| InsBind !LValue !Expression |
|
| InsAssign !LValue !Expression |
|
| InsPrim !(Maybe LValue) !PrimName ![Expression] | Other opcodes |
| InsFun ![Sig] !Expression ![Expression] | Function call |
| InsTailFun !Expression ![Expression] | Tail call |
| InsLabel !LabelName | Label |
| InsComment !String !(Maybe Ins) | Comment |
| InsExp !Expression | Generic expressions |
| InsConst !LValue !ObjType !Expression | Constant |
data Expression Source
Tags a PIR subroutine definition with @MAIN, @LOAD, @ANON,
@METHOD, or @MULTI.
A PMC type, which, for example, can be given as an argument to the new
opcode (e.g. new .PerlScalar).
noArgs :: [Expression]Source
expKeyed :: LValue -> Expression -> ExpressionSource
(.-) :: PrimName -> [Expression] -> InsSource
Calls an opcode, ignoring any return values.
(<-&) :: [Sig] -> Expression -> [Expression] -> InsSource
Calls an user-defined sub which returns a list of values.
(.&) :: Expression -> [Expression] -> InsSource
Calls an user-defined sub, ignoring any return values.
Literal zero
class LiteralClass x whereSource
Methods
lit :: x -> ExpressionSource
Arguments
| :: SubName | Name of the subroutine |
| -> [Sig] | Signature |
| -> [Ins] | Subroutine body |
| -> Decl | The final subroutine declaration |
Subroutine declaration.
sigList :: [Sig] -> [Expression]Source
Constructors
| MkSig | |
Fields
| |
Constructors
| MkArgFlatten | |
| MkArgSlurpyArray | |
| MkArgMaybeFlatten | |
| MkArgOptional |
slurpy :: Expression -> SigSource
Marks a parameter as slurpy.
(-->) :: Decl -> [Expression] -> DeclSource
Returns from a sub.
retSigList :: [Expression] -> [Expression]Source
Arguments
| :: SubName | Perl 6 name of the opcode to wrap |
| -> PrimName | PIR opcode |
| -> Decl | Final 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.
Arguments
| :: SubName | Perl 6 name of the opcode to wrap |
| -> PrimName | PIR opcode |
| -> Decl | Final 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.
Arguments
| :: SubName | Perl 6 name of the sub to create |
| -> LValue | Intermediate register to convert the index to
(e.g. |
| -> Decl | Final subroutine declaration |
Creates a sub which accepts a thing which allows keyed access (for example aggregates) and an index.
Arguments
| :: SubName | Perl 6 name of the sub to create |
| -> PrimName | Opcode 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 |
| -> Decl | Final subroutine declaration |
Generic wrapper for unary opcodes.
Arguments
| :: SubName | Perl 6 name of the sub to create |
| -> (forall a. RegClass a => a) | Register type to convert the parameter to |
| -> Decl | Final subroutine declaration |
Generic wrapper for coercion/context forcing (used by &prefix:<+>,
&prefix:<~>, etc.)
Arguments
| :: SubName | Perl 6 name of the sub to create |
| -> PrimName | Opcode 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 |
| -> Decl | Final subroutine declaration |
Generic wrapper for two-ary opcodes.
vop1ii :: SubName -> PrimName -> DeclSource
Wrapper for an opcode which accepts and returns an I register.
vop1nn :: SubName -> PrimName -> DeclSource
Wrapper for an opcode which accepts and returns a N register.
vop1ss :: SubName -> PrimName -> DeclSource
Wrapper for an opcode which accepts and returns a S register.
vop1si :: SubName -> PrimName -> DeclSource
Wrapper for an opcode which returns a S register and accepts a I register.
vop1is :: SubName -> PrimName -> DeclSource
Wrapper for an opcode which returns a I register and accepts a S register.
vop1ip :: SubName -> PrimName -> DeclSource
Wrapper for an opcode which returns a I register and accepts a P register.
vop2iii :: SubName -> PrimName -> DeclSource
Wrapper for an opcode which accepts and returns I registers.
vop2nnn :: SubName -> PrimName -> DeclSource
Wrapper for an opcode which accepts and returns N registers.
vop2iss :: SubName -> PrimName -> DeclSource
Wrapper for an opcode which accepts two S registers and returns a native
integer (I register).
bare :: VarName -> ExpressionSource
callThunkCC :: Expression -> [Ins]Source
Arguments
| :: VarName | Perl 6 name of the new sub |
| -> PrimName | PIR opcode to use for branching |
| -> Decl | Final declaration of the sub |
Creates appropriate &statement_control:foo subroutines.
Arguments
| :: VarName | Perl 6 name of the new sub |
| -> PrimName | PIR opcode to use for branching |
| -> Decl | Final declaration of the sub |
Creates appropriate &statement_control:foo subroutines.
Arguments
| :: VarName | Perl 6 name of the sub to create |
| -> PrimName | PIR opcode to use ( |
| -> Decl | Final declaration of the sub |
Creates appropriate &infix:foo subs for logical operators (||, &&,
etc.).
The Prelude, defining primitives like &say, &infix:+, etc.
Generated by DrIFT : Look, but Don't Touch. *
class Show x => Emit x whereSource
Instances
| Emit Int | |
| Emit String | |
| Emit Doc | |
| Emit ObjType | Emits PIR code for an |
| Emit RegType | |
| Emit SubFlag | Emits PIR code for a |
| Emit Literal | Emits a literal (a |
| Emit LValue | |
| Emit Expression | |
| Emit Ins | |
| Emit Stmt | |
| Emit Decl | Emits PIR code for declarations (namespace, include, or sub declarations). |
| Emit a => Emit [a] | |
| Emit [ArgFlag] | |
| Emit a => Emit (Maybe a) |