All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dotty.tools.dotc.semanticdb.ConstantOps.scala Maven / Gradle / Ivy

There is a newer version: 3.6.4-RC1-bin-20241220-0bfa1af-NIGHTLY
Show newest version
package dotty.tools
package dotc
package semanticdb

import dotty.tools.dotc.{semanticdb => s}

import core.Contexts.Context
import core.Constants.*

object ConstantOps:
  extension (const: Constant)
    def toSemanticConst(using Context): s.Constant = const.tag match {
      case UnitTag => s.UnitConstant()
      case BooleanTag => s.BooleanConstant(const.booleanValue)
      case ByteTag => s.ByteConstant(const.byteValue)
      case ShortTag => s.ShortConstant(const.shortValue)
      case CharTag => s.CharConstant(const.charValue)
      case IntTag => s.IntConstant(const.intValue)
      case LongTag => s.LongConstant(const.longValue)
      case FloatTag => s.FloatConstant(const.floatValue)
      case DoubleTag => s.DoubleConstant(const.doubleValue)
      case StringTag => s.StringConstant(const.stringValue)
      case NullTag => s.NullConstant()
      case _ => throw new Error(s"Constant ${const} can't be converted to Semanticdb Constant.")
    }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy