Skip to content

Commit e930075

Browse files
marijnhpcwalton
authored andcommitted
---
yaml --- r: 1756 b: refs/heads/master c: 86d0565 h: refs/heads/master v: v3
1 parent 488311c commit e930075

File tree

4 files changed

+295
-43
lines changed

4 files changed

+295
-43
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: a5caa310e4ab803d9f467d1541b7f6eeb7361f54
2+
refs/heads/master: 86d05655b48af5aa2bea7c0e191d0cbe22810e29

trunk/Makefile.in

Lines changed: 17 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ ifdef CFG_WINDOWSY
7070
CFG_LIB_NAME=$(1).dll
7171
CFG_LDPATH :=$(CFG_LDPATH):$(CFG_LLVM_BINDIR)
7272
CFG_LDPATH :=$(CFG_LDPATH):$$PATH
73-
CFG_RUN_TEST=PATH="$(CFG_LDPATH)" $(1)
74-
CFG_RUN_TARG=PATH="$(CFG_LDPATH)" $(1)
73+
CFG_RUN_TARG=PATH=$(CFG_LDPATH) $(1)
7574

7675
CFG_PATH_MUNGE := $(strip | perl -p \
7776
-e 's@\\(.)@/\1@go;' \
@@ -89,8 +88,6 @@ ifdef CFG_UNIXY
8988
CFG_EXE_SUFFIX :=
9089
CFG_LDPATH :=$(CFG_LDPATH):$(CFG_LLVM_LIBDIR)
9190
CFG_RUN_TARG=\
92-
LD_LIBRARY_PATH=$(dir $(1)):$(CFG_LDPATH) $(1)
93-
CFG_RUN_TEST=\
9491
LD_LIBRARY_PATH=$(dir $(1)):$(CFG_LDPATH) $(CFG_VALGRIND) $(1)
9592

9693
CFG_BOOT_NATIVE := 1
@@ -101,7 +98,6 @@ ifdef CFG_UNIXY
10198
CFG_LDPATH :=$(CFG_LDPATH):$(CFG_LLVM_BINDIR)
10299
CFG_LDPATH :=$(CFG_LDPATH):$$PATH
103100
CFG_RUN_TARG=PATH=$(CFG_LDPATH) $(1)
104-
CFG_RUN_TEST=PATH=$(CFG_LDPATH) $(1)
105101

106102
CFG_INFO := $(info cfg: mingw-cross)
107103
CFG_GCC_CROSS := i586-mingw32msvc-
@@ -120,7 +116,7 @@ ifdef CFG_UNIXY
120116
CFG_VALGRIND += --leak-check=full \
121117
--error-exitcode=1 \
122118
--quiet --vex-iropt-level=0 \
123-
--suppressions=$(CFG_SRC_DIR)src/etc/x86.supp
119+
--suppressions=$(S)src/etc/x86.supp
124120
endif
125121
endif
126122

@@ -183,7 +179,6 @@ else
183179
endif
184180

185181
R := $(CFG_RUN_TARG)
186-
T := $(CFG_RUN_TEST)
187182
S := $(CFG_SRC_DIR)
188183
X := $(CFG_EXE_SUFFIX)
189184

@@ -192,8 +187,8 @@ VPATH := $(S)doc $(S)src
192187

193188
# Compilers we build, we now know how to run.
194189
BOOT := $(Q)OCAMLRUNPARAM="b1" boot/rustboot$(X) $(CFG_BOOT_FLAGS) -L boot
195-
STAGE0 := $(Q)$(R) stage0/rustc$(X) $(CFG_RUSTC_FLAGS) -L stage0
196-
STAGE1 := $(Q)$(R) stage1/rustc$(X) $(CFG_RUSTC_FLAGS) -L stage1
190+
STAGE0 := $(Q)$(CFG_RUN_TARG) stage0/rustc$(X) $(CFG_RUSTC_FLAGS) -L stage0
191+
STAGE1 := $(Q)$(CFG_RUN_TARG) stage1/rustc$(X) $(CFG_RUSTC_FLAGS) -L stage1
197192

198193
# "Source" files we generate in builddir along the way.
199194
GENERATED := boot/fe/lexer.ml boot/version.ml
@@ -559,27 +554,27 @@ llvmext/%.o: llvmext/%.cpp $(MKFILES)
559554
test/run-pass/%.out.tmp: test/run-pass/%$(CFG_EXE_SUFFIX) rt/$(CFG_RUNTIME)
560555
$(Q)rm -f $<.tmp
561556
@$(call E, run: $@)
562-
$(Q)$(call T, $<) > $@
557+
$(Q)$(call CFG_RUN_TARG, $<) > $@
563558

564559
test/bench/shootout/%.out.tmp: test/bench/shootout/%$(X) \
565560
rt/$(CFG_RUNTIME)
566561
$(Q)rm -f $<.tmp
567562
@$(call E, run: $@)
568-
$(Q)$(call T, $<) > $@
563+
$(Q)$(call CFG_RUN_TARG, $<) > $@
569564

570565
test/bench/99-bottles/%.out.tmp: test/bench/99-bottles/%$(X) \
571566
rt/$(CFG_RUNTIME)
572567
$(Q)rm -f $<.tmp
573568
@$(call E, run: $@)
574-
$(Q)$(call T, $<) > $@
569+
$(Q)$(call CFG_RUN_TARG, $<) > $@
575570

576571
test/run-fail/%.out.tmp: test/run-fail/%$(X) \
577572
rt/$(CFG_RUNTIME)
578573
$(Q)rm -f $<.tmp
579574
@$(call E, run: $@)
580575
$(Q)grep -q error-pattern $(S)src/test/run-fail/$(basename $*).rs
581576
$(Q)rm -f $@
582-
$(Q)$(call T, $<) >$@ 2>&1 ; X=$$? ; \
577+
$(Q)$(call CFG_RUN_TARG, $<) >$@ 2>&1 ; X=$$? ; \
583578
if [ $$X -eq 0 ] ; then exit 1 ; else exit 0 ; fi
584579
$(Q)grep --text --quiet \
585580
"$$(grep error-pattern $(S)src/test/run-fail/$(basename $*).rs \
@@ -601,15 +596,6 @@ test/compile-fail/%.stage0.out.tmp: test/compile-fail/%.rs $(SREQ0)
601596
$(Q)grep --text --quiet \
602597
"$$(grep error-pattern $< | cut -d : -f 2- | tr -d '\n\r')" $@
603598

604-
######################################################################
605-
# Distribution
606-
######################################################################
607-
608-
PKG_NAME := rust
609-
PKG_VER = $(shell date +"%Y-%m-%d")-snap
610-
PKG_DIR = $(PKG_NAME)-$(PKG_VER)
611-
PKG_TAR = $(PKG_DIR).tar.gz
612-
613599

614600
######################################################################
615601
# Cleanup
@@ -619,23 +605,12 @@ PKG_TAR = $(PKG_DIR).tar.gz
619605

620606
clean:
621607
@$(call E, cleaning)
622-
$(Q)rm -f $(RUNTIME_OBJS)
623-
$(Q)rm -f $(LLVMEXT_OBJS)
624-
$(Q)rm -f $(BOOT_CMOS) $(BOOT_CMIS) $(BOOT_CMXS) $(BOOT_OBJS)
625-
$(Q)rm -f $(ML_DEPFILES) $(C_DEPFILES) $(CRATE_DEPFILES)
626-
$(Q)rm -f $(ML_DEPFILES:%.d=%.d.tmp)
627-
$(Q)rm -f $(C_DEPFILES:%.d=%.d.tmp)
628-
$(Q)rm -f $(CRATE_DEPFILES:%.d=%.d.tmp)
629-
$(Q)rm -f $(GENERATED)
630-
$(Q)rm -f boot/rustboot$(X) boot/$(CFG_STDLIB)
631-
$(Q)rm -f stage0/rustc$(X) stage0/$(CFG_STDLIB) stage0/glue*
632-
$(Q)rm -f stage1/rustc$(X) stage1/$(CFG_STDLIB) stage1/glue*
633-
$(Q)rm -f stage2/rustc$(X) stage2/$(CFG_STDLIB) stage2/glue*
634-
$(Q)rm -f llvmext/$(CFG_LLVMEXT) rt/$(CFG_RUNTIME)
635-
$(Q)rm -Rf $(PKG_NAME)-*.tar.gz dist
636-
$(Q)rm -f $(foreach ext,cmx cmi cmo cma bc o a d exe,\
637-
$(wildcard boot/*/*.$(ext) boot/*/*/*.$(ext)))
638-
$(Q)rm -Rf $(foreach ext,out out.tmp \
639-
boot$(X) stage0$(X) stage1$(X) stage2$(X) \
640-
bc o s exe dSYM, \
641-
$(wildcard test/*/*.$(ext)))
608+
$(Q)rm -f $(foreach ext, cmx cmi cmo cma bc o a d $(X) \
609+
h cpp ml s \
610+
out bc dSYM \
611+
, \
612+
$(wildcard *.$(ext) \
613+
*/*.$(ext) \
614+
*/*/*.$(ext) \
615+
*/*/*/*.$(ext) \
616+
))

trunk/src/comp/front/creader.rs

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ import lib.llvm.llvmext;
66
import lib.llvm.mk_object_file;
77
import lib.llvm.mk_section_iter;
88
import middle.fold;
9+
import middle.ty;
910
import util.common;
1011
import util.common.span;
1112

1213
import std._str;
14+
import std._vec;
1315
import std.fs;
16+
import std.option;
1417
import std.os;
1518
import std.map.hashmap;
1619

@@ -20,6 +23,174 @@ type env = @rec(
2023
vec[str] library_search_paths
2124
);
2225

26+
// Type decoding
27+
28+
// Compact string representation for ty.t values. API ty_str & parse_from_str.
29+
// (The second has to be authed pure.) Extra parameters are for converting
30+
// to/from def_ids in the string rep. Whatever format you choose should not
31+
// contain pipe characters.
32+
33+
// Callback to translate defs to strs or back.
34+
type str_def = fn(str) -> ast.def_id;
35+
36+
type pstate = rec(str rep, mutable uint pos, uint len);
37+
38+
fn peek(@pstate st) -> char {
39+
if (st.pos < st.len) {ret st.rep.(st.pos) as char;}
40+
else {ret ' ';}
41+
}
42+
impure fn next(@pstate st) -> char { // ?? somehow not recognized as impure
43+
if (st.pos >= st.len) {fail;}
44+
auto ch = st.rep.(st.pos);
45+
st.pos = st.pos + 1u;
46+
ret ch as char;
47+
}
48+
49+
fn parse_ty_str(str rep, str_def sd) -> @ty.t {
50+
auto len = _str.byte_len(rep);
51+
auto st = @rec(rep=rep, mutable pos=0u, len=len);
52+
auto result = parse_ty(st, sd);
53+
check(st.pos == len);
54+
ret result;
55+
}
56+
57+
impure fn parse_ty(@pstate st, str_def sd) -> @ty.t {
58+
ret @rec(struct=parse_sty(st, sd),
59+
cname=option.none[str]);
60+
}
61+
62+
impure fn parse_sty(@pstate st, str_def sd) -> ty.sty {
63+
alt (next(st)) {
64+
case ('n') {ret ty.ty_nil;}
65+
case ('b') {ret ty.ty_bool;}
66+
case ('i') {ret ty.ty_int;}
67+
case ('u') {ret ty.ty_uint;}
68+
case ('M') {
69+
alt (next(st)) {
70+
case ('b') {ret ty.ty_machine(common.ty_u8);}
71+
case ('w') {ret ty.ty_machine(common.ty_u16);}
72+
case ('l') {ret ty.ty_machine(common.ty_u32);}
73+
case ('d') {ret ty.ty_machine(common.ty_u64);}
74+
case ('B') {ret ty.ty_machine(common.ty_i8);}
75+
case ('W') {ret ty.ty_machine(common.ty_i16);}
76+
case ('L') {ret ty.ty_machine(common.ty_i32);}
77+
case ('D') {ret ty.ty_machine(common.ty_i64);}
78+
case ('f') {ret ty.ty_machine(common.ty_f32);}
79+
case ('F') {ret ty.ty_machine(common.ty_f64);}
80+
}
81+
}
82+
case ('c') {ret ty.ty_char;}
83+
case ('s') {ret ty.ty_str;}
84+
case ('t') {
85+
check(next(st) == '[');
86+
auto def = "";
87+
while (peek(st) != '|') {def += _str.from_char(next(st));}
88+
st.pos = st.pos + 1u;
89+
let vec[@ty.t] params = vec();
90+
while (peek(st) != ']') {
91+
params = _vec.push[@ty.t](params, parse_ty(st, sd));
92+
}
93+
st.pos = st.pos + 1u;
94+
ret ty.ty_tag(sd(def), params);
95+
}
96+
case ('@') {ret ty.ty_box(parse_ty(st, sd));}
97+
case ('V') {ret ty.ty_vec(parse_ty(st, sd));}
98+
case ('P') {ret ty.ty_port(parse_ty(st, sd));}
99+
case ('C') {ret ty.ty_chan(parse_ty(st, sd));}
100+
case ('T') {
101+
check(next(st) == '[');
102+
let vec[@ty.t] params = vec();
103+
while (peek(st) != ']') {
104+
params = _vec.push[@ty.t](params, parse_ty(st, sd));
105+
}
106+
st.pos = st.pos + 1u;
107+
ret ty.ty_tup(params);
108+
}
109+
case ('R') {
110+
check(next(st) == '[');
111+
let vec[ty.field] fields = vec();
112+
while (peek(st) != ']') {
113+
auto name = "";
114+
while (peek(st) != '=') {name += _str.from_char(next(st));}
115+
st.pos = st.pos + 1u;
116+
fields = _vec.push[ty.field]
117+
(fields, rec(ident=name, ty=parse_ty(st, sd)));
118+
}
119+
st.pos = st.pos + 1u;
120+
ret ty.ty_rec(fields);
121+
}
122+
case ('F') {
123+
auto func = parse_ty_fn(st, sd);
124+
ret ty.ty_fn(ast.proto_fn, func._0, func._1);
125+
}
126+
case ('W') {
127+
auto func = parse_ty_fn(st, sd);
128+
ret ty.ty_fn(ast.proto_iter, func._0, func._1);
129+
}
130+
case ('N') {
131+
auto abi;
132+
alt (next(st)) {
133+
case ('r') {abi = ast.native_abi_rust;}
134+
case ('c') {abi = ast.native_abi_cdecl;}
135+
}
136+
auto func = parse_ty_fn(st, sd);
137+
ret ty.ty_native_fn(abi,func._0,func._1);
138+
}
139+
case ('O') {
140+
check(next(st) == '[');
141+
let vec[ty.method] methods = vec();
142+
while (peek(st) != ']') {
143+
auto proto;
144+
alt (next(st)) {
145+
case ('W') {proto = ast.proto_iter;}
146+
case ('F') {proto = ast.proto_fn;}
147+
}
148+
auto name = "";
149+
while (peek(st) != '[') {name += _str.from_char(next(st));}
150+
auto func = parse_ty_fn(st, sd);
151+
methods = _vec.push[ty.method]
152+
(methods, rec(proto=proto,
153+
ident=name,
154+
inputs=func._0,
155+
output=func._1));
156+
}
157+
ret ty.ty_obj(methods);
158+
}
159+
case ('X') {ret ty.ty_var(parse_int(st));}
160+
case ('E') {ret ty.ty_native;}
161+
}
162+
}
163+
164+
impure fn parse_int(@pstate st) -> int {
165+
auto n = 0;
166+
while (true) {
167+
auto cur = peek(st);
168+
if (cur < '0' || cur > '9') {break;}
169+
st.pos = st.pos + 1u;
170+
n *= 10;
171+
n += (cur as int) - ('0' as int);
172+
}
173+
ret n;
174+
}
175+
176+
impure fn parse_ty_fn(@pstate st, str_def sd) -> tup(vec[ty.arg], @ty.t) {
177+
check(next(st) == '[');
178+
let vec[ty.arg] inputs = vec();
179+
while (peek(st) != ']') {
180+
auto mode = ast.val;
181+
if (peek(st) == '&') {
182+
mode = ast.alias;
183+
st.pos = st.pos + 1u;
184+
}
185+
inputs = _vec.push[ty.arg]
186+
(inputs, rec(mode=mode, ty=parse_ty(st, sd)));
187+
}
188+
st.pos = st.pos + 1u;
189+
ret tup(inputs, parse_ty(st, sd));
190+
}
191+
192+
193+
23194
// TODO: return something
24195
fn load_crate(ast.ident ident, vec[str] library_search_paths) -> @() {
25196
for (str library_search_path in library_search_paths) {

0 commit comments

Comments
 (0)