Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Java - Styve - Teachers Choice Interpreted Language
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Leo
Java - Styve - Teachers Choice Interpreted Language
Commits
b0a048d5
Commit
b0a048d5
authored
10 months ago
by
Leo
Browse files
Options
Downloads
Patches
Plain Diff
feat: fix nesting
parent
c4c90a48
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/08_nesting.asty
+3
-4
3 additions, 4 deletions
examples/08_nesting.asty
src/runtime/eval/Expressions.java
+2
-2
2 additions, 2 deletions
src/runtime/eval/Expressions.java
src/runtime/eval/Statements.java
+1
-1
1 addition, 1 deletion
src/runtime/eval/Statements.java
with
6 additions
and
7 deletions
examples/08_nesting.asty
+
3
−
4
View file @
b0a048d5
...
...
@@ -2,16 +2,15 @@ Arne Arne Styve Arne Arne flattenArray (array, row) 8=
Gjenta Arne Arne Arne i Arne 0 Styve i Underflow array Arne Styve antall Styve i++ 8=
Arne Arne Arne elem Arne array Ransak i Styve
Arne? (Array Arne Styve ArneArray(elem)) 8=
--- STANDUP(globalEnv) Styve
STANDUP("Recursing into array:", elem, "At row:", row, " | New row:", row + 1) Styve
flattenArray(elem, row + 1) Styve
flattenArray(elem, row) Styve
row++ Styve
=D Styve? 8=
STANDUP("Element", row + ":" + i, "=", elem) Styve
=D
=D
=D
Arne Arne Styve arr Arne ..1, 2, 3
.
,
.
4, 5,
6
., .
7
,
8
.. Styve
Arne Arne Styve arr Arne ..1,
.
2, 3, 4
.
, 5
.
,
.6, 7, 8
., .
9
,
10
.. Styve
STANDUP("Flattening array:", arr) Styve
flattenArray(arr, 0) Styve
...
...
This diff is collapsed.
Click to expand it.
src/runtime/eval/Expressions.java
+
2
−
2
View file @
b0a048d5
...
...
@@ -384,12 +384,12 @@ public static RTValue evalPostfixOperatorExpr(PostfixOperatorExpr postfixOp, Env
throw
new
RuntimeException
(
"Evaluation error: Call target must be an identifier, got "
+
call
.
getFunction
().
getKind
());
}
RTValue
fn
=
Interpreter
.
evaluate
(
call
.
getFunction
(),
env
,
debug
);
Environment
callEnv
=
new
Environment
(
env
);
Environment
callEnv
=
env
.
createChild
Environment
();
// Check if the call target is a member expression, if so it needs to be an anonymous function
if
(
call
.
getFunction
().
getKind
()
==
NodeType
.
MemberExpr
)
{
if
(
fn
.
typeIs
(
rtValueType
.
FN
))
{
RTFunctionCall
fnCall
=
(
RTFunctionCall
)
fn
;
callEnv
=
fnCall
.
getDeclarationEnv
();
callEnv
=
fnCall
.
getDeclarationEnv
()
.
createChildEnvironment
()
;
if
(!
fnCall
.
isAnonymous
())
{
throw
new
RuntimeException
(
"Evaluation error: call target is not an anonymous function"
);
}
...
...
This diff is collapsed.
Click to expand it.
src/runtime/eval/Statements.java
+
1
−
1
View file @
b0a048d5
...
...
@@ -84,7 +84,7 @@ public class Statements {
public
static
RTValue
evalForStmt
(
ForStmt
forStmt
,
Environment
env
,
boolean
debug
)
{
// Evaluate the initializer of the for statement
Environment
innerEnv
=
new
Environment
(
env
);
Environment
innerEnv
=
env
.
createChild
Environment
();
if
(
forStmt
.
getInitializer
()
!=
null
)
{
Interpreter
.
evaluate
(
forStmt
.
getInitializer
(),
innerEnv
,
debug
);
}
...
...
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