Skip to content

Commit e4dd91f

Browse files
Merge pull request #5869 from dotty-staging/inline-scala-submodules
Inline scala-{library, backend} submodules
2 parents c48864a + c6b0f28 commit e4dd91f

File tree

741 files changed

+85646
-247
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

741 files changed

+85646
-247
lines changed

.drone.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ clone:
66

77
pipeline:
88
# We add a custom clone step to workaround a bug with GitHub (see #3415)
9-
# and speed up cloning submodules
109
clone:
1110
image: plugins/git
1211
commands:
@@ -16,8 +15,6 @@ pipeline:
1615
git config user.name "Dotty CI";
1716
git pull "$DRONE_REMOTE_URL" "$DRONE_BRANCH";
1817
fi
19-
# clone submodules in parallelRiRem
20-
- git submodule update --init --recursive --jobs 3
2118

2219
# TESTS:
2320
# We run tests in parallel. Tests run in a copy of the working directory to avoid conflict
@@ -42,6 +39,7 @@ pipeline:
4239
image: lampepfl/dotty:2019-02-06
4340
commands:
4441
- cp -R . /tmp/3/ && cd /tmp/3/
42+
- git submodule update --init --recursive --jobs 7
4543
- export PATH=/tmp/4/project/scripts:$PATH
4644
- sbt community-build/test
4745

.gitmodules

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
[submodule "scala-backend"]
2-
path = scala-backend
3-
url = https://github.com/lampepfl/scala.git
4-
branch = sharing-backend
5-
[submodule "scala2-library"]
6-
path = scala2-library
7-
url = https://github.com/lampepfl/scala.git
8-
branch = dotty-library2.12
91
[submodule "community-build/community-projects/algebra"]
102
path = community-build/community-projects/algebra
113
url = https://github.com/dotty-staging/algebra

