本文整理汇总了C#中System.Machine.GetVariableValue方法的典型用法代码示例。如果您正苦于以下问题:C# Machine.GetVariableValue方法的具体用法?C# Machine.GetVariableValue怎么用?C# Machine.GetVariableValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Machine
的用法示例。
在下文中一共展示了Machine.GetVariableValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Evaluate
public object Evaluate(Machine machine, ValueEnvironment environment)
{
string nsname = null;
if (string.IsNullOrEmpty(this.symbol.Namespace))
{
// TODO this lookup should be for special forms
if (machine.Environment.IsDefined(this.symbol.Name))
return machine.Environment.GetValue(this.symbol.Name);
// Test if it is a Type
// TODO import treatment
if (this.symbol.Name.IndexOf('.') > 0)
{
Type type = Utilities.GetType(this.symbol.Name);
if (type != null)
return type;
}
if (environment.IsDefined(this.symbol.Name))
return environment.GetValue(this.symbol.Name);
nsname = (string)environment.GetValue(Machine.CurrentNamespaceKey);
}
else
nsname = this.symbol.Namespace;
return machine.GetVariableValue(nsname, this.symbol.Name);
}
示例2: Evaluate
public object Evaluate(Machine machine, ValueEnvironment environment)
{
return machine.GetVariableValue(this.variable);
}
示例3: SetMacro
public void SetMacro(Machine machine)
{
object obj = machine.GetVariableValue(this);
if (obj is DefinedFunction)
{
obj = ((DefinedFunction)obj).ToMacro();
machine.SetVariableValue(this, obj);
}
else if (obj is DefinedMultiFunction)
{
obj = ((DefinedMultiFunction)obj).ToMacro();
machine.SetVariableValue(this, obj);
}
else if (!(obj is DefinedMacro))
throw new InvalidOperationException();
if (this.metadata != null)
this.metadata = this.metadata.Associate(Keyword.Create("macro"), true);
else
{
IDictionary dict = new Hashtable();
dict[Keyword.Create("macro")] = true;
this.metadata = new DictionaryObject(dict);
}
}
示例4: SetMacroOnDefinedMultiFunction
public void SetMacroOnDefinedMultiFunction()
{
Machine machine = new Machine();
machine.CreateNamespace("ns");
FnStarPrimitive fnprim = new FnStarPrimitive();
Parser parser = new Parser("([x] (+ x 1)) ([x y] (+ x y 1))");
object[] parameters = new object[2];
parameters[0] = parser.ParseForm();
parameters[1] = parser.ParseForm();
object result = fnprim.Apply(machine, machine.Environment, parameters);
DefinedMultiFunction multifn = (DefinedMultiFunction)result;
Variable variable = Variable.Intern(machine, "ns/func");
machine.SetVariableValue(variable, multifn);
variable.SetMacro(machine);
object mresult = machine.GetVariableValue(variable);
Assert.IsNotNull(mresult);
Assert.IsInstanceOfType(mresult, typeof(DefinedMultiMacro));
}
示例5: SetMacroOnDefinedFunction
public void SetMacroOnDefinedFunction()
{
Machine machine = new Machine();
machine.CreateNamespace("ns");
Variable variable = Variable.Intern(machine, "ns/func");
Parser parser = new Parser("[x y] (list x y) 1 2");
object argumentNames = parser.ParseForm();
object body = parser.ParseForm();
DefinedFunction func = new DefinedFunction("simple-list", (ICollection)argumentNames, Utilities.ToExpression(body));
machine.SetVariableValue(variable, func);
variable.SetMacro(machine);
object result = machine.GetVariableValue(variable);
Assert.IsNotNull(result);
Assert.IsInstanceOfType(result, typeof(DefinedMacro));
}