1package mill.api
2
3import mill.api.internal.OverrideMapping
4
5import scala.annotation.implicitNotFound
6import scala.quoted.*
7
8/**
9 * The contextual information provided to a [[mill.api.Module]] or [[mill.api.Task]]
…lines 10–41 unchanged (32 lines)
42
43object ModuleCtx extends LowPriCtx {
44 trait Wrapper {
45 def moduleSegments: Segments = moduleCtx.segments
46 def moduleCtx: ModuleCtx
47 private[mill] def moduleLinearized: Seq[Class[?]]
48 private[mill] def moduleDynamicBuildOverrides: Map[String, internal.LocatedValue] = Map()
49 }
50
51 import upickle.core.BufferedValue
52 implicit val bufferedRw: upickle.ReadWriter[BufferedValue] =
53 new upickle.ReadWriter[BufferedValue] {
54 def visitArray(length: Int, index: Int): upickle.core.ArrVisitor[Any, BufferedValue] =
55 new upickle.core.ArrVisitor[Any, BufferedValue] {
56 def subVisitor = bufferedRw
57 private[this] val vs = collection.mutable.ArrayBuffer.newBuilder[BufferedValue]
58 def visitValue(v: Any, index: Int): Unit = vs += v.asInstanceOf[BufferedValue]
59
60 def visitEnd(index: Int) = BufferedValue.Arr(vs.result(), index)
61 }
62
63 def visitBinary(bytes: Array[Byte], offset: Int, len: Int, index: Int) =
64 BufferedValue.Binary(bytes, offset, len, index)
65 def visitChar(s: Char, index: Int) = BufferedValue.Char(s, index)
66 def visitExt(tag: Byte, bytes: Array[Byte], offset: Int, len: Int, index: Int) =
67 BufferedValue.Ext(tag, bytes, offset, len, index)
68 def visitFalse(index: Int) = BufferedValue.False(index)
69 def visitFloat32(d: Float, index: Int) = BufferedValue.Float32(d, index)
70 def visitFloat64(d: Double, index: Int) = BufferedValue.NumRaw(d, index)
71 def visitFloat64String(s: String, index: Int) = BufferedValue.Float64String(s, index)
72 def visitFloat64StringParts(s: CharSequence, decIndex: Int, expIndex: Int, index: Int) =
73 BufferedValue.Num(s, decIndex, expIndex, index)
74 def visitInt32(i: Int, index: Int) = BufferedValue.Int32(i, index)
75 def visitInt64(i: Long, index: Int) = BufferedValue.Int64(i, index)
76 def visitNull(index: Int) = BufferedValue.Null(index)
77 def visitObject(
78 length: Int,
79 jsonableKeys: Boolean,
80 index: Int
81 ): upickle.core.ObjVisitor[Any, BufferedValue] =
82 new upickle.core.ObjVisitor[Any, BufferedValue] {
83 private[this] var key: BufferedValue = null
84 private[this] val vs =
85 collection.mutable.ArrayBuffer.newBuilder[(BufferedValue, BufferedValue)]
86
87 def subVisitor = bufferedRw
88
89 def visitKey(index: Int) = bufferedRw
90
91 def visitKeyValue(s: Any): Unit = key = s.asInstanceOf[BufferedValue]
92
93 def visitValue(v: Any, index: Int): Unit = vs += (key -> v.asInstanceOf[BufferedValue])
94
95 def visitEnd(index: Int) = BufferedValue.Obj(vs.result(), jsonableKeys = true, index)
96 }
97 def visitString(s: CharSequence, index: Int) = BufferedValue.Str(s, index)
98 def visitTrue(index: Int) = BufferedValue.True(index)
99 def visitUInt64(i: Long, index: Int) = BufferedValue.UInt64(i, index)
100
101 def write0[V](out: upickle.core.Visitor[?, V], v: BufferedValue): V =
102 BufferedValue.transform(v, out)
103
104 }
105 private[mill] case class HeaderData(
106 `extends`: Seq[String] = Nil,
107 moduleDeps: Seq[String] = Nil,
108 compileModuleDeps: Seq[String] = Nil,
109 runModuleDeps: Seq[String] = Nil,
110 @upickle.implicits.flatten rest: Map[String, upickle.core.BufferedValue]
111 ) derives upickle.ReadWriter
112
113 private case class Impl(
114 enclosing: String,
115 lineNum: Int,
116 millSourcePath: os.Path,
117 segments: Segments,
…lines 118–250 unchanged (133 lines)