.vscode-template/settings.json

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,7 @@
99
"**/*.class": true,
1010
"**/*.hasTasty": true,
1111
"**/target/": true,
12-
"community-build/community-projects": true,
13-
"scala2-library/{doc,docs,lib,META-INF,scripts,spec,test,tools}/": true, // only allow scala-backend/src
14-
"scala2-library/src/[abcefimprs]*": true, // only allow scala-backend/src/library
15-
"scala-backend/{doc,docs,lib,META-INF,scripts,spec,test,tools}/": true, // only allow scala-backend/src
16-
"scala-backend/src/[abefilmprs]*": true, // only allow scala-backend/src/compiler
17-
"scala-backend/src/scala/reflect/": true,
18-
"scala-backend/src/scala/tools/{ant,cmd,reflect,util}*": true,
19-
"scala-backend/src/scala/tools/nsc/*.scala": true,
20-
"scala-backend/src/scala/tools/nsc/[aijrstu]*": true // only allow scala-backend/src/scala/tools/nsc/backend
12+
"tests/": true,
13+
"community-build/community-projects": true
2114
}
2215
}
Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
package dotty.tools
2+
package backend
3+
4+
object ScalaPrimitivesOps extends ScalaPrimitivesOps
5+
6+
class ScalaPrimitivesOps {
7+
// Arithmetic unary operations
8+
final val POS = 1 // +x
9+
final val NEG = 2 // -x
10+
final val NOT = 3 // ~x
11+
12+
// Arithmetic binary operations
13+
final val ADD = 10 // x + y
14+
final val SUB = 11 // x - y
15+
final val MUL = 12 // x * y
16+
final val DIV = 13 // x / y
17+
final val MOD = 14 // x % y
18+
19+
// Bitwise operations
20+
final val OR = 20 // x | y
21+
final val XOR = 21 // x ^ y
22+
final val AND = 22 // x & y
23+
24+
// Shift operations
25+
final val LSL = 30 // x << y
26+
final val LSR = 31 // x >>> y
27+
final val ASR = 32 // x >> y
28+
29+
// Comparison operations
30+
final val ID = 40 // x eq y
31+
final val NI = 41 // x ne y
32+
final val EQ = 42 // x == y
33+
final val NE = 43 // x != y
34+
final val LT = 44 // x < y
35+
final val LE = 45 // x <= y
36+
final val GE = 46 // x > y
37+
final val GT = 47 // x >= y
38+
39+
// Boolean unary operations
40+
final val ZNOT = 50 // !x
41+
42+
// Boolean binary operations
43+
final val ZOR = 60 // x || y
44+
final val ZAND = 61 // x && y
45+
46+
// Array operations
47+
final val LENGTH = 70 // x.length
48+
final val APPLY = 71 // x(y)
49+
final val UPDATE = 72 // x(y) = z
50+
51+
// Any operations
52+
final val IS = 80 // x.is[y]
53+
final val AS = 81 // x.as[y]
54+
final val HASH = 87 // x.##
55+
56+
// AnyRef operations
57+
final val SYNCHRONIZED = 90 // x.synchronized(y)
58+
59+
// String operations
60+
final val CONCAT = 100 // String.valueOf(x)+String.valueOf(y)
61+
62+
// coercions
63+
final val COERCE = 101
64+
65+
// RunTime operations
66+
final val BOX = 110 // RunTime.box_<X>(x)
67+
final val UNBOX = 111 // RunTime.unbox_<X>(x)
68+
final val NEW_ZARRAY = 112 // RunTime.zarray(x)
69+
final val NEW_BARRAY = 113 // RunTime.barray(x)
70+
final val NEW_SARRAY = 114 // RunTime.sarray(x)
71+
final val NEW_CARRAY = 115 // RunTime.carray(x)
72+
final val NEW_IARRAY = 116 // RunTime.iarray(x)
73+
final val NEW_LARRAY = 117 // RunTime.larray(x)
74+
final val NEW_FARRAY = 118 // RunTime.farray(x)
75+
final val NEW_DARRAY = 119 // RunTime.darray(x)
76+
final val NEW_OARRAY = 120 // RunTime.oarray(x)
77+
78+
final val ZARRAY_LENGTH = 131 // RunTime.zarray_length(x)
79+
final val BARRAY_LENGTH = 132 // RunTime.barray_length(x)
80+
final val SARRAY_LENGTH = 133 // RunTime.sarray_length(x)
81+
final val CARRAY_LENGTH = 134 // RunTime.carray_length(x)
82+
final val IARRAY_LENGTH = 135 // RunTime.iarray_length(x)
83+
final val LARRAY_LENGTH = 136 // RunTime.larray_length(x)
84+
final val FARRAY_LENGTH = 137 // RunTime.farray_length(x)
85+
final val DARRAY_LENGTH = 138 // RunTime.darray_length(x)
86+
final val OARRAY_LENGTH = 139 // RunTime.oarray_length(x)
87+
88+
final val ZARRAY_GET = 140 // RunTime.zarray_get(x,y)
89+
final val BARRAY_GET = 141 // RunTime.barray_get(x,y)
90+
final val SARRAY_GET = 142 // RunTime.sarray_get(x,y)
91+
final val CARRAY_GET = 143 // RunTime.carray_get(x,y)
92+
final val IARRAY_GET = 144 // RunTime.iarray_get(x,y)
93+
final val LARRAY_GET = 145 // RunTime.larray_get(x,y)
94+
final val FARRAY_GET = 146 // RunTime.farray_get(x,y)
95+
final val DARRAY_GET = 147 // RunTime.darray_get(x,y)
96+
final val OARRAY_GET = 148 // RunTime.oarray_get(x,y)
97+
98+
final val ZARRAY_SET = 150 // RunTime.zarray(x,y,z)
99+
final val BARRAY_SET = 151 // RunTime.barray(x,y,z)
100+
final val SARRAY_SET = 152 // RunTime.sarray(x,y,z)
101+
final val CARRAY_SET = 153 // RunTime.carray(x,y,z)
102+
final val IARRAY_SET = 154 // RunTime.iarray(x,y,z)
103+
final val LARRAY_SET = 155 // RunTime.larray(x,y,z)
104+
final val FARRAY_SET = 156 // RunTime.farray(x,y,z)
105+
final val DARRAY_SET = 157 // RunTime.darray(x,y,z)
106+
final val OARRAY_SET = 158 // RunTime.oarray(x,y,z)
107+
108+
final val B2B = 200 // RunTime.b2b(x)
109+
final val B2S = 201 // RunTime.b2s(x)
110+
final val B2C = 202 // RunTime.b2c(x)
111+
final val B2I = 203 // RunTime.b2i(x)
112+
final val B2L = 204 // RunTime.b2l(x)
113+
final val B2F = 205 // RunTime.b2f(x)
114+
final val B2D = 206 // RunTime.b2d(x)
115+
116+
final val S2B = 210 // RunTime.s2b(x)
117+
final val S2S = 211 // RunTime.s2s(x)
118+
final val S2C = 212 // RunTime.s2c(x)
119+
final val S2I = 213 // RunTime.s2i(x)
120+
final val S2L = 214 // RunTime.s2l(x)
121+
final val S2F = 215 // RunTime.s2f(x)
122+
final val S2D = 216 // RunTime.s2d(x)
123+
124+
final val C2B = 220 // RunTime.c2b(x)
125+
final val C2S = 221 // RunTime.c2s(x)
126+
final val C2C = 222 // RunTime.c2c(x)
127+
final val C2I = 223 // RunTime.c2i(x)
128+
final val C2L = 224 // RunTime.c2l(x)
129+
final val C2F = 225 // RunTime.c2f(x)
130+
final val C2D = 226 // RunTime.c2d(x)
131+
132+
final val I2B = 230 // RunTime.i2b(x)
133+
final val I2S = 231 // RunTime.i2s(x)
134+
final val I2C = 232 // RunTime.i2c(x)
135+
final val I2I = 233 // RunTime.i2i(x)
136+
final val I2L = 234 // RunTime.i2l(x)
137+
final val I2F = 235 // RunTime.i2f(x)
138+
final val I2D = 236 // RunTime.i2d(x)
139+
140+
final val L2B = 240 // RunTime.l2b(x)
141+
final val L2S = 241 // RunTime.l2s(x)
142+
final val L2C = 242 // RunTime.l2c(x)
143+
final val L2I = 243 // RunTime.l2i(x)
144+
final val L2L = 244 // RunTime.l2l(x)
145+
final val L2F = 245 // RunTime.l2f(x)
146+
final val L2D = 246 // RunTime.l2d(x)
147+
148+
final val F2B = 250 // RunTime.f2b(x)
149+
final val F2S = 251 // RunTime.f2s(x)
150+
final val F2C = 252 // RunTime.f2c(x)
151+
final val F2I = 253 // RunTime.f2i(x)
152+
final val F2L = 254 // RunTime.f2l(x)
153+
final val F2F = 255 // RunTime.f2f(x)
154+
final val F2D = 256 // RunTime.f2d(x)
155+
156+
final val D2B = 260 // RunTime.d2b(x)
157+
final val D2S = 261 // RunTime.d2s(x)
158+
final val D2C = 262 // RunTime.d2c(x)
159+
final val D2I = 263 // RunTime.d2i(x)
160+
final val D2L = 264 // RunTime.d2l(x)
161+
final val D2F = 265 // RunTime.d2f(x)
162+
final val D2D = 266 // RunTime.d2d(x)
163+
164+
/** Check whether the given operation code is an array operation. */
165+
def isArrayOp(code: Int): Boolean =
166+
isArrayNew(code) | isArrayLength(code) | isArrayGet(code) | isArraySet(code)
167+
168+
def isArrayNew(code: Int): Boolean = code match {
169+
case NEW_ZARRAY | NEW_BARRAY | NEW_SARRAY | NEW_CARRAY |
170+
NEW_IARRAY | NEW_LARRAY | NEW_FARRAY | NEW_DARRAY |
171+
NEW_OARRAY => true
172+
case _ => false
173+
}
174+
175+
def isArrayLength(code: Int): Boolean = code match {
176+
case ZARRAY_LENGTH | BARRAY_LENGTH | SARRAY_LENGTH | CARRAY_LENGTH |
177+
IARRAY_LENGTH | LARRAY_LENGTH | FARRAY_LENGTH | DARRAY_LENGTH |
178+
OARRAY_LENGTH | LENGTH => true
179+
case _ => false
180+
}
181+
182+
def isArrayGet(code: Int): Boolean = code match {
183+
case ZARRAY_GET | BARRAY_GET | SARRAY_GET | CARRAY_GET |
184+
IARRAY_GET | LARRAY_GET | FARRAY_GET | DARRAY_GET |
185+
OARRAY_GET | APPLY => true
186+
case _ => false
187+
}
188+
189+
def isArraySet(code: Int): Boolean = code match {
190+
case ZARRAY_SET | BARRAY_SET | SARRAY_SET | CARRAY_SET |
191+
IARRAY_SET | LARRAY_SET | FARRAY_SET | DARRAY_SET |
192+
OARRAY_SET | UPDATE => true
193+
case _ => false
194+
}
195+
196+
/** Check whether the given code is a comparison operator */
197+
def isComparisonOp(code: Int): Boolean = code match {
198+
case ID | NI | EQ | NE |
199+
LT | LE | GT | GE => true
200+
201+
case _ => false
202+
}
203+
def isUniversalEqualityOp(code: Int): Boolean = (code == EQ) || (code == NE)
204+
def isReferenceEqualityOp(code: Int): Boolean = (code == ID) || (code == NI)
205+
206+
def isArithmeticOp(code: Int): Boolean = code match {
207+
case POS | NEG | NOT => true; // unary
208+
case ADD | SUB | MUL |
209+
DIV | MOD => true; // binary
210+
case OR | XOR | AND |
211+
LSL | LSR | ASR => true; // bitwise
212+
case _ => false
213+
}
214+
215+
def isLogicalOp(code: Int): Boolean = code match {
216+
case ZNOT | ZAND | ZOR => true
217+
case _ => false
218+
}
219+
220+
def isShiftOp(code: Int): Boolean = code match {
221+
case LSL | LSR | ASR => true
222+
case _ => false
223+
}
224+
225+
def isBitwiseOp(code: Int): Boolean = code match {
226+
case OR | XOR | AND => true
227+
case _ => false
228+
}
229+
230+
def isCoercion(code: Int): Boolean = (code >= B2B) && (code <= D2D)
231+
232+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package dotty.tools
2+
package backend
3+
4+
import scala.collection.mutable
5+
6+
/**
7+
* Simple implementation of a worklist algorithm. A processing
8+
* function is applied repeatedly to the first element in the
9+
* worklist, as long as the stack is not empty.
10+
*
11+
* The client class should mix-in this class and initialize the worklist
12+
* field and define the `processElement` method. Then call the `run` method
13+
* providing a function that initializes the worklist.
14+
*
15+
* @author Martin Odersky
16+
* @version 1.0
17+
* @see [[scala.tools.nsc.backend.icode.Linearizers]]
18+
*/
19+
trait WorklistAlgorithm {
20+
type Elem
21+
class WList {
22+
private[this] var list: List[Elem] = Nil
23+
def isEmpty = list.isEmpty
24+
def nonEmpty = !isEmpty
25+
def push(e: Elem): Unit = { list = e :: list }
26+
def pop(): Elem = {
27+
val head = list.head
28+
list = list.tail
29+
head
30+
}
31+
def pushAll(xs: Iterable[Elem]): Unit = xs.foreach(push)
32+
def clear(): Unit = list = Nil
33+
34+
}
35+
36+
val worklist: WList
37+
38+
/**
39+
* Run the iterative algorithm until the worklist remains empty.
40+
* The initializer is run once before the loop starts and should
41+
* initialize the worklist.
42+
*/
43+
def run(initWorklist: => Unit) = {
44+
initWorklist
45+
46+
while (worklist.nonEmpty)
47+
processElement(dequeue)
48+
}
49+
50+
/**
51+
* Process the current element from the worklist.
52+
*/
53+
def processElement(e: Elem): Unit
54+
55+
/**
56+
* Remove and return the first element to be processed from the worklist.
57+
*/
58+
def dequeue: Elem
59+
}

0 commit comments

Comments
 (0)