Skip to content

Commit ce89eb5

Browse files
Steffan153JRaspass
andauthored
Add Dart (#755)
* Add Dart * why did vscode change those permissions * undo one more permission change * undo one more permission change * Oops, it's MiB, not MB * Add Dart logo * Add new Dart Logo (thanks to @SirBogman!) * Copy way less stuff to the container and use bash instead of C for the wrapper * Fix the MiB numbers Fixes #312 Co-authored-by: James Raspass <jraspass@gmail.com>
1 parent bfa7e0c commit ce89eb5

File tree

10 files changed

+89
-34
lines changed

10 files changed

+89
-34
lines changed

config/langs.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,27 @@ void main(string[] argv) {
297297
}
298298
'''
299299

300+
[Dart]
301+
size = '532 MiB'
302+
version = '2.18.2'
303+
website = 'https://dart.dev/'
304+
example = '''
305+
void main(List<String> argv) {
306+
// Printing
307+
print("Hello, World!");
308+
309+
// Looping
310+
for (var i = 0; i < 10; i++) {
311+
print(i);
312+
}
313+
314+
// Accessing arguments
315+
for (final arg in argv) {
316+
print(arg);
317+
}
318+
}
319+
'''
320+
300321
[Elixir]
301322
size = '167 MiB'
302323
version = '1.14.0'

db/a-schema.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ CREATE TYPE keymap AS ENUM ('default', 'vim');
4848

4949
CREATE TYPE lang AS ENUM (
5050
'assembly', 'bash', 'basic', 'brainfuck', 'c', 'c-sharp', 'cpp', 'cobol',
51-
'crystal', 'd', 'elixir', 'f-sharp', 'fish', 'fortran', 'go',
51+
'crystal', 'd', 'dart', 'elixir', 'f-sharp', 'fish', 'fortran', 'go',
5252
'golfscript', 'haskell', 'hexagony', 'j', 'java', 'javascript', 'julia',
5353
'k', 'lisp', 'lua', 'nim', 'pascal', 'perl', 'php', 'powershell',
5454
'prolog', 'python', 'raku', 'ruby', 'rust', 'sed', 'sql', 'swift', 'tcl',

docker/dev.Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ RUN apk add --no-cache build-base curl git linux-headers tzdata \
77
&& GOBIN=/bin go install github.com/cespare/reflex@latest
88

99
COPY --from=codegolf/lang-swift ["/", "/langs/swift/rootfs/" ] # 561 MiB
10+
COPY --from=codegolf/lang-dart ["/", "/langs/dart/rootfs/" ] # 532 MiB
1011
COPY --from=codegolf/lang-rust ["/", "/langs/rust/rootfs/" ] # 404 MiB
1112
COPY --from=codegolf/lang-haskell ["/", "/langs/haskell/rootfs/" ] # 309 MiB
1213
COPY --from=codegolf/lang-julia ["/", "/langs/julia/rootfs/" ] # 298 MiB

docker/live.Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ RUN ./esbuild \
2020
FROM scratch
2121

2222
COPY --from=codegolf/lang-swift ["/", "/langs/swift/rootfs/" ] # 561 MiB
23+
COPY --from=codegolf/lang-dart ["/", "/langs/dart/rootfs/" ] # 532 MiB
2324
COPY --from=codegolf/lang-rust ["/", "/langs/rust/rootfs/" ] # 404 MiB
2425
COPY --from=codegolf/lang-haskell ["/", "/langs/haskell/rootfs/" ] # 309 MiB
2526
COPY --from=codegolf/lang-julia ["/", "/langs/julia/rootfs/" ] # 298 MiB

hole/play.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ func play(ctx context.Context, holeID, langID, code string, score *Scorecard) {
211211
case "d":
212212
cmd.Args = []string{"/usr/bin/ldc2", "--enable-color=true", "--run", "-"}
213213
cmd.Env = []string{"PATH=/usr/bin"}
214+
case "dart":
215+
cmd.Args = []string{"/bin/dart-wrapper", "/tmp/code.dart"}
214216
case "elixir":
215217
cmd.Args = []string{"/usr/local/bin/elixir", "-e", code, "--"}
216218
cmd.Env = []string{"LANG=C.UTF-8", "PATH=/usr/local/bin:/usr/bin:/bin"}

js/_codemirror.ts

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,39 +17,39 @@ import { oneDarkTheme, oneDarkHighlightStyle } from '@codemirror/theme-one-dar
1717
import { vim } from '@replit/codemirror-vim';
1818

1919
// Languages.
20-
import { assembly } from '@defasm/codemirror';
21-
// import { brainfuck } from '@codemirror/legacy-modes/mode/brainfuck';
22-
import { c, csharp } from './vendor/codemirror-clike';
23-
import { cobol } from './vendor/codemirror-cobol';
24-
import { commonLisp } from '@codemirror/legacy-modes/mode/commonlisp';
25-
import { cpp } from '@codemirror/lang-cpp';
26-
import { crystal } from '@codemirror/legacy-modes/mode/crystal';
27-
import { d } from '@codemirror/legacy-modes/mode/d';
28-
import { fortran } from '@codemirror/legacy-modes/mode/fortran';
29-
import { fSharp } from '@codemirror/legacy-modes/mode/mllike';
30-
import { go } from '@codemirror/legacy-modes/mode/go';
31-
import { golfScript } from 'codemirror-lang-golfscript';
32-
import { haskell } from '@codemirror/legacy-modes/mode/haskell';
33-
import { j } from 'codemirror-lang-j';
34-
import { java } from '@codemirror/lang-java';
35-
import { javascript } from '@codemirror/lang-javascript';
36-
import { julia } from '@codemirror/legacy-modes/mode/julia';
37-
import { k } from 'codemirror-lang-k';
38-
import { lua } from '@codemirror/legacy-modes/mode/lua';
39-
import { nim } from 'nim-codemirror-mode';
40-
import { pascal } from '@codemirror/legacy-modes/mode/pascal';
41-
import { perl } from '@codemirror/legacy-modes/mode/perl';
42-
import { php } from '@codemirror/lang-php';
43-
import { powerShell } from '@codemirror/legacy-modes/mode/powershell';
44-
import { python } from '@codemirror/lang-python';
45-
import { raku } from './vendor/codemirror-raku';
46-
import { ruby } from '@codemirror/legacy-modes/mode/ruby';
47-
import { rust } from '@codemirror/lang-rust';
48-
import { shell } from '@codemirror/legacy-modes/mode/shell';
49-
import { sql, SQLite } from '@codemirror/lang-sql';
50-
import { swift } from '@codemirror/legacy-modes/mode/swift';
51-
import { tcl } from '@codemirror/legacy-modes/mode/tcl';
52-
import { wren } from '@exercism/codemirror-lang-wren';
20+
import { assembly } from '@defasm/codemirror';
21+
// import { brainfuck } from '@codemirror/legacy-modes/mode/brainfuck';
22+
import { c, csharp, dart } from '@codemirror/legacy-modes/mode/clike';
23+
import { cobol } from './vendor/codemirror-cobol';
24+
import { commonLisp } from '@codemirror/legacy-modes/mode/commonlisp';
25+
import { cpp } from '@codemirror/lang-cpp';
26+
import { crystal } from '@codemirror/legacy-modes/mode/crystal';
27+
import { d } from '@codemirror/legacy-modes/mode/d';
28+
import { fortran } from '@codemirror/legacy-modes/mode/fortran';
29+
import { fSharp } from '@codemirror/legacy-modes/mode/mllike';
30+
import { go } from '@codemirror/legacy-modes/mode/go';
31+
import { golfScript } from 'codemirror-lang-golfscript';
32+
import { haskell } from '@codemirror/legacy-modes/mode/haskell';
33+
import { j } from 'codemirror-lang-j';
34+
import { java } from '@codemirror/lang-java';
35+
import { javascript } from '@codemirror/lang-javascript';
36+
import { julia } from '@codemirror/legacy-modes/mode/julia';
37+
import { k } from 'codemirror-lang-k';
38+
import { lua } from '@codemirror/legacy-modes/mode/lua';
39+
import { nim } from 'nim-codemirror-mode';
40+
import { pascal } from '@codemirror/legacy-modes/mode/pascal';
41+
import { perl } from '@codemirror/legacy-modes/mode/perl';
42+
import { php } from '@codemirror/lang-php';
43+
import { powerShell } from '@codemirror/legacy-modes/mode/powershell';
44+
import { python } from '@codemirror/lang-python';
45+
import { raku } from './vendor/codemirror-raku';
46+
import { ruby } from '@codemirror/legacy-modes/mode/ruby';
47+
import { rust } from '@codemirror/lang-rust';
48+
import { shell } from '@codemirror/legacy-modes/mode/shell';
49+
import { sql, SQLite } from '@codemirror/lang-sql';
50+
import { swift } from '@codemirror/legacy-modes/mode/swift';
51+
import { tcl } from '@codemirror/legacy-modes/mode/tcl';
52+
import { wren } from '@exercism/codemirror-lang-wren';
5353

5454
// For some reason, this doesn't fully work unless added to both themes.
5555
const asmErrorTooltip = {
@@ -112,6 +112,7 @@ export const extensions = {
112112
'cpp': cpp(),
113113
'crystal': StreamLanguage.define(crystal),
114114
'd': StreamLanguage.define(d),
115+
'dart': StreamLanguage.define(dart),
115116
// TODO elixir
116117
'f-sharp': StreamLanguage.define(fSharp),
117118
// TODO fish

langs/dart/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM dart:2.18.2-sdk as builder
2+
3+
COPY dart-wrapper /bin
4+
RUN chmod +x /bin/dart-wrapper
5+
6+
FROM codegolf/lang-base
7+
8+
COPY --from=0 /lib/x86_64-linux-gnu/libc.so.6 \
9+
/lib/x86_64-linux-gnu/libm.so.6 \
10+
/lib/x86_64-linux-gnu/libdl.so.2 \
11+
/lib/x86_64-linux-gnu/libpthread.so.0 /lib/
12+
COPY --from=0 /usr/lib/dart /usr/lib/dart
13+
COPY --from=0 /lib64/ld-linux-x86-64.so.2 /lib64/
14+
COPY --from=0 /bin /bin
15+
COPY --from=0 /usr/bin /usr/bin
16+
17+
ENTRYPOINT ["dart-wrapper"]
18+
19+
CMD ["--version"]

langs/dart/dart-wrapper

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh -e
2+
3+
[ "$1" = "--version" ] && exec /usr/lib/dart/bin/dart --version
4+
5+
cat - > /tmp/code.dart
6+
7+
shift
8+
exec /usr/lib/dart/bin/dart "$@"

latest-langs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ constant @urls = (
1111
'COBOL' => 'GnuCOBOL',
1212
'Crystal' => 'Crystal_(programming_language)',
1313
'D' => 'D_(programming_language)',
14+
'Dart' => 'Dart_(programming_language)',
1415
'Elixir' => 'Elixir_(programming_language)',
1516
'F#' => 'F_Sharp_(programming_language)',
1617
'Fortran' => 'GNU_Fortran',

svg/dart.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)