renamed main

This commit is contained in:
gnembon committed 2020-01-08 23:47:54 -04:00
1 parent 4f65be946c
commit f674936199
5 files changed
+20 -20

No files matched your search

@@ -60,7 +60,7 @@ public class CarpetScriptHost extends ScriptHost
return null;
}
host.setChatErrorSnooper(source);
CarpetExpression ex = new CarpetExpression(host.myCode, code, source, new BlockPos(0, 0, 0));
CarpetExpression ex = new CarpetExpression(host.main, code, source, new BlockPos(0, 0, 0));
ex.getExpr().asATextSource();
ex.scriptRunCommand(host, new BlockPos(source.getPosition()));
}
@@ -78,7 +78,7 @@ public class CarpetScriptHost extends ScriptHost
@Override
protected ScriptHost duplicate()
{
return new CarpetScriptHost(scriptServer, myCode, false, this);
return new CarpetScriptHost(scriptServer, main, false, this);
}
@Override
@@ -312,19 +312,19 @@ public class CarpetScriptHost extends ScriptHost
private void dumpState()
{
myCode.saveData(null, globalState);
main.saveData(null, globalState);
}
private Tag loadState()
{
return myCode.getData(null);
return main.getData(null);
}
public Tag getGlobalState(String file)
{
if (getName() == null ) return null;
if (file != null)
return myCode.getData(file);
return main.getData(file);
if (parent == null)
return globalState;
return ((CarpetScriptHost)parent).globalState;
@@ -336,7 +336,7 @@ public class CarpetScriptHost extends ScriptHost
if (file!= null)
{
myCode.saveData(file, tag);
main.saveData(file, tag);
return;
}
@@ -217,7 +217,7 @@ public class CarpetScriptServer
return 1;
});
for (String function : host.globaFunctionNames(host.myCode, s -> !s.startsWith("_")).sorted().collect(Collectors.toList()))
for (String function : host.globaFunctionNames(host.main, s -> !s.startsWith("_")).sorted().collect(Collectors.toList()))
{
command = command.
then(literal(function).
@@ -48,8 +48,8 @@ public class ExpressionInspector
// not that useful in commandline, more so in external scripts, so skipping here
//scarpetMatches.addAll(CarpetServer.scriptServer.events.eventHandlers.keySet().stream().
// filter(s -> s.startsWith(prefix) && s.length() <= maxLen).map(s -> "__"+s+"(").collect(Collectors.toList()));
scarpetMatches.addAll(host.globaFunctionNames(host.myCode, s -> s.startsWith(prefix)).map(s -> s+"(").collect(Collectors.toList()));
scarpetMatches.addAll(host.globaVariableNames(host.myCode, s -> s.startsWith(prefix)).collect(Collectors.toList()));
scarpetMatches.addAll(host.globaFunctionNames(host.main, s -> s.startsWith(prefix)).map(s -> s+"(").collect(Collectors.toList()));
scarpetMatches.addAll(host.globaVariableNames(host.main, s -> s.startsWith(prefix)).collect(Collectors.toList()));
return scarpetMatches;
}
}
+5 -5
View File
@@ -64,16 +64,16 @@ public abstract class ScriptHost
protected ScriptHost parent;
protected boolean perUser;
public String getName() {return myCode==null?null:myCode.getName();}
public String getName() {return main ==null?null: main.getName();}
public final Module myCode;
public final Module main;
public Fluff.TriFunction<Expression, Tokenizer.Token, String, List<String>> errorSnooper = null;
protected ScriptHost(Module code, boolean perUser, ScriptHost parent)
{
this.parent = parent;
this.myCode = code;
this.main = code;
this.perUser = perUser;
ModuleData moduleData = new ModuleData(code);
initializeModuleGlobals(moduleData);
@@ -138,7 +138,7 @@ public abstract class ScriptHost
protected abstract void runModuleCode(Context c, Module module); // this should be shell out in the executor
public FunctionValue getFunction(String name) { return getFunction(myCode, name); }
public FunctionValue getFunction(String name) { return getFunction(main, name); }
public FunctionValue getAssertFunction(Module module, String name)
{
FunctionValue ret = getFunction(module, name);
@@ -178,7 +178,7 @@ public abstract class ScriptHost
return null;
}
public LazyValue getGlobalVariable(String name) { return getGlobalVariable(myCode, name); }
public LazyValue getGlobalVariable(String name) { return getGlobalVariable(main, name); }
public LazyValue getGlobalVariable(Module module, String name)
{
ModuleData local = moduleData.get(module);