本文整理汇总了C#中Ioke.Lang.IokeObject.MimicsWithoutCheck方法的典型用法代码示例。如果您正苦于以下问题:C# IokeObject.MimicsWithoutCheck方法的具体用法?C# IokeObject.MimicsWithoutCheck怎么用?C# IokeObject.MimicsWithoutCheck使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ioke.Lang.IokeObject
的用法示例。
在下文中一共展示了IokeObject.MimicsWithoutCheck方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public override void Init(IokeObject obj)
{
obj.Kind = "Sequence Iterator";
obj.MimicsWithoutCheck(obj.runtime.Sequence);
obj.RegisterMethod(obj.runtime.NewNativeMethod("returns the next object from this sequence if it exists. the behavior otherwise is undefined",
new TypeCheckingNativeMethod.WithNoArguments("next", obj,
(method, on, args, keywords, context, message) => {
return ((Iterator2Sequence)IokeObject.dataOf(on)).iter.next();
})));
obj.RegisterMethod(obj.runtime.NewNativeMethod("returns true if there is another object in this sequence.",
new TypeCheckingNativeMethod.WithNoArguments("next?", obj,
(method, on, args, keywords, context, message) => {
return ((Iterator2Sequence)IokeObject.dataOf(on)).iter.hasNext() ? method.runtime.True : method.runtime.False;
})));
}
示例2: Init
public static void Init(IokeObject bm)
{
Runtime runtime = bm.runtime;
bm.Kind = "Benchmark";
runtime.Ground.SetCell("Benchmark", bm);
bm.MimicsWithoutCheck(runtime.Origin);
bm.RegisterMethod(runtime.NewNativeMethod("expects two optional numbers, x (default 10) and y (default 1), and a block of code to run, and will run benchmark this block x times, while looping y times in each benchmark. after each loop will print the timings for this loop",
new NativeMethod("report", DefaultArgumentsDefinition.builder()
.WithOptionalPositional("repetitions", "10")
.WithOptionalPositional("loops", "1")
.WithRequiredPositionalUnevaluated("code")
.Arguments,
(method, context, message, on, outer) => {
outer.ArgumentsDefinition.CheckArgumentCount(context, message, on);
int count = message.Arguments.Count;
int bmRounds = 10;
long iterations = 1;
int index = 0;
if(count > 1) {
bmRounds = ((Number)IokeObject.dataOf(IokeObject.ConvertToNumber(((Message)IokeObject.dataOf(message)).GetEvaluatedArgument(message, index, context), message, context))).AsNativeInteger();
index++;
if(count > 2) {
iterations = ((Number)IokeObject.dataOf(IokeObject.ConvertToNumber(((Message)IokeObject.dataOf(message)).GetEvaluatedArgument(message, index, context), message, context))).AsNativeLong();
index++;
}
}
for(int i=0;i<bmRounds;i++) {
long before = System.DateTime.Now.Ticks;
for(int j=0;j<iterations;j++) {
((Message)IokeObject.dataOf(message)).GetEvaluatedArgument(message, index, context);
}
long after = System.DateTime.Now.Ticks;
long time = after-before;
long secs = time/10000000;
long rest = time%10000000;
string theCode = Message.ThisCode(((IokeObject)message.Arguments[index]));
((Message)IokeObject.dataOf(context.runtime.printlnMessage)).SendTo(context.runtime.printlnMessage, context, ((Message)IokeObject.dataOf(context.runtime.outMessage)).SendTo(context.runtime.outMessage, context, context.runtime.System), context.runtime.NewText(string.Format("{0,-32} {1:d6}.{2:d9}", theCode, secs, rest)));
}
return context.runtime.nil;
})));
}
示例3: 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);
//.........这里部分代码省略.........
示例4: Init
public override void Init(IokeObject obj)
{
Runtime runtime = obj.runtime;
IokeObject number = obj;
obj.Kind = "Number";
obj.Mimics(IokeObject.As(runtime.Mixins.GetCell(null, null, "Comparing"), obj), runtime.nul, runtime.nul);
IokeObject real = new IokeObject(runtime, "A real number can be either a rational number or a decimal number", new Number());
real.MimicsWithoutCheck(number);
real.Kind = "Number Real";
number.RegisterCell("Real", real);
IokeObject rational = new IokeObject(runtime, "A rational number is either an integer or a ratio", new Number());
rational.MimicsWithoutCheck(real);
rational.Kind = "Number Rational";
number.RegisterCell("Rational", rational);
IokeObject integer = new IokeObject(runtime, "An integral number", new Number());
integer.MimicsWithoutCheck(rational);
integer.Kind = "Number Integer";
number.RegisterCell("Integer", integer);
runtime.Integer = integer;
IokeObject ratio = new IokeObject(runtime, "A ratio of two integral numbers", new Number());
ratio.MimicsWithoutCheck(rational);
ratio.Kind = "Number Ratio";
number.RegisterCell("Ratio", ratio);
runtime.Ratio = ratio;
IokeObject _decimal = new IokeObject(runtime, "An exact, unlimited representation of a decimal number", new Decimal(BigDecimal.ZERO));
_decimal.MimicsWithoutCheck(real);
_decimal.Init();
number.RegisterCell("Decimal", _decimal);
IokeObject infinity = new IokeObject(runtime, "A value representing infinity", new Number(RatNum.infinity(1)));
infinity.MimicsWithoutCheck(ratio);
infinity.Kind = "Number Infinity";
number.RegisterCell("Infinity", infinity);
runtime.Infinity = infinity;
IokeObject infinity2 = new IokeObject(runtime, "A value representing infinity", new Number(RatNum.infinity(1)));
infinity2.MimicsWithoutCheck(ratio);
infinity2.Kind = "Number \u221E";
number.RegisterCell("\u221E", infinity2);
number.RegisterMethod(runtime.NewNativeMethod("returns a hash for the number",
new NativeMethod.WithNoArguments("hash", (method, context, message, on, outer) => {
outer.ArgumentsDefinition.CheckArgumentCount(context, message, on);
return context.runtime.NewNumber(Number.GetValue(on).GetHashCode());
})));
number.RegisterMethod(runtime.NewNativeMethod("returns the square root of the receiver. this should return the same result as calling ** with 0.5",
new NativeMethod.WithNoArguments("sqrt", (method, context, message, on, outer) => {
outer.ArgumentsDefinition.CheckArgumentCount(context, message, on);
RatNum value = Number.GetValue(on);
if(value is IntFraction) {
IntNum num = value.numerator();
IntNum den = value.denominator();
BigDecimal nums = new BigSquareRoot().Get(num.AsBigDecimal());
BigDecimal dens = new BigSquareRoot().Get(den.AsBigDecimal());
try {
num = IntNum.valueOf(nums.toBigIntegerExact().ToString());
den = IntNum.valueOf(dens.toBigIntegerExact().ToString());
return context.runtime.NewNumber(new IntFraction(num, den));
} catch(ArithmeticException e) {
// Ignore and fall through
}
}
if(RatNum.compare(value, IntNum.zero()) < 1) {
IokeObject condition = IokeObject.As(IokeObject.GetCellChain(context.runtime.Condition,
message,
context,
"Error",
"Arithmetic"), context).Mimic(message, context);
condition.SetCell("message", message);
condition.SetCell("context", context);
condition.SetCell("receiver", on);
context.runtime.ErrorCondition(condition);
}
return context.runtime.NewDecimal(new BigSquareRoot().Get(value.AsBigDecimal()));
})));
number.RegisterMethod(runtime.NewNativeMethod("returns true if the left hand side number is equal to the right hand side number.",
new TypeCheckingNativeMethod("==", TypeCheckingArgumentsDefinition.builder()
.ReceiverMustMimic(runtime.Number)
.WithRequiredPositional("other")
.Arguments,
(method, on, args, keywords, context, message) => {
Number d = (Number)IokeObject.dataOf(on);
object other = args[0];
return ((other is IokeObject) &&
(IokeObject.dataOf(other) is Number)
&& (((d.kind || ((Number)IokeObject.dataOf(other)).kind) ? on == other :
d.value.Equals(((Number)IokeObject.dataOf(other)).value)))) ? context.runtime.True : context.runtime.False;
})));
//.........这里部分代码省略.........
示例5: 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;
//.........这里部分代码省略.........
示例6: Init
public static void Init(Runtime runtime)
{
IokeObject obj = new IokeObject(runtime, "A hook allow you to observe what happens to a specific object. All hooks have Hook in their mimic chain.");
obj.Kind = "Hook";
obj.MimicsWithoutCheck(runtime.Origin);
runtime.IokeGround.RegisterCell("Hook", obj);
obj.RegisterMethod(runtime.NewNativeMethod("Takes one or more arguments to hook into and returns a new Hook connected to them.",
new TypeCheckingNativeMethod("into", TypeCheckingArgumentsDefinition.builder()
.ReceiverMustMimic(obj)
.WithRequiredPositional("firstConnected")
.WithRest("restConnected")
.Arguments,
(method, on, args, keywords, context, message) => {
IokeObject hook = obj.AllocateCopy(context, message);
hook.MimicsWithoutCheck(obj);
IList objs = new SaneArrayList();
foreach(object o in args) {
objs.Add(IokeObject.As(o, context));
}
Hook h = new Hook(objs);
hook.Data = h;
h.Rewire(hook);
return hook;
})));
obj.RegisterMethod(runtime.NewNativeMethod("returns the objects this hook is connected to",
new TypeCheckingNativeMethod.WithNoArguments("connectedObjects", obj,
(method, on, args, keywords, context, message) => {
Hook h = (Hook)IokeObject.dataOf(on);
IList l = new SaneArrayList(h.connected);
return method.runtime.NewList(l);
})));
obj.RegisterMethod(runtime.NewNativeMethod("Takes one argument and will add that to the list of connected objects",
new TypeCheckingNativeMethod("hook!", TypeCheckingArgumentsDefinition.builder()
.ReceiverMustMimic(obj)
.WithRequiredPositional("objectToHookInto")
.Arguments,
(method, on, args, keywords, context, message) => {
Hook h = (Hook)IokeObject.dataOf(on);
h.connected.Add(IokeObject.As(args[0], context));
h.Rewire(IokeObject.As(on, context));
return on;
})));
}
示例7: GetSymbol
public IokeObject GetSymbol(string name)
{
lock(symbolTable) {
if(symbolTable.ContainsKey(name))
return symbolTable[name];
IokeObject obj = new IokeObject(this, null, new Symbol(name));
obj.MimicsWithoutCheck(this.Symbol);
symbolTable[name] = obj;
return obj;
}
}
示例8: Init
public static void Init(Runtime runtime)
{
IokeObject obj = new IokeObject(runtime, "Allows access to the internals of any object without actually using methods on that object");
obj.Kind = "Reflector";
obj.MimicsWithoutCheck(runtime.Origin);
runtime.IokeGround.RegisterCell("Reflector", obj);
obj.RegisterMethod(obj.runtime.NewNativeMethod("returns the documentation text of the object given as argument. anything can have a documentation text - this text will initially be nil.",
new TypeCheckingNativeMethod("other:documentation", TypeCheckingArgumentsDefinition.builder()
.WithRequiredPositional("other")
.Arguments,
(method, on, args, keywords, context, message) => {
return Base.Documentation(context, message, args[0]);
})));
obj.RegisterMethod(obj.runtime.NewNativeMethod("sets the documentation string for a specific object.",
new TypeCheckingNativeMethod("other:documentation=", TypeCheckingArgumentsDefinition.builder()
.WithRequiredPositional("other")
.WithRequiredPositional("text").WhichMustMimic(obj.runtime.Text).OrBeNil()
.Arguments,
(method, on, args, keywords, context, message) => {
return Base.SetDocumentation(context, message, args[0], args[1]);
})));
obj.RegisterMethod(obj.runtime.NewNativeMethod("will return a new derivation of the receiving object. Might throw exceptions if the object is an oddball object.",
new TypeCheckingNativeMethod("other:mimic", TypeCheckingArgumentsDefinition.builder()
.WithRequiredPositional("other")
.Arguments,
(method, on, args, keywords, context, message) => {
return IokeObject.As(args[0], context).Mimic(message, context);
})));
obj.RegisterMethod(obj.runtime.NewNativeMethod("expects one evaluated text or symbol argument that names the cell to set, sets this cell to the result of evaluating the second argument, and returns the value set.",
new NativeMethod("other:cell=",
DefaultArgumentsDefinition
.builder()
.WithRequiredPositional("other")
.WithRequiredPositional("cellName")
.WithRequiredPositional("value")
.Arguments,
(method, context, message, on, outer) => {
var args = new SaneArrayList();
outer.ArgumentsDefinition.GetEvaluatedArguments(context, message, on, args, new SaneDictionary<string, object>());
return Base.AssignCell(context, message, args[0], args[1], args[2]);
})));
obj.RegisterMethod(obj.runtime.NewNativeMethod("expects one evaluated text or symbol argument and returns the cell that matches that name, without activating even if it's activatable.",
new NativeMethod("other:cell", DefaultArgumentsDefinition.builder()
.WithRequiredPositional("other")
.WithRequiredPositional("cellName")
.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(context.runtime.asText)).SendTo(context.runtime.asText, context, args[1]));
return IokeObject.GetCell(args[0], message, context, name);
})));
obj.RegisterMethod(obj.runtime.NewNativeMethod("expects one evaluated text or symbol argument and returns a boolean indicating whether such a cell is reachable from this point.",
new NativeMethod("other:cell?", DefaultArgumentsDefinition.builder()
.WithRequiredPositional("other")
.WithRequiredPositional("cellName")
.Arguments,
(method, context, message, on, outer) => {
IList args = new SaneArrayList();
outer.ArgumentsDefinition.GetEvaluatedArguments(context, message, on, args, new SaneDictionary<string, object>());
string name = Text.GetText(((Message)IokeObject.dataOf(context.runtime.asText)).SendTo(context.runtime.asText, context, args[1]));
return IokeObject.FindCell(args[0], message, context, name) != context.runtime.nul ? context.runtime.True : context.runtime.False;
})));
obj.RegisterMethod(obj.runtime.NewNativeMethod("expects one evaluated text or symbol argument and returns a boolean indicating whether this cell is owned by the receiver or not. the assumption is that the cell should exist. if it doesn't exist, a NoSuchCell condition will be signalled.",
new NativeMethod("other:cellOwner?", DefaultArgumentsDefinition.builder()
.WithRequiredPositional("other")
.WithRequiredPositional("cellName")
.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(context.runtime.asText)).SendTo(context.runtime.asText, context, args[1]));
return (IokeObject.FindPlace(args[0], message, context, name) == args[0]) ? context.runtime.True : context.runtime.False;
})));
obj.RegisterMethod(obj.runtime.NewNativeMethod("expects one evaluated text or symbol argument and returns the closest object that defines such a cell. if it doesn't exist, a NoSuchCell condition will be signalled.",
new NativeMethod("other:cellOwner", DefaultArgumentsDefinition.builder()
.WithRequiredPositional("other")
.WithRequiredPositional("cellName")
.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(context.runtime.asText)).SendTo(context.runtime.asText, context, args[1]));
object result = IokeObject.FindPlace(args[0], message, context, name);
if(result == context.runtime.nul) {
return context.runtime.nil;
}
return result;
})));
obj.RegisterMethod(obj.runtime.NewNativeMethod("expects one evaluated text or symbol argument and removes that cell from the current receiver. if the current receiver has no such object, signals a condition. note that if another cell with that name is available in the mimic chain, it will still be accessible after calling this method. the method returns the receiver.",
//.........这里部分代码省略.........
示例9: 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);
}
示例10: 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;
}
//.........这里部分代码省略.........