Skip to content

Commit

Permalink
Rename 'CastType' to 'CastKind'
Browse files Browse the repository at this point in the history
  • Loading branch information
SupunS committed Nov 6, 2024
1 parent c61f9b2 commit ad3620e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions bbq/bytecode_printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ func (p *BytecodePrinter) printCode(codes []byte) {

case opcode.Cast:
var typeIndex int
var castType byte
var castKind byte
typeIndex, i = p.getIntOperand(codes, i)
castType, i = p.getByteOperand(codes, i)
p.stringBuilder.WriteString(" " + fmt.Sprint(typeIndex) + " " + fmt.Sprint(int8(castType)))
castKind, i = p.getByteOperand(codes, i)
p.stringBuilder.WriteString(" " + fmt.Sprint(typeIndex) + " " + fmt.Sprint(int8(castKind)))

case opcode.Path:
var identifier string
Expand Down
6 changes: 3 additions & 3 deletions bbq/commons/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ const (
TransactionGeneratedParamPrefix = "$_param_"
)

type CastType byte
type CastKind byte

const (
SimpleCast CastType = iota
SimpleCast CastKind = iota
FailableCast
ForceCast
)

func CastTypeFrom(operation ast.Operation) CastType {
func CastKindFrom(operation ast.Operation) CastKind {
switch operation {
case ast.OperationCast:
return SimpleCast
Expand Down
4 changes: 2 additions & 2 deletions bbq/compiler/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -984,9 +984,9 @@ func (c *Compiler) VisitCastingExpression(expression *ast.CastingExpression) (_
index := c.getOrAddType(castingTypes.TargetType)
first, second := encodeUint16(index)

castType := commons.CastTypeFrom(expression.Operation)
castKind := commons.CastKindFrom(expression.Operation)

c.emit(opcode.Cast, first, second, byte(castType))
c.emit(opcode.Cast, first, second, byte(castKind))
return
}

Expand Down
4 changes: 2 additions & 2 deletions bbq/vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,10 +536,10 @@ func opCast(vm *VM) {
callframe := vm.callFrame
value := vm.pop()
targetType := vm.loadType()
castType := commons.CastType(callframe.getByte())
castKind := commons.CastKind(callframe.getByte())

// TODO:
_ = castType
_ = castKind
_ = targetType

vm.push(value)
Expand Down

0 comments on commit ad3620e

Please sign in to comment.