-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Maxel Black
committed
Mar 7, 2021
1 parent
03ca98a
commit 0d1a781
Showing
9 changed files
with
101 additions
and
33 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
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,36 @@ | ||
package ink.pd2.shell.buildin; | ||
|
||
import ink.pd2.shell.core.Mark; | ||
|
||
import java.util.HashMap; | ||
|
||
public class VariableMark extends Mark { | ||
private final VariableMark parent; //上级标记对象 | ||
private final HashMap<String, String> variables = new HashMap<>(); //本级变量存储 | ||
|
||
protected VariableMark(VariableMark parent) { | ||
this.parent = parent; | ||
} | ||
|
||
public String get(String key) { | ||
String v = variables.get(key); | ||
if (v == null) | ||
if (parent == null) return null; | ||
else return parent.get(key); | ||
return v; | ||
} | ||
public String put(String key, String value) { | ||
return variables.put(key, value); | ||
} | ||
public String remove(String key) { | ||
return variables.remove(key); | ||
} | ||
|
||
public VariableMark getParent() { | ||
return parent; | ||
} | ||
|
||
public VariableMark newChild() { | ||
return new VariableMark(this); | ||
} | ||
} |
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
4 changes: 2 additions & 2 deletions
4
...2/shell/core/CommandExecutedListener.java → ...d2/shell/core/CommandEnteredListener.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
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