本文整理汇总了C#中Ioke.Lang.IokeObject.RegisterCell方法的典型用法代码示例。如果您正苦于以下问题:C# IokeObject.RegisterCell方法的具体用法?C# IokeObject.RegisterCell怎么用?C# IokeObject.RegisterCell使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ioke.Lang.IokeObject
的用法示例。
在下文中一共展示了IokeObject.RegisterCell方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public static void Init(IokeObject obj)
{
Runtime runtime = obj.runtime;
obj.Kind = "Restart";
obj.RegisterCell("name", runtime.nil);
obj.RegisterCell("report", runtime.EvaluateString("fn(r, \"restart: \" + r name)", runtime.Message, runtime.Ground));
obj.RegisterCell("test", runtime.EvaluateString("fn(c, true)", runtime.Message, runtime.Ground));
obj.RegisterCell("code", runtime.EvaluateString("fn()", runtime.Message, runtime.Ground));
obj.RegisterCell("argumentNames", runtime.EvaluateString("method(self code argumentNames)", runtime.Message, runtime.Ground));
}
示例2: Init
public override void Init(IokeObject obj)
{
Runtime runtime = obj.runtime;
obj.Kind = "Regexp";
IokeObject regexpMatch = new IokeObject(runtime, "contains behavior related to assignment", new RegexpMatch(obj, null, null));
regexpMatch.MimicsWithoutCheck(runtime.Origin);
regexpMatch.Init();
obj.RegisterCell("Match", regexpMatch);
obj.RegisterMethod(runtime.NewNativeMethod("returns a hash for the regexp",
new NativeMethod.WithNoArguments("hash", (method, context, message, on, outer) => {
outer.ArgumentsDefinition.CheckArgumentCount(context, message, on);
Regexp r = (Regexp)IokeObject.dataOf(on);
return context.runtime.NewNumber(r.pattern.GetHashCode() + 13 * r.flags.GetHashCode());
})));
obj.RegisterMethod(runtime.NewNativeMethod("returns true if the left hand side pattern is equal to the right hand side pattern.",
new TypeCheckingNativeMethod("==", TypeCheckingArgumentsDefinition.builder()
.ReceiverMustMimic(runtime.Regexp)
.WithRequiredPositional("other")
.Arguments,
(method, on, args, keywords, context, message) => {
Regexp d = (Regexp)IokeObject.dataOf(on);
object other = args[0];
return ((other is IokeObject) &&
(IokeObject.dataOf(other) is Regexp) &&
((on == context.runtime.Regexp || other == context.runtime.Regexp) ? on == other :
(d.pattern.Equals(((Regexp)IokeObject.dataOf(other)).pattern) &&
d.flags.Equals(((Regexp)IokeObject.dataOf(other)).flags)))) ? context.runtime.True : context.runtime.False;
})));
obj.RegisterMethod(runtime.NewNativeMethod("Returns the pattern use for this regular expression",
new TypeCheckingNativeMethod.WithNoArguments("pattern", obj,
(method, on, args, keywords, context, message) => {
return context.runtime.NewText(GetPattern(on));
})));
obj.RegisterMethod(runtime.NewNativeMethod("Takes one argument and tries to match that argument against the current pattern. Returns nil if no match can be done, or a Regexp Match object if a match succeeds",
new TypeCheckingNativeMethod("match", TypeCheckingArgumentsDefinition.builder()
.ReceiverMustMimic(obj)
.WithRequiredPositional("other")
.Arguments,
(method, on, args, keywords, context, message) => {
IokeObject target = IokeObject.As(Interpreter.Send(context.runtime.asText, context, args[0]), context);
string arg = Text.GetText(target);
Matcher m = ((Regexp)IokeObject.dataOf(on)).regexp.Matcher(arg);
if(m.Find()) {
IokeObject match = regexpMatch.AllocateCopy(message, context);
match.MimicsWithoutCheck(regexpMatch);
match.Data = new RegexpMatch(IokeObject.As(on, context), m, target);
return match;
} else {
return context.runtime.nil;
}
})));
obj.AliasMethod("match", "=~", null, null);
obj.RegisterMethod(runtime.NewNativeMethod("Takes one argument that should be a text and returns a text that has all regexp meta characters quoted",
new NativeMethod("quote", DefaultArgumentsDefinition.builder()
.WithRequiredPositional("text")
.Arguments,
(method, on, args, keywords, context, message) => {
return context.runtime.NewText(Pattern.Quote(Text.GetText(Interpreter.Send(context.runtime.asText, context, args[0]))));
})));
obj.RegisterMethod(runtime.NewNativeMethod("Takes one or two text arguments that describes the regular expression to create. the first text is the pattern and the second is the flags.",
new NativeMethod("from", DefaultArgumentsDefinition.builder()
.WithRequiredPositional("pattern")
.WithOptionalPositional("flags", "")
.Arguments,
(method, on, args, keywords, context, message) => {
string pattern = Text.GetText(Interpreter.Send(context.runtime.asText, context, args[0]));
string flags = "";
if(args.Count > 1) {
flags = Text.GetText(Interpreter.Send(context.runtime.asText, context, args[1]));
}
return context.runtime.NewRegexp(pattern, flags, context, message);
})));
obj.RegisterMethod(runtime.NewNativeMethod("Takes one argument and tries to match that argument against the current pattern. Returns a list of all the texts that were matched.",
new TypeCheckingNativeMethod("allMatches", TypeCheckingArgumentsDefinition.builder()
.ReceiverMustMimic(obj)
.WithRequiredPositional("other")
.Arguments,
(method, on, args, keywords, context, message) => {
string arg = Text.GetText(Interpreter.Send(context.runtime.asText, context, args[0]));
Matcher m = ((Regexp)IokeObject.dataOf(on)).regexp.Matcher(arg);
var result = new SaneArrayList();
MatchIterator iter = m.FindAll();
while(iter.HasMore) {
result.Add(runtime.NewText(iter.NextMatch.Group(0)));
}
return runtime.NewList(result);
//.........这里部分代码省略.........
示例3: Init
public override void Init(IokeObject obj)
{
obj.Kind = "DefaultSyntax";
obj.RegisterCell("activatable", obj.runtime.True);
obj.RegisterMethod(obj.runtime.NewNativeMethod("returns the name of the syntax",
new TypeCheckingNativeMethod.WithNoArguments("name", obj,
(method, on, args, keywords, _context, message) => {
return _context.runtime.NewText(((DefaultSyntax)IokeObject.dataOf(on)).name);
})));
obj.RegisterMethod(obj.runtime.NewNativeMethod("activates this syntax with the arguments given to call",
new NativeMethod("call", DefaultArgumentsDefinition.builder()
.WithRestUnevaluated("arguments")
.Arguments,
(method, _context, message, on, outer) => {
return IokeObject.As(on, _context).Activate(_context, message, _context.RealContext);
})));
obj.RegisterMethod(obj.runtime.NewNativeMethod("returns the result of activating this syntax without actually doing the replacement or execution part.",
new NativeMethod("expand", DefaultArgumentsDefinition.builder()
.WithRestUnevaluated("arguments")
.Arguments,
(method, _context, message, on, outer) => {
object onAsSyntax = _context.runtime.DefaultSyntax.ConvertToThis(on, message, _context);
return ((DefaultSyntax)IokeObject.dataOf(onAsSyntax)).Expand(IokeObject.As(onAsSyntax, context), context, message, context.RealContext, null);
})));
obj.RegisterMethod(obj.runtime.NewNativeMethod("returns the message chain for this syntax",
new TypeCheckingNativeMethod.WithNoArguments("message", obj,
(method, on, args, keywords, _context, message) => {
return ((AssociatedCode)IokeObject.dataOf(on)).Code;
})));
obj.RegisterMethod(obj.runtime.NewNativeMethod("returns the code for the argument definition",
new TypeCheckingNativeMethod.WithNoArguments("argumentsCode", obj,
(method, on, args, keywords, _context, message) => {
return _context.runtime.NewText(((AssociatedCode)IokeObject.dataOf(on)).ArgumentsCode);
})));
obj.RegisterMethod(obj.runtime.NewNativeMethod("Returns a text inspection of the object",
new TypeCheckingNativeMethod.WithNoArguments("inspect", obj,
(method, on, args, keywords, _context, message) => {
return _context.runtime.NewText(DefaultSyntax.GetInspect(on));
})));
obj.RegisterMethod(obj.runtime.NewNativeMethod("Returns a brief text inspection of the object",
new TypeCheckingNativeMethod.WithNoArguments("notice", obj,
(method, on, args, keywords, _context, message) => {
return _context.runtime.NewText(DefaultSyntax.GetNotice(on));
})));
obj.RegisterMethod(obj.runtime.NewNativeMethod("returns the full code of this syntax, as a Text",
new TypeCheckingNativeMethod.WithNoArguments("code", obj,
(method, on, args, keywords, _context, message) => {
IokeData data = IokeObject.dataOf(on);
if(data is DefaultSyntax) {
return _context.runtime.NewText(((DefaultSyntax)data).CodeString);
} else {
return _context.runtime.NewText(((AliasMethod)data).CodeString);
}
})));
obj.RegisterMethod(obj.runtime.NewNativeMethod("returns idiomatically formatted code for this syntax",
new TypeCheckingNativeMethod.WithNoArguments("formattedCode", obj,
(method, on, args, keywords, _context, message) => {
return _context.runtime.NewText(((AssociatedCode)IokeObject.dataOf(on)).FormattedCode(method));
})));
}
示例4: Init
public static void Init(IokeObject obj)
{
Runtime runtime = obj.runtime;
obj.Kind = "FileSystem";
IokeObject file = new IokeObject(runtime, "represents a file in the file system", new IokeFile(null));
file.MimicsWithoutCheck(runtime.Io);
file.Init();
obj.RegisterCell("File", file);
obj.RegisterMethod(runtime.NewNativeMethod("Tries to interpret the given arguments as strings describing file globs, and returns an array containing the result of applying these globs.",
new NativeMethod("[]", DefaultArgumentsDefinition.builder()
.WithRest("globTexts")
.Arguments,
(method, context, message, on, outer) => {
var args = new SaneArrayList();
outer.ArgumentsDefinition.GetEvaluatedArguments(context, message, on, args, new SaneDictionary<string, object>());
var dirs = FileSystem.Glob(context.runtime, Text.GetText(args[0]));
var result = new SaneArrayList();
foreach(string s in dirs) {
result.Add(context.runtime.NewText(s));
}
return context.runtime.NewList(result);
})));
obj.RegisterMethod(runtime.NewNativeMethod("Takes one string argument and returns true if it's the relative or absolute name of a directory, and false otherwise.",
new NativeMethod("directory?", DefaultArgumentsDefinition.builder()
.WithRequiredPositional("directoryName")
.Arguments,
(method, context, message, on, outer) => {
var args = new SaneArrayList();
outer.ArgumentsDefinition.GetEvaluatedArguments(context, message, on, args, new SaneDictionary<string, object>());
string name = Text.GetText(args[0]);
DirectoryInfo f = null;
if(IokeSystem.IsAbsoluteFileName(name)) {
f = new DirectoryInfo(name);
} else {
f = new DirectoryInfo(Path.Combine(context.runtime.CurrentWorkingDirectory, name));
}
return f.Exists ? context.runtime.True : context.runtime.False;
})));
obj.RegisterMethod(runtime.NewNativeMethod("Takes one string argument that should be a file name, and returns a text of the contents of this file.",
new NativeMethod("readFully", DefaultArgumentsDefinition.builder()
.WithRequiredPositional("fileName")
.Arguments,
(method, context, message, on, outer) => {
var args = new SaneArrayList();
outer.ArgumentsDefinition.GetEvaluatedArguments(context, message, on, args, new SaneDictionary<string, object>());
string name = Text.GetText(args[0]);
FileInfo f = null;
if(IokeSystem.IsAbsoluteFileName(name)) {
f = new FileInfo(name);
} else {
f = new FileInfo(Path.Combine(context.runtime.CurrentWorkingDirectory, name));
}
return context.runtime.NewText(File.ReadAllText(f.FullName));
})));
obj.RegisterMethod(runtime.NewNativeMethod("Takes one string argument and returns true if it's the relative or absolute name of a file, and false otherwise.",
new NativeMethod("file?", DefaultArgumentsDefinition.builder()
.WithRequiredPositional("fileName")
.Arguments,
(method, context, message, on, outer) => {
var args = new SaneArrayList();
outer.ArgumentsDefinition.GetEvaluatedArguments(context, message, on, args, new SaneDictionary<string, object>());
string name = Text.GetText(args[0]);
FileInfo f = null;
if(IokeSystem.IsAbsoluteFileName(name)) {
f = new FileInfo(name);
} else {
f = new FileInfo(Path.Combine(context.runtime.CurrentWorkingDirectory, name));
}
return f.Exists ? context.runtime.True : context.runtime.False;
})));
obj.RegisterMethod(runtime.NewNativeMethod("Takes one string argument and returns true if it's the relative or absolute name of something that exists.",
new NativeMethod("exists?", DefaultArgumentsDefinition.builder()
.WithRequiredPositional("entryName")
.Arguments,
(method, context, message, on, outer) => {
var args = new SaneArrayList();
outer.ArgumentsDefinition.GetEvaluatedArguments(context, message, on, args, new SaneDictionary<string, object>());
string name = Text.GetText(args[0]);
string nx = null;
if(IokeSystem.IsAbsoluteFileName(name)) {
nx = name;
} else {
nx = Path.Combine(context.runtime.CurrentWorkingDirectory, name);
}
return (new FileInfo(nx).Exists || new DirectoryInfo(nx).Exists) ? context.runtime.True : context.runtime.False;
//.........这里部分代码省略.........
示例5: Init
public override void Init(IokeObject obj)
{
Runtime runtime = obj.runtime;
obj.Kind = "System";
if(currentWorkingDirectory == null) {
// Use CLRs CWD
try {
currentWorkingDirectory = System.IO.Directory.GetCurrentDirectory();
} catch(System.Exception) {
currentWorkingDirectory = ".";
}
}
var l = new SaneArrayList();
l.Add(runtime.NewText("."));
loadPath = runtime.NewList(l);
programArguments = runtime.NewList(new SaneArrayList());
IokeObject outx = runtime.Io.Mimic(null, null);
outx.Data = new IokeIO(runtime.Out);
obj.RegisterCell("out", outx);
IokeObject errx = runtime.Io.Mimic(null, null);
errx.Data = new IokeIO(runtime.Error);
obj.RegisterCell("err", errx);
IokeObject inx = runtime.Io.Mimic(null, null);
inx.Data = new IokeIO(runtime.In);
obj.RegisterCell("in", inx);
obj.RegisterCell("currentDebugger", runtime.nil);
obj.RegisterMethod(runtime.NewNativeMethod("takes one text or symbol argument and returns a boolean indicating whether the named feature is available on this runtime.",
new NativeMethod("feature?", DefaultArgumentsDefinition.builder()
.WithRequiredPositional("feature")
.Arguments,
(method, context, message, on, outer) => {
var args = new SaneArrayList();
outer.ArgumentsDefinition.GetEvaluatedArguments(context, message, on, args, new SaneDictionary<string, object>());
string name = Text.GetText(((Message)IokeObject.dataOf(runtime.asText)).SendTo(runtime.asText, context, args[0]));
if(FEATURES.Contains(name)) {
return runtime.True;
} else {
return runtime.False;
}
})));
obj.RegisterMethod(runtime.NewNativeMethod("returns the current file executing",
new NativeMethod.WithNoArguments("currentFile",
(method, context, message, on, outer) => {
outer.ArgumentsDefinition.GetEvaluatedArguments(context, message, on, new SaneArrayList(), new SaneDictionary<string, object>());
return runtime.NewText(((IokeSystem)IokeObject.dataOf(on)).currentFile[0]);
})));
obj.RegisterMethod(runtime.NewNativeMethod("returns true if running on windows, otherwise false",
new NativeMethod.WithNoArguments("windows?",
(method, context, message, on, outer) => {
outer.ArgumentsDefinition.GetEvaluatedArguments(context, message, on, new SaneArrayList(), new SaneDictionary<string, object>());
return DOSISH ? runtime.True : runtime.False;
})));
obj.RegisterMethod(runtime.NewNativeMethod("returns the current load path",
new NativeMethod.WithNoArguments("loadPath",
(method, context, message, on, outer) => {
outer.ArgumentsDefinition.GetEvaluatedArguments(context, message, on, new SaneArrayList(), new SaneDictionary<string, object>());
return ((IokeSystem)IokeObject.dataOf(on)).loadPath;
})));
obj.RegisterMethod(runtime.NewNativeMethod("returns a random number",
new NativeMethod.WithNoArguments("randomNumber",
(method, context, message, on, outer) => {
outer.ArgumentsDefinition.GetEvaluatedArguments(context, message, on, new SaneArrayList(), new SaneDictionary<string, object>());
return context.runtime.NewNumber(((IokeSystem)IokeObject.dataOf(on)).random.Next());
})));
obj.RegisterMethod(runtime.NewNativeMethod("returns the current directory that the code is executing in",
new NativeMethod.WithNoArguments("currentDirectory",
(method, context, message, on, outer) => {
outer.ArgumentsDefinition.GetEvaluatedArguments(context, message, on, new SaneArrayList(), new SaneDictionary<string, object>());
string name = Message.GetFile(message);
FileInfo f = null;
if(IsAbsoluteFileName(name)) {
f = new FileInfo(name);
} else {
f = new FileInfo(Path.Combine(context.runtime.CurrentWorkingDirectory, name));
}
if(f.Exists) {
return context.runtime.NewText(f.Directory.FullName);
}
return context.runtime.nil;
})));
obj.RegisterMethod(runtime.NewNativeMethod("forcibly exits the currently running interpreter. takes one optional argument that defaults to 1 - which is the value to return from the process, if the process is exited.",
new NativeMethod("exit", DefaultArgumentsDefinition.builder()
.WithOptionalPositional("other", "1")
.Arguments,
//.........这里部分代码省略.........
示例6: Init
public override void Init(IokeObject obj)
{
obj.Kind = "LexicalMacro";
obj.RegisterCell("activatable", obj.runtime.True);
obj.RegisterMethod(obj.runtime.NewNativeMethod("returns the name of the lecro",
new NativeMethod.WithNoArguments("name",
(method, _context, message, on, outer) => {
outer.ArgumentsDefinition.GetEvaluatedArguments(_context, message, on, new SaneArrayList(), new SaneDictionary<string, object>());
return _context.runtime.NewText(((LexicalMacro)IokeObject.dataOf(on)).name);
})));
obj.RegisterMethod(obj.runtime.NewNativeMethod("activates this lecro with the arguments given to call",
new NativeMethod("call", DefaultArgumentsDefinition.builder()
.WithRestUnevaluated("arguments")
.Arguments,
(method, _context, message, on, outer) => {
return IokeObject.As(on, _context).Activate(_context, message, _context.RealContext);
})));
obj.RegisterMethod(obj.runtime.NewNativeMethod("returns the message chain for this lecro",
new NativeMethod.WithNoArguments("message",
(method, _context, message, on, outer) => {
outer.ArgumentsDefinition.GetEvaluatedArguments(_context, message, on, new SaneArrayList(), new SaneDictionary<string, object>());
return ((AssociatedCode)IokeObject.dataOf(on)).Code;
})));
obj.RegisterMethod(obj.runtime.NewNativeMethod("returns the code for the argument definition",
new NativeMethod.WithNoArguments("argumentsCode",
(method, _context, message, on, outer) => {
outer.ArgumentsDefinition.GetEvaluatedArguments(_context, message, on, new SaneArrayList(), new SaneDictionary<string, object>());
return _context.runtime.NewText(((AssociatedCode)IokeObject.dataOf(on)).ArgumentsCode);
})));
obj.RegisterMethod(obj.runtime.NewNativeMethod("Returns a text inspection of the object",
new NativeMethod.WithNoArguments("inspect",
(method, _context, message, on, outer) => {
outer.ArgumentsDefinition.GetEvaluatedArguments(_context, message, on, new SaneArrayList(), new SaneDictionary<string, object>());
return _context.runtime.NewText(LexicalMacro.GetInspect(on));
})));
obj.RegisterMethod(obj.runtime.NewNativeMethod("Returns a brief text inspection of the object",
new NativeMethod.WithNoArguments("notice",
(method, _context, message, on, outer) => {
outer.ArgumentsDefinition.GetEvaluatedArguments(_context, message, on, new SaneArrayList(), new SaneDictionary<string, object>());
return _context.runtime.NewText(LexicalMacro.GetNotice(on));
})));
obj.RegisterMethod(obj.runtime.NewNativeMethod("returns the full code of this lecro, as a Text",
new NativeMethod.WithNoArguments("code",
(method, _context, message, on, outer) => {
outer.ArgumentsDefinition.GetEvaluatedArguments(_context, message, on, new SaneArrayList(), new SaneDictionary<string, object>());
IokeData data = IokeObject.dataOf(on);
if(data is LexicalMacro) {
return _context.runtime.NewText(((LexicalMacro)data).CodeString(on));
} else {
return _context.runtime.NewText(((AliasMethod)data).CodeString);
}
})));
obj.RegisterMethod(obj.runtime.NewNativeMethod("returns idiomatically formatted code for this lecro",
new NativeMethod.WithNoArguments("formattedCode",
(method, _context, message, on, outer) => {
outer.ArgumentsDefinition.GetEvaluatedArguments(_context, message, on, new SaneArrayList(), new SaneDictionary<string, object>());
return _context.runtime.NewText(((AssociatedCode)IokeObject.dataOf(on)).FormattedCode(method));
})));
}
示例7: Init
public static void Init(IokeObject obj)
{
Runtime runtime = obj.runtime;
obj.Kind = "DefaultBehavior";
IokeObject baseBehavior = new IokeObject(runtime, "contains behavior copied from Base");
baseBehavior.Kind = "DefaultBehavior BaseBehavior";
baseBehavior.SetCell("=", runtime.Base.body.Get("="));
baseBehavior.SetCell("==", runtime.Base.body.Get("=="));
baseBehavior.SetCell("cell", runtime.Base.body.Get("cell"));
baseBehavior.SetCell("cell?", runtime.Base.body.Get("cell?"));
baseBehavior.SetCell("cell=", runtime.Base.body.Get("cell="));
baseBehavior.SetCell("cells", runtime.Base.body.Get("cells"));
baseBehavior.SetCell("cellNames", runtime.Base.body.Get("cellNames"));
baseBehavior.SetCell("removeCell!", runtime.Base.body.Get("removeCell!"));
baseBehavior.SetCell("undefineCell!", runtime.Base.body.Get("undefineCell!"));
baseBehavior.SetCell("cellOwner?", runtime.Base.body.Get("cellOwner?"));
baseBehavior.SetCell("cellOwner", runtime.Base.body.Get("cellOwner"));
baseBehavior.SetCell("documentation", runtime.Base.body.Get("documentation"));
baseBehavior.SetCell("identity", runtime.Base.body.Get("identity"));
obj.MimicsWithoutCheck(baseBehavior);
obj.RegisterCell("BaseBehavior", baseBehavior);
IokeObject assignmentBehavior = new IokeObject(runtime, "contains behavior related to assignment");
assignmentBehavior.MimicsWithoutCheck(baseBehavior);
AssignmentBehavior.Init(assignmentBehavior);
obj.MimicsWithoutCheck(assignmentBehavior);
obj.RegisterCell("Assignment", assignmentBehavior);
IokeObject internalBehavior = new IokeObject(runtime, "contains behavior related to internal functionality");
internalBehavior.MimicsWithoutCheck(baseBehavior);
InternalBehavior.Init(internalBehavior);
obj.MimicsWithoutCheck(internalBehavior);
obj.RegisterCell("Internal", internalBehavior);
IokeObject flowControlBehavior = new IokeObject(runtime, "contains behavior related to flow control");
flowControlBehavior.MimicsWithoutCheck(baseBehavior);
FlowControlBehavior.Init(flowControlBehavior);
obj.MimicsWithoutCheck(flowControlBehavior);
obj.RegisterCell("FlowControl", flowControlBehavior);
IokeObject definitionsBehavior = new IokeObject(runtime, "contains behavior related to the definition of different concepts");
definitionsBehavior.MimicsWithoutCheck(baseBehavior);
DefinitionsBehavior.Init(definitionsBehavior);
obj.MimicsWithoutCheck(definitionsBehavior);
obj.RegisterCell("Definitions", definitionsBehavior);
IokeObject conditionsBehavior = new IokeObject(runtime, "contains behavior related to conditions");
conditionsBehavior.MimicsWithoutCheck(baseBehavior);
ConditionsBehavior.Init(conditionsBehavior);
obj.MimicsWithoutCheck(conditionsBehavior);
obj.RegisterCell("Conditions", conditionsBehavior);
IokeObject literalsBehavior = new IokeObject(runtime, "contains behavior related to literals");
literalsBehavior.MimicsWithoutCheck(baseBehavior);
LiteralsBehavior.Init(literalsBehavior);
obj.MimicsWithoutCheck(literalsBehavior);
obj.RegisterCell("Literals", literalsBehavior);
IokeObject caseBehavior = new IokeObject(runtime, "contains behavior related to the case statement");
caseBehavior.MimicsWithoutCheck(baseBehavior);
CaseBehavior.Init(caseBehavior);
obj.MimicsWithoutCheck(caseBehavior);
obj.RegisterCell("Case", caseBehavior);
IokeObject reflectionBehavior = new IokeObject(runtime, "contains behavior related to reflection");
reflectionBehavior.MimicsWithoutCheck(baseBehavior);
ReflectionBehavior.Init(reflectionBehavior);
obj.MimicsWithoutCheck(reflectionBehavior);
obj.RegisterCell("Reflection", reflectionBehavior);
IokeObject booleanBehavior = new IokeObject(runtime, "contains behavior related to boolean behavior");
booleanBehavior.MimicsWithoutCheck(baseBehavior);
booleanBehavior.Kind = "DefaultBehavior Boolean";
obj.MimicsWithoutCheck(booleanBehavior);
obj.RegisterCell("Boolean", booleanBehavior);
IokeObject aspects = new IokeObject(runtime, "contains behavior related to aspects");
aspects.MimicsWithoutCheck(baseBehavior);
aspects.Kind = "DefaultBehavior Aspects";
obj.MimicsWithoutCheck(aspects);
obj.RegisterCell("Aspects", aspects);
}
示例8: Init
public static void Init(IokeObject obj)
{
Runtime runtime = obj.runtime;
obj.Kind = "DefaultBehavior";
IokeObject baseBehavior = new IokeObject(runtime, "contains behavior copied from Base");
baseBehavior.Kind = "DefaultBehavior BaseBehavior";
baseBehavior.SetCell("=", runtime.Base.Cells["="]);
baseBehavior.SetCell("==", runtime.Base.Cells["=="]);
baseBehavior.SetCell("cell", runtime.Base.Cells["cell"]);
baseBehavior.SetCell("cell?", runtime.Base.Cells["cell?"]);
baseBehavior.SetCell("cell=", runtime.Base.Cells["cell="]);
baseBehavior.SetCell("cells", runtime.Base.Cells["cells"]);
baseBehavior.SetCell("cellNames", runtime.Base.Cells["cellNames"]);
baseBehavior.SetCell("removeCell!", runtime.Base.Cells["removeCell!"]);
baseBehavior.SetCell("undefineCell!", runtime.Base.Cells["undefineCell!"]);
baseBehavior.SetCell("cellOwner?", runtime.Base.Cells["cellOwner?"]);
baseBehavior.SetCell("cellOwner", runtime.Base.Cells["cellOwner"]);
baseBehavior.SetCell("documentation", runtime.Base.Cells["documentation"]);
baseBehavior.SetCell("identity", runtime.Base.Cells["identity"]);
obj.MimicsWithoutCheck(baseBehavior);
obj.RegisterCell("BaseBehavior", baseBehavior);
IokeObject assignmentBehavior = new IokeObject(runtime, "contains behavior related to assignment");
assignmentBehavior.MimicsWithoutCheck(baseBehavior);
AssignmentBehavior.Init(assignmentBehavior);
obj.MimicsWithoutCheck(assignmentBehavior);
obj.RegisterCell("Assignment", assignmentBehavior);
IokeObject internalBehavior = new IokeObject(runtime, "contains behavior related to internal functionality");
internalBehavior.MimicsWithoutCheck(baseBehavior);
InternalBehavior.Init(internalBehavior);
obj.MimicsWithoutCheck(internalBehavior);
obj.RegisterCell("Internal", internalBehavior);
IokeObject flowControlBehavior = new IokeObject(runtime, "contains behavior related to flow control");
flowControlBehavior.MimicsWithoutCheck(baseBehavior);
FlowControlBehavior.Init(flowControlBehavior);
obj.MimicsWithoutCheck(flowControlBehavior);
obj.RegisterCell("FlowControl", flowControlBehavior);
IokeObject definitionsBehavior = new IokeObject(runtime, "contains behavior related to the definition of different concepts");
definitionsBehavior.MimicsWithoutCheck(baseBehavior);
DefinitionsBehavior.Init(definitionsBehavior);
obj.MimicsWithoutCheck(definitionsBehavior);
obj.RegisterCell("Definitions", definitionsBehavior);
IokeObject conditionsBehavior = new IokeObject(runtime, "contains behavior related to conditions");
conditionsBehavior.MimicsWithoutCheck(baseBehavior);
ConditionsBehavior.Init(conditionsBehavior);
obj.MimicsWithoutCheck(conditionsBehavior);
obj.RegisterCell("Conditions", conditionsBehavior);
IokeObject literalsBehavior = new IokeObject(runtime, "contains behavior related to literals");
literalsBehavior.MimicsWithoutCheck(baseBehavior);
LiteralsBehavior.Init(literalsBehavior);
obj.MimicsWithoutCheck(literalsBehavior);
obj.RegisterCell("Literals", literalsBehavior);
IokeObject caseBehavior = new IokeObject(runtime, "contains behavior related to the case statement");
caseBehavior.MimicsWithoutCheck(baseBehavior);
CaseBehavior.Init(caseBehavior);
obj.MimicsWithoutCheck(caseBehavior);
obj.RegisterCell("Case", caseBehavior);
IokeObject reflectionBehavior = new IokeObject(runtime, "contains behavior related to reflection");
reflectionBehavior.MimicsWithoutCheck(baseBehavior);
ReflectionBehavior.Init(reflectionBehavior);
obj.MimicsWithoutCheck(reflectionBehavior);
obj.RegisterCell("Reflection", reflectionBehavior);
IokeObject booleanBehavior = new IokeObject(runtime, "contains behavior related to boolean behavior");
booleanBehavior.MimicsWithoutCheck(baseBehavior);
booleanBehavior.Kind = "DefaultBehavior Boolean";
obj.MimicsWithoutCheck(booleanBehavior);
obj.RegisterCell("Boolean", booleanBehavior);
IokeObject aspects = new IokeObject(runtime, "contains behavior related to aspects");
aspects.MimicsWithoutCheck(baseBehavior);
aspects.Kind = "DefaultBehavior Aspects";
obj.MimicsWithoutCheck(aspects);
obj.RegisterCell("Aspects", aspects);
obj.RegisterMethod(runtime.NewNativeMethod("takes one or more evaluated string argument. will import the files corresponding to each of the strings named based on the Ioke loading behavior that can be found in the documentation for the loadBehavior cell on System.",
new NativeMethod("use", DefaultArgumentsDefinition.builder()
.WithOptionalPositional("module", "false")
.Arguments,
(method, context, message, on, outer) => {
IList args = new SaneArrayList();
outer.ArgumentsDefinition.GetEvaluatedArguments(context, message, on, args, new SaneDictionary<string, object>());
if(args.Count == 0) {
return method;
}
string name = Text.GetText(((Message)IokeObject.dataOf(runtime.asText)).SendTo(runtime.asText, context, args[0]));
if(((IokeSystem)IokeObject.dataOf(runtime.System)).Use(IokeObject.As(on, context), context, message, name)) {
return runtime.True;
} else {
return runtime.False;
}
//.........这里部分代码省略.........
示例9: Init
public static void Init(IokeObject iokeGround, IokeObject ground)
{
Runtime runtime = ground.runtime;
iokeGround.Kind = "IokeGround";
ground.Kind = "Ground";
iokeGround.RegisterCell("Base", runtime.Base);
iokeGround.RegisterCell("DefaultBehavior", runtime.DefaultBehavior);
iokeGround.RegisterCell("IokeGround", runtime.IokeGround);
iokeGround.RegisterCell("Ground", runtime.Ground);
iokeGround.RegisterCell("Origin", runtime.Origin);
iokeGround.RegisterCell("System", runtime.System);
iokeGround.RegisterCell("Runtime", runtime._Runtime);
iokeGround.RegisterCell("Text", runtime.Text);
iokeGround.RegisterCell("Symbol", runtime.Symbol);
iokeGround.RegisterCell("Number", runtime.Number);
iokeGround.RegisterCell("nil", runtime.nil);
iokeGround.RegisterCell("true", runtime.True);
iokeGround.RegisterCell("false", runtime.False);
iokeGround.RegisterCell("Arity", runtime.Arity);
iokeGround.RegisterCell("Method", runtime.Method);
iokeGround.RegisterCell("DefaultMethod", runtime.DefaultMethod);
iokeGround.RegisterCell("NativeMethod", runtime.NativeMethod);
iokeGround.RegisterCell("LexicalBlock", runtime.LexicalBlock);
iokeGround.RegisterCell("DefaultMacro", runtime.DefaultMacro);
iokeGround.RegisterCell("LexicalMacro", runtime.LexicalMacro);
iokeGround.RegisterCell("DefaultSyntax", runtime.DefaultSyntax);
iokeGround.RegisterCell("Mixins", runtime.Mixins);
iokeGround.RegisterCell("Restart", runtime.Restart);
iokeGround.RegisterCell("List", runtime.List);
iokeGround.RegisterCell("Dict", runtime.Dict);
iokeGround.RegisterCell("Set", runtime.Set);
iokeGround.RegisterCell("Range", runtime.Range);
iokeGround.RegisterCell("Pair", runtime.Pair);
iokeGround.RegisterCell("DateTime", runtime.DateTime);
iokeGround.RegisterCell("Message", runtime.Message);
iokeGround.RegisterCell("Call", runtime.Call);
iokeGround.RegisterCell("Condition", runtime.Condition);
iokeGround.RegisterCell("Rescue", runtime.Rescue);
iokeGround.RegisterCell("Handler", runtime.Handler);
iokeGround.RegisterCell("IO", runtime.Io);
iokeGround.RegisterCell("FileSystem", runtime.FileSystem);
iokeGround.RegisterCell("Regexp", runtime.Regexp);
iokeGround.RegisterCell("Sequence", runtime.Sequence);
iokeGround.RegisterMethod(runtime.NewNativeMethod("will return a text representation of the current stack trace",
new NativeMethod.WithNoArguments("stackTraceAsText",
(method, context, message, on, outer) => {
outer.ArgumentsDefinition.GetEvaluatedArguments(context, message, on, new SaneArrayList(), new SaneDictionary<string, object>());
return context.runtime.NewText("");
})));
}