Skip to content

Commit

Permalink
FIX: Trim space(shell)
Browse files Browse the repository at this point in the history
- Add `task system pipe`
- Add `task system share`
  • Loading branch information
bajdcc committed Apr 18, 2017
1 parent 29204fc commit c052b8e
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,11 @@ public interface IRuntimePipeService {
* @return 是否存在
*/
boolean query(String name);

/**
* 获取管道数量
*
* @return 管道数量
*/
long size();
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,11 @@ public interface IRuntimeShareService {
* @param lock 是否锁定
*/
void setLocked(String name, boolean lock);

/**
* 获取共享数量
*
* @return 共享数量
*/
long size();
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,9 @@ public boolean isEmpty(int handle) {
public boolean query(String name) {
return mapPipeNames.containsKey(name);
}

@Override
public long size() {
return setPipeId.size();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,9 @@ public void setLocked(String name, boolean lock) {
if (mapShares.containsKey(name))
mapShares.get(name).locked = lock;
}

@Override
public long size() {
return mapShares.size();
}
}
51 changes: 51 additions & 0 deletions src/priv/bajdcc/LALR1/interpret/module/ModuleTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,57 @@ public RuntimeObject ExternalProcCall(List<RuntimeObject> args,
return new RuntimeObject(BigInteger.valueOf(System.currentTimeMillis()));
}
});
info.addExternalFunc("g_task_get_timestamp", new IRuntimeDebugExec() {
@Override
public String getDoc() {
return "获取当前时间戳";
}

@Override
public RuntimeObjectType[] getArgsType() {
return null;
}

@Override
public RuntimeObject ExternalProcCall(List<RuntimeObject> args,
IRuntimeStatus status) throws Exception {
return new RuntimeObject(BigInteger.valueOf(System.currentTimeMillis()));
}
});
info.addExternalFunc("g_task_get_pipe_count", new IRuntimeDebugExec() {
@Override
public String getDoc() {
return "获取管道数量";
}

@Override
public RuntimeObjectType[] getArgsType() {
return null;
}

@Override
public RuntimeObject ExternalProcCall(List<RuntimeObject> args,
IRuntimeStatus status) throws Exception {
return new RuntimeObject(BigInteger.valueOf(status.getService().getPipeService().size()));
}
});
info.addExternalFunc("g_task_get_share_count", new IRuntimeDebugExec() {
@Override
public String getDoc() {
return "获取共享数量";
}

@Override
public RuntimeObjectType[] getArgsType() {
return null;
}

@Override
public RuntimeObject ExternalProcCall(List<RuntimeObject> args,
IRuntimeStatus status) throws Exception {
return new RuntimeObject(BigInteger.valueOf(status.getService().getShareService().size()));
}
});
}

private void buildUtilMethod(IRuntimeDebugInfo info) {
Expand Down
6 changes: 6 additions & 0 deletions src/priv/bajdcc/LALR1/interpret/os/task/TKSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ public String getCode() {
" let val = call g_task_get_time(\"yyyy-MM-dd HH:mm:ss\");\n" +
" }\n" +
" call g_map_put(msg, \"val\", val);\n" +
" } else if (id == \"pipe\") {\n" +
" var val = call g_task_get_pipe_count();\n" +
" call g_map_put(msg, \"val\", val);\n" +
" } else if (id == \"share\") {\n" +
" var val = call g_task_get_share_count();\n" +
" call g_map_put(msg, \"val\", val);\n" +
" }\n" +
"};\n" +
"\n" +
Expand Down
4 changes: 2 additions & 2 deletions src/priv/bajdcc/LALR1/interpret/os/user/routine/URRange.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public String getCode() {
" call g_destroy_pipe(in);\n" +
" return;\n" +
"}\n" +
"var lower = 0 + call g_array_get(args, 0);\n" +
"var upper = 0 + call g_array_get(args, 1);\n" +
"var lower = call g_string_atoi(call g_array_get(args, 0));\n" +
"var upper = call g_string_atoi(call g_array_get(args, 1));\n" +
"if (lower > upper) {\n" +
" for (var i = lower; i >= upper && call g_query_share(signal); i--) {\n" +
" foreach (var j : call g_range_string(call g_to_string(i))) {\n" +
Expand Down
18 changes: 16 additions & 2 deletions src/priv/bajdcc/LALR1/interpret/os/user/routine/URShell.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,14 @@ public String getCode() {
" var parent = call g_map_get(arg, \"parent\");\n" +
" var exe = call g_array_pop(cmd);\n" +
" let exe = call g_string_trim(exe);\n" +
" var args = call g_string_split(exe, \" \");\n" +
" var _args = call g_string_split(exe, \" \");\n" +
" var args = [];\n" +
" foreach (var s :call g_range_array(_args)) {\n" +
" var ss = call g_string_trim(s);\n" +
" if (!call g_string_empty(ss)) {\n" +
" call g_array_add(args, ss);\n" +
" }\n" +
" }\n" +
" var exec = call g_array_get(args, 0);\n" +
" call g_array_remove(args, 0);\n" +
" var share = {};\n" +
Expand Down Expand Up @@ -97,7 +104,14 @@ public String getCode() {
" var pid = call g_get_pid();\n" +
" var exe = call g_array_pop(cmd);\n" +
" let exe = call g_string_trim(exe);\n" +
" var args = call g_string_split(exe, \" \");\n" +
" var _args = call g_string_split(exe, \" \");\n" +
" var args = [];\n" +
" foreach (var s :call g_range_array(_args)) {\n" +
" var ss = call g_string_trim(s);\n" +
" if (!call g_string_empty(ss)) {\n" +
" call g_array_add(args, ss);\n" +
" }\n" +
" }\n" +
" var exec = call g_array_get(args, 0);\n" +
" call g_array_remove(args, 0);\n" +
" var share = {};\n" +
Expand Down

0 comments on commit c052b8e

Please sign in to comment.