本文整理汇总了C#中ICommandContext.AddVariable方法的典型用法代码示例。如果您正苦于以下问题:C# ICommandContext.AddVariable方法的具体用法?C# ICommandContext.AddVariable怎么用?C# ICommandContext.AddVariable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICommandContext
的用法示例。
在下文中一共展示了ICommandContext.AddVariable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Do
public override void Do(ICommandContext context)
{
/*
if (dimension == 1)
context.AddVariable(name, new Types.Array(type, context.RunStack.Pop().ToInt32()));
else
throw new Psimulex.Core.Exceptions.PsimulexException("More than one dimensional array is not implemented yet!");
*/
if (dimension == 1)
context.AddVariable(name, new Types.Array(type, 0));
else
throw new Psimulex.Core.Exceptions.PsimulexException("More than one dimensional array is not implemented yet!");
}
示例2: Do
public override void Do(ICommandContext context)
{
BaseType value = context.RunStack.Pop();
using (new Memory.AutoCleanup())
{
if (IsReference)
value = value.ToReference();
else
value = value.Dereference();
value = ValueFactory.Convert(value.Clone(), type);
}
context.AddVariable(name, value.Clone());
}
示例3: CallByName
private void CallByName(ICommandContext context)
{
// It has to look up the availabe function names
Function function = null;
if (parametersCount >= 0)
{
function = context.FunctionLookup.GetFunctionByNameAndParameterCount(functionName, parametersCount);
if (function == null)
{
throw new PsimulexCoreException(string.Format("Call to an undefined function: {0} with {1} parameters.", functionName, parametersCount));
}
}
else
{
function = context.FunctionLookup.GetFunctionByName(functionName);
if (function == null)
{
throw new PsimulexCoreException("Call to an undefined function: " + functionName);
}
}
if (function.IsUserDefined)
{
UserDefinedFunction udf = function as UserDefinedFunction;
Stack<BaseType> parameters = new Stack<BaseType>();
foreach (var param in udf.Parameters)
{
var value = context.RunStack.Pop();
if (param.IsReference)
{
value = value.ToReference();
}
parameters.Push(value.Clone());
}
parameters = parameters.Reverse();
context.PushState();
foreach (var param in udf.Parameters)
{
context.AddVariable(param.Name, parameters[udf.Parameters.IndexOf(param)]);
}
// Just jump to its entry point.
context.PC = udf.EntryPoint;
}
else
{
// Pack each parameter, and Invoke.
Stack<BaseType> poppedValues = new Stack<BaseType>();
var parameters = new List<BaseType>(function.ParameterCount);
for (int i = 0; i < function.ParameterCount; ++i)
{
var param = context.RunStack.Pop();
if (function.Parameters[i].IsReference)
{
param = param.ToReference();
}
poppedValues.Push(param.Clone());
}
parameters.AddRange(poppedValues.AsEnumerable());
// Make the call
var returnValue = context.System.SystemCall(function, parameters);
// Push the returned value
if (function.HasReturnValue)
{
context.RunStack.Push(returnValue);
}
foreach (var param in parameters)
{
param.Delete();
}
}
}
示例4: Do
public override void Do(ICommandContext context)
{
context.AddVariable(name, ValueFactory.CreateValue(type));
}