本文整理汇总了C#中Boo.Lang.Compiler.Ast.MacroStatement.get方法的典型用法代码示例。如果您正苦于以下问题:C# MacroStatement.get方法的具体用法?C# MacroStatement.get怎么用?C# MacroStatement.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Boo.Lang.Compiler.Ast.MacroStatement
的用法示例。
在下文中一共展示了MacroStatement.get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTemplates
private IDictionary<string, MacroStatement> GetTemplates(MacroStatement _bml) {
if (!_bml.ContainsAnnotation("templates"))
{
_bml["templates"] = new Dictionary<string, MacroStatement>();
}
return _bml.get<IDictionary<string, MacroStatement>>("templates");
}
示例2: ExpandImpl
protected override Statement ExpandImpl(MacroStatement macro){
if (macro.Arguments.Count == 0){
throw new Exception("need at least one IEnumerable parameter");
}
var result = new Block();
Expression src = macro.Arguments[0];
var idx = new ReferenceExpression("_idx");
Expression item = new ReferenceExpression("i");
var col = new ReferenceExpression("current_collection");
if (src is BinaryExpression){
item = ((BinaryExpression) src).Left;
src = ((BinaryExpression) src).Right;
}
if (macro.Arguments.Count > 1){
idx = (ReferenceExpression) macro.Arguments[1];
}
string prefix = macro.get<string>("_prefix") ?? "";
string suffix = macro.get<string>("_suffix") ?? "";
Func<string, MacroStatement> findmacro = s =>{
var r = macro.get<Node>(s);
if (null == r){
return null;
}
if (!(r is MacroStatement)){
var m = new MacroStatement("stub");
m.Body = new Block().add(r);
r = m;
}
return (MacroStatement) r;
};
Func<MacroStatement, Block> extract = m =>{
if (null == m){
return null;
}
if (m.Body != null && !m.Body.IsEmpty){
if (m.Body.Statements.Count == 1){
if (m.Body.Statements[0] is ExpressionStatement){
Expression _ex =
((ExpressionStatement) m.Body.Statements[0]).
Expression;
if (_ex is LiteralExpression ||
!_ex.ToCodeString().ToLower().StartsWith("out")){
return new Block().add(_ex.writeOut());
}
}
}
return m.Body;
}
if (m.Arguments.Count == 0){
return null;
}
var r = new Block();
if (!(m.Arguments[0] is MethodInvocationExpression)){
r.Add(BrailBuildingHelper.WriteOut(m.Arguments[0]));
}
else{
r.Add(m.Arguments[0]);
}
return r;
};
MacroStatement beforeall_macro = findmacro("beforeall");
MacroStatement onitem_macro = findmacro("onitem") ?? macro;
MacroStatement onerror_macro = findmacro("onerror");
;
MacroStatement between_macro = findmacro("between");
;
MacroStatement afterall_macro = findmacro("afterall");
;
MacroStatement onempty_macro = findmacro("onempty");
;
MacroStatement beforeeach_macro = findmacro("beforeeach");
;
MacroStatement aftereach_macro = findmacro("aftereach");
MacroStatement prepare_macro = findmacro("prepare");
;
Block beforeall = extract(beforeall_macro);
Block onitem = extractMainItemBlock(macro, extract, onitem_macro, item, prefix, suffix);
Block onerror = extract(onerror_macro);
Block between = extract(between_macro);
Block afterall = extract(afterall_macro);
Block onempty = null;
bool proceed_on_empty = false;
if (onempty_macro != null && onempty_macro.Arguments.Count != 0 &&
onempty_macro.Arguments[0].ToCodeString() == "proceed"){
proceed_on_empty = true;
}
else{
onempty = extract(onempty_macro);
//.........这里部分代码省略.........