Skip to content

Commit f4c432b

Browse files
Merge pull request RustPython#1198 from RustPython/master
REALLY update the demo this time
2 parents e0bfd18 + 6cc4ebb commit f4c432b

21 files changed

+589
-122
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ matrix:
8484
# Set in the settings page of your repository, as a secure variable
8585
github-token: $WEBSITE_GITHUB_TOKEN
8686
keep-history: true
87+
on:
88+
branch: release
8789

8890
- name: WASM online demo
8991
language: rust
@@ -109,6 +111,8 @@ matrix:
109111
# Set in the settings page of your repository, as a secure variable
110112
github-token: $WEBSITE_GITHUB_TOKEN
111113
keep-history: true
114+
on:
115+
branch: release
112116

113117
- name: Code Coverage
114118
language: python

Cargo.lock

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Dockerfile.wasm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ COPY parser parser
1717
COPY bytecode bytecode
1818
COPY compiler compiler
1919
COPY wasm/lib wasm/lib
20+
COPY Lib Lib
2021

2122
RUN cd wasm/lib/ && wasm-pack build --release
2223

parser/src/ast.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub struct Node {
1414
}
1515
*/
1616

17+
#[allow(clippy::large_enum_variant)]
1718
#[derive(Debug, PartialEq)]
1819
pub enum Top {
1920
Program(Program),
@@ -41,7 +42,6 @@ pub struct Located<T> {
4142
pub type Statement = Located<StatementType>;
4243

4344
/// Abstract syntax tree nodes for python statements.
44-
#[allow(clippy::large_enum_variant)]
4545
#[derive(Debug, PartialEq)]
4646
pub enum StatementType {
4747
Break,
@@ -100,8 +100,8 @@ pub enum StatementType {
100100
},
101101
For {
102102
is_async: bool,
103-
target: Expression,
104-
iter: Expression,
103+
target: Box<Expression>,
104+
iter: Box<Expression>,
105105
body: Vec<Statement>,
106106
orelse: Option<Vec<Statement>>,
107107
},
@@ -125,7 +125,7 @@ pub enum StatementType {
125125
FunctionDef {
126126
is_async: bool,
127127
name: String,
128-
args: Parameters,
128+
args: Box<Parameters>,
129129
body: Vec<Statement>,
130130
decorator_list: Vec<Expression>,
131131
returns: Option<Expression>,
@@ -217,7 +217,7 @@ pub enum ExpressionType {
217217
name: String,
218218
},
219219
Lambda {
220-
args: Parameters,
220+
args: Box<Parameters>,
221221
body: Box<Expression>,
222222
},
223223
IfExpression {
@@ -293,6 +293,7 @@ pub struct Parameters {
293293

294294
#[derive(Debug, PartialEq, Default)]
295295
pub struct Parameter {
296+
pub location: Location,
296297
pub arg: String,
297298
pub annotation: Option<Box<Expression>>,
298299
}
@@ -308,6 +309,7 @@ pub enum ComprehensionKind {
308309

309310
#[derive(Debug, PartialEq)]
310311
pub struct Comprehension {
312+
pub location: Location,
311313
pub target: Expression,
312314
pub iter: Expression,
313315
pub ifs: Vec<Expression>,
@@ -321,6 +323,7 @@ pub struct Keyword {
321323

322324
#[derive(Debug, PartialEq)]
323325
pub struct ExceptHandler {
326+
pub location: Location,
324327
pub typ: Option<Expression>,
325328
pub name: Option<String>,
326329
pub body: Vec<Statement>,

parser/src/parser.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,15 @@ mod tests {
233233
Ok(vec![as_statement(ast::Expression {
234234
location: ast::Location::new(1, 1),
235235
node: ast::ExpressionType::Lambda {
236-
args: ast::Parameters {
236+
args: Box::new(ast::Parameters {
237237
args: vec![
238238
ast::Parameter {
239+
location: ast::Location::new(1, 8),
239240
arg: String::from("x"),
240241
annotation: None,
241242
},
242243
ast::Parameter {
244+
location: ast::Location::new(1, 11),
243245
arg: String::from("y"),
244246
annotation: None,
245247
}
@@ -249,7 +251,7 @@ mod tests {
249251
kwarg: ast::Varargs::None,
250252
defaults: vec![],
251253
kw_defaults: vec![],
252-
},
254+
}),
253255
body: Box::new(ast::Expression {
254256
location: ast::Location::new(1, 16),
255257
node: ast::ExpressionType::Binop {
@@ -308,8 +310,9 @@ mod tests {
308310
node: ast::StatementType::FunctionDef {
309311
is_async: false,
310312
name: String::from("__init__"),
311-
args: ast::Parameters {
313+
args: Box::new(ast::Parameters {
312314
args: vec![ast::Parameter {
315+
location: ast::Location::new(2, 15),
313316
arg: String::from("self"),
314317
annotation: None,
315318
}],
@@ -318,7 +321,7 @@ mod tests {
318321
kwarg: ast::Varargs::None,
319322
defaults: vec![],
320323
kw_defaults: vec![],
321-
},
324+
}),
322325
body: vec![ast::Statement {
323326
location: ast::Location::new(3, 3),
324327
node: ast::StatementType::Pass,
@@ -332,13 +335,15 @@ mod tests {
332335
node: ast::StatementType::FunctionDef {
333336
is_async: false,
334337
name: String::from("method_with_default"),
335-
args: ast::Parameters {
338+
args: Box::new(ast::Parameters {
336339
args: vec![
337340
ast::Parameter {
341+
location: ast::Location::new(4, 26),
338342
arg: String::from("self"),
339343
annotation: None,
340344
},
341345
ast::Parameter {
346+
location: ast::Location::new(4, 32),
342347
arg: String::from("arg"),
343348
annotation: None,
344349
}
@@ -348,7 +353,7 @@ mod tests {
348353
kwarg: ast::Varargs::None,
349354
defaults: vec![make_string("default", 4, 37)],
350355
kw_defaults: vec![],
351-
},
356+
}),
352357
body: vec![ast::Statement {
353358
location: ast::Location::new(5, 3),
354359
node: ast::StatementType::Pass,
@@ -377,6 +382,7 @@ mod tests {
377382
element: mk_ident("x", 1, 2),
378383
}),
379384
generators: vec![ast::Comprehension {
385+
location: ast::Location::new(1, 4),
380386
target: mk_ident("y", 1, 8),
381387
iter: mk_ident("z", 1, 13),
382388
ifs: vec![],
@@ -400,6 +406,7 @@ mod tests {
400406
}),
401407
generators: vec![
402408
ast::Comprehension {
409+
location: ast::Location::new(1, 4),
403410
target: ast::Expression {
404411
location: ast::Location::new(1, 8),
405412
node: ast::ExpressionType::Tuple {
@@ -410,6 +417,7 @@ mod tests {
410417
ifs: vec![],
411418
},
412419
ast::Comprehension {
420+
location: ast::Location::new(1, 19),
413421
target: mk_ident("a", 1, 23),
414422
iter: mk_ident("b", 1, 28),
415423
ifs: vec![

0 commit comments

Comments
 (0)