-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Updated instruction format and explanations in VM_Design.md.
2. Removed unnecessary code in CymbolAssembler. 3. Updated dependencies in pom.xml.
- Loading branch information
Showing
13 changed files
with
290 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,38 @@ | ||
.def main: args=0 ,locals=0 | ||
.def dec1: args=1 ,locals=1: | ||
iconst 1 | ||
iload 0 | ||
br L2 | ||
L2: | ||
ret | ||
.def main: args=0 ,locals=1: | ||
iconst 10 | ||
istore 0 | ||
br L5 | ||
L5: | ||
iconst 0 | ||
br main_0 | ||
main_0 : | ||
halt | ||
iload 0 | ||
brf L7 | ||
L6: | ||
iconst 5 | ||
iload 0 | ||
brf L9 | ||
L8: | ||
iload 0 | ||
call print() | ||
iconst 7 | ||
iload 0 | ||
brf L11 | ||
L10: | ||
iconst 7 | ||
br L4 | ||
L9: | ||
call print() | ||
iload 0 | ||
call dec1() | ||
istore 0 | ||
br L5 | ||
L7: | ||
iconst 0 | ||
br L4 | ||
L4: | ||
ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
ep20/src/main/java/org/teachfx/antlr4/ep20/driver/Task.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.teachfx.antlr4.ep20.driver; | ||
import java.util.Optional; | ||
import java.util.function.Function; | ||
|
||
/** | ||
* Represents a "task" function that accepts one argument and may produce a result. Can be regarded as a "partial" | ||
* function. | ||
*/ | ||
public interface Task<T, R> extends Function<T, Optional<R>> { | ||
/** | ||
* Pipe two tasks. This will return a function which does "this" first, if succeeds, continue do {@code next} with | ||
* the previous result as input; or else exits and returns {@link Optional#empty}. | ||
* <p> | ||
* In terms of monad, this is just a Kleisli composition. | ||
* | ||
* @param next the next function | ||
* @return the piped (Kleisli-composed) function | ||
*/ | ||
default <V> Task<T, V> then(Task<R, V> next) { | ||
return t -> this.apply(t).flatMap(next); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.