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.
- blockSource
-
private Void boolLiteral(LiteralExpr expr)
- codeSource
-
Buf code
-
private Void coerce(TypeCheckExpr tc)
-
private Void compareOp(Obj lhs, FOp opCode, Expr rhs)
Generate a comparison. The lhs can be either a ctype or an expr.
-
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)
- errCountSource
-
Int errCount
- errTableSource
-
Buf errTable
- exprSource
- finishCodeSource
-
Buf finishCode()
Finish writing out the exception handling table
- finishErrTableSource
-
Buf finishErrTable()
Finish writing out the exception handling table
- finishLinesSource
-
Buf finishLines()
Finish writing out the line number table
-
private Void floatLiteral(LiteralExpr expr)
- fpodSource
-
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.
- lastLineSource
-
Int lastLine := -1
- leavesToReturnSource
-
Int[]? leavesToReturn
-
private Void line(Location loc)
Map the opcode we are getting ready to add to the specified line number
- lineCountSource
-
Int lineCount
- linesSource
-
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)
- locationSource
-
Location location
- loopStackSource
-
Loop[] loopStack
- makeSource
-
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()
- opSource
-
Void op(FOp op, Int? arg := null)
Append a opcode with option two byte argument.
- opTypeSource
-
Void opType(FOp opcode, CType arg)
Append a opcode with a type argument.
- protectedRegionsSource
-
ProtectedRegion[]? protectedRegions
-
private Void rangeLiteral(RangeLiteralExpr r)
- returnLocalSource
-
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)
- stmtSource
-
private Void storeLocalVar(LocalVarExpr var)
-
private Void strLiteral(LiteralExpr expr)
-
private Int switchBlock(Block? block, CType? popType := null)
-
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)