
CodeAsm is used to assemble the fcode instructions of an Expr or Block.
Slots
-
private Void addStr(ShortcutExpr expr, Bool topLevel)
Assemble code to build a string using sys::StrBuf.
-
private Void addToErrTable(Int start, Int end, Int handler, CType errType)
-
private Void asExpr(TypeCheckExpr tc)
-
private Void assign(BinaryExpr expr)
Simple assignment using =
-
private Void assignField(BinaryExpr assign)
-
private Void assignLocalVar(BinaryExpr assign)
-
private Void backpatch(Int pos, Int mark := this.code.size)
Backpacth the mark of forward jump using the given pos which was returned by jump(). If mark is defaulted, then we use the current instruction as the mark.
- block
-
private Void boolLiteral(LiteralExpr expr)
-
private Void cast(TypeCheckExpr tc)
- code
-
Buf code
-
private Int[] computeTableRange(SwitchStmt stmt)
Compute the range of this switch and return as a list of
[min, max]
if the switch is a candidate for a table switch as a series of contiguous (or near contiguous) cases which can be represented an offset into a jump table. Return null if the switch is not numeric or too sparse to use as a table switch. -
private Void decimalLiteral(LiteralExpr expr)
-
private Void durationLiteral(LiteralExpr expr)
-
private Void elvis(BinaryExpr binary)
-
private Void equalsSwitchStmt(SwitchStmt stmt)
- errCount
-
Int errCount
- errTable
-
Buf errTable
- expr
- finishCode
-
Buf finishCode()
Finish writing out the exception handling table
- finishErrTable
-
Buf finishErrTable()
Finish writing out the exception handling table
- finishLines
-
Buf finishLines()
Finish writing out the line number table
-
private Void floatLiteral(LiteralExpr expr)
- fpod
-
FPod fpod
-
private Bool inProtectedRegion()
-
private Void intLiteral(LiteralExpr expr)
-
private Void invokeCall(CallExpr call, Bool leave := call.leave)
-
private Void isExpr(TypeCheckExpr tc)
-
private Void isnotExpr(TypeCheckExpr tc)
-
private Int jump(FOp op, Int mark := 65535)
Add the specified jump opcode and two bytes for the jump location. If a backward jump then pass the mark; if a a forward jump we return the code pos to backpatch the mark later.
- lastLine
-
Int lastLine := -1
- leavesToReturn
-
Int[] leavesToReturn
-
private Void line(Location loc)
Map the opcode we are getting ready to add to the specified line number
- lineCount
-
Int lineCount
- lines
-
Buf lines
-
private Void listLiteral(ListLiteralExpr list)
-
private Void loadField(FieldExpr fexpr, Bool dupTarget := false)
-
private Void loadLocalVar(LocalVarExpr var)
-
private Void localVarDefStmt(LocalDefStmt stmt)
- location
-
Location location
- loopStack
-
Loop[] loopStack
- make
-
private Void mapLiteral(MapLiteralExpr map)
-
private Int mark()
Get the current location as a mark to use for backwards jump.
-
private Void notSame(BinaryExpr binary)
-
private Void nullLiteral()
- op
-
Void op(FOp op, Int arg := null)
Append a opcode with option two byte argument.
- protectedRegions
-
ProtectedRegion[] protectedRegions
-
private Void rangeLiteral(RangeLiteralExpr r)
- returnLocal
-
MethodVar returnLocal
-
private Void returnStmt(ReturnStmt stmt)
-
private Void same(BinaryExpr binary)
-
private Void shortcut(ShortcutExpr call)
-
private Void shortcutAssign(ShortcutExpr c)
This method is used for complex assignments: prefix/postfix increment and special dual assignment operators like "+=".
-
private Void slotLiteral(SlotLiteralExpr expr)
- stmt
-
private Void storeLocalVar(LocalVarExpr var)
-
private Void strLiteral(LiteralExpr expr)
-
private Void switchStmt(SwitchStmt stmt)
-
private Void tableSwitchStmt(SwitchStmt stmt, Int min, Int max)
-
private Void ternary(TernaryExpr ternary)
-
private Int tryCatch(Catch c, Int start, Int end, ProtectedRegion region)
-
private Void typeLiteral(LiteralExpr expr)
-
private Void uriLiteral(LiteralExpr expr)
-
private Void withBlock(WithBlockExpr withBlock)
More Info
Slots
- addStr
- addToErrTable
- and
- asExpr
- assign
- assignField
- assignLocalVar
- backpatch
- block
- boolLiteral
- breakOrContinueStmt
- call
- cast
- cmpNotNull
- cmpNull
- code
- computeTableRange
- cond
- condEnd
- decimalLiteral
- durationLiteral
- dynamicCall
- elvis
- equalsSwitchStmt
- errCount
- errTable
- expr
- finishCode
- finishErrTable
- finishLines
- floatLiteral
- forStmt
- fpod
- ifStmt
- inProtectedRegion
- intLiteral
- invokeCall
- isEmptyStrLiteral
- isExpr
- isnotExpr
- jump
- lastLine
- leavesToReturn
- line
- lineCount
- lines
- listLiteral
- loadField
- loadLocalVar
- localVarDefStmt
- location
- loopStack
- make
- mapLiteral
- mark
- not
- notSame
- nullLiteral
- op
- or
- protectedRegions
- rangeLiteral
- returnLocal
- returnStmt
- same
- shortcut
- shortcutAssign
- shortcutOp
- slotLiteral
- stmt
- storeField
- storeLocalVar
- strLiteral
- switchBlock
- switchStmt
- tableSwitchStmt
- ternary
- throwStmt
- tryCatch
- tryStmt
- typeLiteral
- uriLiteral
- whileStmt
- withBlock