本文整理汇总了C#中Stack.PushRange方法的典型用法代码示例。如果您正苦于以下问题:C# Stack.PushRange方法的具体用法?C# Stack.PushRange怎么用?C# Stack.PushRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stack
的用法示例。
在下文中一共展示了Stack.PushRange方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Runner
/// <summary>
/// 文字列を解釈し、実行する
/// </summary>
/// <param name="input">入力文字列</param>
/// <param name="addingFuncStack">追加プリミティブ関数</param>
/// <param name="rule">文字列からトークンに変換するためのルール</param>
public Runner(string input, BaseRule rule, Stack<GrassFunc> addingFuncStack = null)
{
Input = input;
_Rule = rule;
_FuncStack = new Stack<GrassFunc>();
_FuncStack.PushRange(_PrimitiveFuntions);
if (addingFuncStack != null && addingFuncStack.Count > 0)
{
_FuncStack.PushRange(addingFuncStack);
}
}
示例2: ParseStatements
public static Statement[] ParseStatements(GMFileContent content, RefData rdata, CodeInfo code, AnyInstruction*[] instr = null, Stack<Expression> stack = null, List<Expression> dupTars = null)
{
//! here be dragons
stack = stack ?? new Stack<Expression>();
dupTars = dupTars ?? new List <Expression>();
instr = instr ?? code.Instructions;
if (instr.Length == 0)
return EmptyStmtArray;
var stmts = new List<Statement>();
var firstI = code.Instructions[0];
//TODO: use locals
Func<Expression> Pop = () => stack.Count == 0 ? PopExpr : stack.Pop ();
//Func<Expression> Peek = () => stack.Count == 0 ? PopExpr : stack.Peek();
Func<int, IEnumerable<Expression>> PopMany = i =>
{
var ret = new List<Expression>();
for (int j = 0; j < i; j++)
ret.Add(Pop());
return ret;
};
#region Action FlushStack = () => { };
Action FlushStack = () =>
{
var readd = new Stack<Expression>();
//? not sure if this is a good idea (random 'push'es in the wild) (see TODO)
stmts.AddRange(stack.PopAll().Where(e =>
{
if (dupTars.Contains(e))
{
readd.Push(e);
return false;
}
return !(e is PopExpression); // 'push pop' is obviously stupid to emit
}).Reverse().Select(e =>
e is UnaryOperatorExpression &&
((UnaryOperatorExpression)e).Operator == UnaryOperator.Duplicate
? (Statement)new DupStatement() : new PushStatement { Expr = e }));
stack.PushRange(readd);
};
#endregion
Action<Statement> AddStmt = s =>
{
FlushStack();
stmts.Add(s);
};
Func<VariableType, Expression[]> TryGetIndices = vt =>
{
Expression index = null;
var dimentions = 0;
if (vt == VariableType.Array)
{
index = Pop();
var arrInd = Pop();
if ((arrInd is LiteralExpression) && ((LiteralExpression)arrInd).Value is short)
{
var s = (short)((LiteralExpression)arrInd).Value;
switch (s)
{
case -1:
dimentions = 2;
break;
case -5:
dimentions = 1;
break;
}
}
if (dimentions == 0)
{
stack.Push(arrInd);
stack.Push(index);
index = null;
}
}
if (index == null)
return null;
// analyse index for specified dimention
switch (dimentions)
{
case 2:
if (index is BinaryOperatorExpression && ((BinaryOperatorExpression)index).Operator == BinaryOperator.Addition)
//.........这里部分代码省略.........