本文整理汇总了C#中Mono.CSharp.Block类的典型用法代码示例。如果您正苦于以下问题:C# Block类的具体用法?C# Block怎么用?C# Block使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Block类属于Mono.CSharp命名空间,在下文中一共展示了Block类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CreateBranching
public static FlowBranching CreateBranching (FlowBranching parent, BranchingType type, Block block, Location loc)
{
switch (type) {
case BranchingType.Exception:
case BranchingType.Labeled:
case BranchingType.Toplevel:
case BranchingType.TryCatch:
throw new InvalidOperationException ();
case BranchingType.Switch:
return new FlowBranchingBreakable (parent, type, SiblingType.SwitchSection, block, loc);
case BranchingType.Block:
return new FlowBranchingBlock (parent, type, SiblingType.Block, block, loc);
case BranchingType.Loop:
return new FlowBranchingBreakable (parent, type, SiblingType.Conditional, block, loc);
case BranchingType.Embedded:
return new FlowBranchingContinuable (parent, type, SiblingType.Conditional, block, loc);
default:
return new FlowBranchingBlock (parent, type, SiblingType.Conditional, block, loc);
}
}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:25,代码来源:flowanalysis.cs
示例2: FlowBranching
// <summary>
// Creates a new flow branching which is contained in `parent'.
// You should only pass non-null for the `block' argument if this block
// introduces any new variables - in this case, we need to create a new
// usage vector with a different size than our parent's one.
// </summary>
protected FlowBranching(FlowBranching parent, BranchingType type, SiblingType stype,
Block block, Location loc)
{
Parent = parent;
Block = block;
Location = loc;
Type = type;
id = ++next_id;
UsageVector vector;
if (Block != null) {
UsageVector parent_vector = parent != null ? parent.CurrentUsageVector : null;
vector = new UsageVector (stype, parent_vector, Block, loc, Block.AssignableSlots);
} else {
vector = new UsageVector (stype, Parent.CurrentUsageVector, null, loc);
}
AddSibling (vector);
}
开发者ID:speier,项目名称:shake,代码行数:25,代码来源:flowanalysis.cs
示例3: RemapBlockCopy
///
/// Remaps block to cloned copy if one exists.
///
public Block RemapBlockCopy (Block from)
{
Block mapped_to;
if (!block_map.TryGetValue (from, out mapped_to))
return from;
return mapped_to;
}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:11,代码来源:context.cs
示例4: AddBlockMap
public void AddBlockMap (Block from, Block to)
{
block_map.Add (from, to);
}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:4,代码来源:context.cs
示例5: AddBlockChildren
void AddBlockChildren (BlockStatement result, Block blockStatement, List<LocalInfo> localVariables, ref int curLocal)
{
foreach (Statement stmt in blockStatement.Statements) {
if (stmt == null)
continue;
if (curLocal < localVariables.Count && IsLower (localVariables[curLocal].Location, stmt.loc)) {
result.AddChild (CreateVariableDeclaration (localVariables[curLocal]), AbstractCSharpNode.Roles.Statement);
curLocal++;
}
if (stmt is Block && !(stmt is ToplevelBlock || stmt is ExplicitBlock)) {
AddBlockChildren (result, (Block)stmt, localVariables, ref curLocal);
} else {
result.AddChild ((INode)stmt.Accept (this), AbstractCSharpNode.Roles.Statement);
}
}
}
开发者ID:pgoron,项目名称:monodevelop,代码行数:16,代码来源:CSharpParser.cs
示例6: Visit
public override object Visit (Block blockStatement)
{
if (blockStatement.IsGenerated) {
if (blockStatement.Statements.First () is Using)
return CreateUsingStatement (blockStatement);
return blockStatement.Statements.Last ().Accept (this);
}
var result = new BlockStatement ();
result.AddChild (new CSharpTokenNode (Convert (blockStatement.StartLocation), 1), AbstractCSharpNode.Roles.LBrace);
int curLocal = 0;
List<LocalInfo> localVariables = new List<LocalInfo> (blockStatement.Variables.Values);
AddBlockChildren (result, blockStatement, localVariables, ref curLocal);
while (curLocal < localVariables.Count) {
result.AddChild (CreateVariableDeclaration (localVariables[curLocal]), AbstractCSharpNode.Roles.Statement);
curLocal++;
}
result.AddChild (new CSharpTokenNode (Convert (blockStatement.EndLocation), 1), AbstractCSharpNode.Roles.RBrace);
return result;
}
开发者ID:pgoron,项目名称:monodevelop,代码行数:21,代码来源:CSharpParser.cs
示例7: AddBlockChildren
void AddBlockChildren(BlockStatement result, Block blockStatement, ref int curLocal)
{
if (convertTypeSystemMode) {
return;
}
foreach (Mono.CSharp.Statement stmt in blockStatement.Statements) {
if (stmt == null)
continue;
/* if (curLocal < localVariables.Count && IsLower (localVariables[curLocal].Location, stmt.loc)) {
result.AddChild (CreateVariableDeclaration (localVariables[curLocal]), Roles.Statement);
curLocal++;
}*/
if (stmt is Block && !(stmt is ToplevelBlock || stmt is ExplicitBlock)) {
AddBlockChildren(result, (Block)stmt, ref curLocal);
} else {
result.AddChild((Statement)stmt.Accept(this), BlockStatement.StatementRole);
}
}
}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:19,代码来源:CSharpParser.cs
示例8: EmitMoveNext_NoResumePoints
void EmitMoveNext_NoResumePoints(EmitContext ec, Block original_block)
{
ec.Emit (OpCodes.Ldarg_0);
ec.Emit (OpCodes.Ldfld, IteratorHost.PC.Spec);
ec.Emit (OpCodes.Ldarg_0);
ec.EmitInt ((int) State.After);
ec.Emit (OpCodes.Stfld, IteratorHost.PC.Spec);
// We only care if the PC is zero (start executing) or non-zero (don't do anything)
ec.Emit (OpCodes.Brtrue, move_next_error);
SymbolWriter.StartIteratorBody (ec);
original_block.Emit (ec);
SymbolWriter.EndIteratorBody (ec);
ec.MarkLabel (move_next_error);
ec.Emit (OpCodes.Ldc_I4_0);
ec.Emit (OpCodes.Ret);
}
开发者ID:speier,项目名称:shake,代码行数:20,代码来源:iterators.cs
示例9: case_978
void case_978()
#line 6605 "cs-parser.jay"
{
current_block.SetEndLocation (lexer.Location);
current_block = current_block.Parent;
current_block = new Linq.QueryBlock (current_block, lexer.Location);
linq_clause_blocks.Push ((Linq.QueryBlock) current_block);
}
开发者ID:segaman,项目名称:NRefactory,代码行数:9,代码来源:cs-parser.cs
示例10: case_977
void case_977()
#line 6597 "cs-parser.jay"
{
if (linq_clause_blocks == null)
linq_clause_blocks = new Stack<Linq.QueryBlock> ();
current_block = new Linq.QueryBlock (current_block, lexer.Location);
linq_clause_blocks.Push ((Linq.QueryBlock) current_block);
}
开发者ID:segaman,项目名称:NRefactory,代码行数:9,代码来源:cs-parser.cs
示例11: case_976
void case_976()
#line 6587 "cs-parser.jay"
{
yyVal = new Linq.Where ((Linq.QueryBlock)current_block, (Expression)yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop]));
current_block.SetEndLocation (lexer.Location);
current_block = current_block.Parent;
}
开发者ID:segaman,项目名称:NRefactory,代码行数:8,代码来源:cs-parser.cs
示例12: case_974
void case_974()
#line 6568 "cs-parser.jay"
{
var lt = (LocatedToken) yyVals[-3+yyTop];
var sn = new Linq.RangeVariable (lt.Value, lt.Location);
yyVal = new Linq.Let ((Linq.QueryBlock) current_block, sn, (Expression)yyVals[0+yyTop], GetLocation (yyVals[-4+yyTop]));
lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]));
current_block.SetEndLocation (lexer.Location);
current_block = current_block.Parent;
((Linq.QueryBlock)current_block).AddRangeVariable (sn);
}
开发者ID:segaman,项目名称:NRefactory,代码行数:13,代码来源:cs-parser.cs
示例13: case_963
void case_963()
#line 6522 "cs-parser.jay"
{
var obj = (object[]) yyVals[0+yyTop];
yyVal = new Linq.GroupBy ((Linq.QueryBlock)current_block, (Expression)yyVals[-2+yyTop], linq_clause_blocks.Pop (), (Expression)obj[0], GetLocation (yyVals[-4+yyTop]));
lbag.AddLocation (yyVal, (Location) obj[1]);
current_block.SetEndLocation (lexer.Location);
current_block = current_block.Parent;
}
开发者ID:segaman,项目名称:NRefactory,代码行数:11,代码来源:cs-parser.cs
示例14: case_962
void case_962()
#line 6515 "cs-parser.jay"
{
current_block.SetEndLocation (lexer.Location);
current_block = current_block.Parent;
current_block = new Linq.QueryBlock (current_block, lexer.Location);
}
开发者ID:segaman,项目名称:NRefactory,代码行数:8,代码来源:cs-parser.cs
示例15: case_953
void case_953()
#line 6436 "cs-parser.jay"
{
var lt = (LocatedToken) yyVals[-3+yyTop];
var sn = new Linq.RangeVariable (lt.Value, lt.Location);
yyVal = new Linq.SelectMany ((Linq.QueryBlock)current_block, sn, (Expression)yyVals[0+yyTop], GetLocation (yyVals[-5+yyTop])) {
IdentifierType = (FullNamedExpression)yyVals[-4+yyTop]
};
current_block.SetEndLocation (lexer.Location);
current_block = current_block.Parent;
((Linq.QueryBlock)current_block).AddRangeVariable (sn);
lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]));
}
开发者ID:segaman,项目名称:NRefactory,代码行数:17,代码来源:cs-parser.cs
示例16: IteratorStatement
public IteratorStatement(Iterator iterator, Block original_block)
{
this.iterator = iterator;
this.original_block = original_block;
this.loc = iterator.Location;
}
开发者ID:speier,项目名称:shake,代码行数:6,代码来源:iterators.cs
示例17: EmitMoveNext
internal void EmitMoveNext(EmitContext ec, Block original_block)
{
move_next_ok = ec.DefineLabel ();
move_next_error = ec.DefineLabel ();
if (resume_points == null) {
EmitMoveNext_NoResumePoints (ec, original_block);
return;
}
current_pc = ec.GetTemporaryLocal (TypeManager.uint32_type);
ec.Emit (OpCodes.Ldarg_0);
ec.Emit (OpCodes.Ldfld, IteratorHost.PC.Spec);
ec.Emit (OpCodes.Stloc, current_pc);
// We're actually in state 'running', but this is as good a PC value as any if there's an abnormal exit
ec.Emit (OpCodes.Ldarg_0);
ec.EmitInt ((int) State.After);
ec.Emit (OpCodes.Stfld, IteratorHost.PC.Spec);
Label [] labels = new Label [1 + resume_points.Count];
labels [0] = ec.DefineLabel ();
bool need_skip_finally = false;
for (int i = 0; i < resume_points.Count; ++i) {
ResumableStatement s = resume_points [i];
need_skip_finally |= s is ExceptionStatement;
labels [i+1] = s.PrepareForEmit (ec);
}
if (need_skip_finally) {
skip_finally = ec.GetTemporaryLocal (TypeManager.bool_type);
ec.Emit (OpCodes.Ldc_I4_0);
ec.Emit (OpCodes.Stloc, skip_finally);
}
SymbolWriter.StartIteratorDispatcher (ec);
ec.Emit (OpCodes.Ldloc, current_pc);
ec.Emit (OpCodes.Switch, labels);
ec.Emit (OpCodes.Br, move_next_error);
SymbolWriter.EndIteratorDispatcher (ec);
ec.MarkLabel (labels [0]);
SymbolWriter.StartIteratorBody (ec);
original_block.Emit (ec);
SymbolWriter.EndIteratorBody (ec);
SymbolWriter.StartIteratorDispatcher (ec);
ec.Emit (OpCodes.Ldarg_0);
ec.EmitInt ((int) State.After);
ec.Emit (OpCodes.Stfld, IteratorHost.PC.Spec);
ec.MarkLabel (move_next_error);
ec.EmitInt (0);
ec.Emit (OpCodes.Ret);
ec.MarkLabel (move_next_ok);
ec.Emit (OpCodes.Ldc_I4_1);
ec.Emit (OpCodes.Ret);
SymbolWriter.EndIteratorDispatcher (ec);
}
开发者ID:speier,项目名称:shake,代码行数:65,代码来源:iterators.cs
示例18: case_979
void case_979()
#line 6613 "cs-parser.jay"
{
current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop]));
current_block.SetEndLocation (lexer.Location);
current_block = current_block.Parent;
current_block = new Linq.QueryBlock (current_block, lexer.Location);
}
开发者ID:segaman,项目名称:NRefactory,代码行数:9,代码来源:cs-parser.cs
示例19: CreateUsingStatement
public UsingStatement CreateUsingStatement(Block blockStatement)
{
var usingResult = new UsingStatement();
Mono.CSharp.Statement cur = blockStatement.Statements [0];
var u = cur as Using;
if (u != null) {
usingResult.AddChild(new CSharpTokenNode(Convert(u.loc), UsingStatement.UsingKeywordRole), UsingStatement.UsingKeywordRole);
usingResult.AddChild(new CSharpTokenNode(Convert(blockStatement.StartLocation), Roles.LPar), Roles.LPar);
if (u.Variables != null) {
var initializer = new VariableInitializer {
NameToken = Identifier.Create(u.Variables.Variable.Name, Convert(u.Variables.Variable.Location)),
};
var loc = LocationsBag.GetLocations(u.Variables);
if (loc != null)
initializer.AddChild(new CSharpTokenNode(Convert(loc [0]), Roles.Assign), Roles.Assign);
if (u.Variables.Initializer != null)
initializer.Initializer = u.Variables.Initializer.Accept(this) as Expression;
var varDec = new VariableDeclarationStatement {
Type = ConvertToType(u.Variables.TypeExpression),
Variables = { initializer }
};
if (u.Variables.Declarators != null) {
foreach (var decl in u.Variables.Declarators) {
var declLoc = LocationsBag.GetLocations(decl);
var init = new VariableInitializer();
if (declLoc != null && declLoc.Count > 0)
varDec.AddChild(new CSharpTokenNode(Convert(declLoc [0]), Roles.Comma), Roles.Comma);
init.AddChild(Identifier.Create(decl.Variable.Name, Convert(decl.Variable.Location)), Roles.Identifier);
if (decl.Initializer != null) {
if (declLoc != null && declLoc.Count > 1)
init.AddChild(new CSharpTokenNode(Convert(declLoc [1]), Roles.Assign), Roles.Assign);
init.AddChild((Expression)decl.Initializer.Accept(this), Roles.Expression);
}
varDec.AddChild(init, Roles.Variable);
}
}
usingResult.AddChild(varDec, UsingStatement.ResourceAcquisitionRole);
}
cur = u.Statement;
usingResult.AddChild(new CSharpTokenNode(Convert(blockStatement.EndLocation), Roles.RPar), Roles.RPar);
if (cur != null)
usingResult.AddChild((Statement)cur.Accept(this), Roles.EmbeddedStatement);
}
return usingResult;
}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:49,代码来源:CSharpParser.cs
示例20: case_980
void case_980()
#line 6621 "cs-parser.jay"
{
current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop]));
current_block.SetEndLocation (lexer.Location);
var outer_selector = linq_clause_blocks.Pop ();
var block = linq_clause_blocks.Pop ();
var lt = (LocatedToken) yyVals[-10+yyTop];
var sn = new Linq.RangeVariable (lt.Value, lt.Location);
Linq.RangeVariable into;
if (yyVals[0+yyTop] == null) {
into = sn;
yyVal = new Linq.Join (block, sn, (Expression)yyVals[-7+yyTop], outer_selector, (Linq.QueryBlock) current_block, GetLocation (yyVals[-11+yyTop]));
lbag.AddLocation (yyVal, GetLocation (yyVals[-9+yyTop]), GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[-3+yyTop]));
} else {
/**/
/* Set equals right side parent to beginning of linq query, it is not accessible therefore cannot cause name collisions*/
/**/
var parent = block.Parent;
while (parent is Linq.QueryBlock) {
parent = parent.Parent;
}
current_block.Parent = parent;
((Linq.QueryBlock)current_block).AddRangeVariable (sn);
lt = (LocatedToken) yyVals[0+yyTop];
into = new Linq.RangeVariable (lt.Value, lt.Location);
yyVal = new Linq.GroupJoin (block, sn, (Expression)yyVals[-7+yyTop], outer_selector, (Linq.QueryBlock) current_block, into, GetLocation (yyVals[-11+yyTop]));
lbag.AddLocation (yyVal, GetLocation (yyVals[-9+yyTop]), GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[-3+yyTop]), opt_intoStack.Pop ());
}
current_block = block.Parent;
((Linq.QueryBlock)current_block).AddRangeVariable (into);
}
void case_981()
#line 6659 "cs-parser.jay"
{
if (linq_clause_blocks == null)
linq_clause_blocks = new Stack<Linq.QueryBlock> ();
current_block = new Linq.QueryBlock (current_block, lexer.Location);
linq_clause_blocks.Push ((Linq.QueryBlock) current_block);
}
void case_982()
#line 6667 "cs-parser.jay"
{
current_block.SetEndLocation (lexer.Location);
current_block = current_block.Parent;
current_block = new Linq.QueryBlock (current_block, lexer.Location);
linq_clause_blocks.Push ((Linq.QueryBlock) current_block);
}
void case_983()
#line 6675 "cs-parser.jay"
{
current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop]));
current_block.SetEndLocation (lexer.Location);
current_block = current_block.Parent;
current_block = new Linq.QueryBlock (current_block, lexer.Location);
}
void case_984()
#line 6683 "cs-parser.jay"
{
current_block.AddStatement (new ContextualReturn ((Expression) yyVals[-1+yyTop]));
current_block.SetEndLocation (lexer.Location);
var outer_selector = linq_clause_blocks.Pop ();
var block = linq_clause_blocks.Pop ();
var lt = (LocatedToken) yyVals[-10+yyTop];
var sn = new Linq.RangeVariable (lt.Value, lt.Location);
Linq.RangeVariable into;
if (yyVals[0+yyTop] == null) {
into = sn;
yyVal = new Linq.Join (block, sn, (Expression)yyVals[-7+yyTop], outer_selector, (Linq.QueryBlock) current_block, GetLocation (yyVals[-12+yyTop])) {
IdentifierType = (FullNamedExpression)yyVals[-11+yyTop]
};
lbag.AddLocation (yyVal, GetLocation (yyVals[-10+yyTop]), GetLocation (yyVals[-7+yyTop]), GetLocation (yyVals[-4+yyTop]));
} else {
/**/
/* Set equals right side parent to beginning of linq query, it is not accessible therefore cannot cause name collisions*/
/**/
var parent = block.Parent;
while (parent is Linq.QueryBlock) {
parent = parent.Parent;
}
current_block.Parent = parent;
((Linq.QueryBlock)current_block).AddRangeVariable (sn);
//.........这里部分代码省略.........
开发者ID:segaman,项目名称:NRefactory,代码行数:101,代码来源:cs-parser.cs
注:本文中的Mono.CSharp.Block类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论