Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
erode
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Per Lindgren
erode
Commits
2f1cb57d
Commit
2f1cb57d
authored
Sep 20, 2020
by
Per Lindgren
Browse files
Options
Downloads
Patches
Plain Diff
prepare for semi change
parent
990d4f0f
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
examples/call3.rs
+1
-1
1 addition, 1 deletion
examples/call3.rs
src/ast.rs
+6
-4
6 additions, 4 deletions
src/ast.rs
src/check.rs
+1
-0
1 addition, 0 deletions
src/check.rs
src/vm.rs
+1
-0
1 addition, 0 deletions
src/vm.rs
with
9 additions
and
5 deletions
examples/call3.rs
+
1
−
1
View file @
2f1cb57d
fn
f
(
mut
x
:
i32
,
mut
y
:
i32
)
->
i32
{
fn
f
(
mut
x
:
i32
,
mut
y
:
i32
)
->
i32
{
x
=
x
+
1
;
// mutable paramer
x
=
x
+
1
;
// mutable parame
te
r
x
+
y
x
+
y
}
}
...
...
This diff is collapsed.
Click to expand it.
src/ast.rs
+
6
−
4
View file @
2f1cb57d
...
@@ -36,6 +36,7 @@ pub enum Stmt {
...
@@ -36,6 +36,7 @@ pub enum Stmt {
Expr
(
Box
<
Expr
>
),
Expr
(
Box
<
Expr
>
),
// perhaps block should be expression, hmm everything is expressions?
// perhaps block should be expression, hmm everything is expressions?
Block
(
Stmts
),
Block
(
Stmts
),
Semi
,
}
}
#[derive(Debug,
PartialEq,
Clone)]
#[derive(Debug,
PartialEq,
Clone)]
...
@@ -213,13 +214,13 @@ impl Stmts {
...
@@ -213,13 +214,13 @@ impl Stmts {
fn
ifmt
(
&
self
,
fmt
:
&
mut
Formatter
,
indent
:
usize
)
->
Result
<
(),
Error
>
{
fn
ifmt
(
&
self
,
fmt
:
&
mut
Formatter
,
indent
:
usize
)
->
Result
<
(),
Error
>
{
write!
(
fmt
,
"{{"
)
?
;
write!
(
fmt
,
"{{"
)
?
;
let
len
=
self
.stmts
.len
();
let
len
=
self
.stmts
.len
();
for
(
i
,
s
)
in
(
&
self
.stmts
)
.into_iter
()
.enumerate
()
{
for
(
_
i
,
s
)
in
(
&
self
.stmts
)
.into_iter
()
.enumerate
()
{
// set tab
// set tab
write!
(
fmt
,
"
\n
{}"
,
" "
.repeat
(
indent
+
4
))
?
;
write!
(
fmt
,
"
\n
{}"
,
" "
.repeat
(
indent
+
4
))
?
;
s
.ifmt
(
fmt
,
indent
+
4
)
?
;
s
.ifmt
(
fmt
,
indent
+
4
)
?
;
if
i
<
len
-
1
||
self
.ret
{
//
if i < len - 1 || self.ret {
write!
(
fmt
,
";"
)
?
;
//
write!(fmt, ";")?;
}
//
}
}
}
write!
(
fmt
,
"
\n
{}}}"
,
" "
.repeat
(
indent
))
write!
(
fmt
,
"
\n
{}}}"
,
" "
.repeat
(
indent
))
}
}
...
@@ -260,6 +261,7 @@ impl Stmt {
...
@@ -260,6 +261,7 @@ impl Stmt {
Ok
(())
Ok
(())
}
}
Stmt
::
Expr
(
e
)
=>
write!
(
fmt
,
"{}"
,
e
),
Stmt
::
Expr
(
e
)
=>
write!
(
fmt
,
"{}"
,
e
),
Stmt
::
Semi
=>
write!
(
fmt
,
";"
),
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/check.rs
+
1
−
0
View file @
2f1cb57d
...
@@ -361,6 +361,7 @@ pub fn check_stmts(
...
@@ -361,6 +361,7 @@ pub fn check_stmts(
}
}
_
=>
Err
(
"Condition not Boolean"
.to_string
()),
_
=>
Err
(
"Condition not Boolean"
.to_string
()),
},
},
Semi
=>
panic!
(
"ICE"
),
}
}
})
?
;
})
?
;
...
...
This diff is collapsed.
Click to expand it.
src/vm.rs
+
1
−
0
View file @
2f1cb57d
...
@@ -286,6 +286,7 @@ fn eval_stmts(stmts: &Stmts, m: &mut Mem, fn_env: &FnEnv) -> Val {
...
@@ -286,6 +286,7 @@ fn eval_stmts(stmts: &Stmts, m: &mut Mem, fn_env: &FnEnv) -> Val {
println!
(
"block"
);
println!
(
"block"
);
eval_stmts
(
block
,
m
,
fn_env
)
eval_stmts
(
block
,
m
,
fn_env
)
}
}
Stmt
::
Semi
=>
panic!
(
"ICE"
),
}
}
}
}
m
.pop_scope
();
m
.pop_scope
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment