本文整理汇总了C#中BlockStatement.GetRegion方法的典型用法代码示例。如果您正苦于以下问题:C# BlockStatement.GetRegion方法的具体用法?C# BlockStatement.GetRegion怎么用?C# BlockStatement.GetRegion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BlockStatement
的用法示例。
在下文中一共展示了BlockStatement.GetRegion方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompileMethod
public JsFunctionDefinitionExpression CompileMethod(IList<IParameter> parameters, IDictionary<IVariable, VariableData> variables, BlockStatement body, bool staticMethodWithThisAsFirstArgument)
{
SetRegion(body.GetRegion());
try {
_result = MethodCompiler.FixByRefParameters(parameters, variables);
VisitChildren(body);
JsBlockStatement jsbody;
if (_result.Count == 1 && _result[0] is JsBlockStatement)
jsbody = (JsBlockStatement)_result[0];
else
jsbody = new JsBlockStatement(_result);
return JsExpression.FunctionDefinition((staticMethodWithThisAsFirstArgument ? new[] { _namer.ThisAlias } : new string[0]).Concat(parameters.Select(p => variables[p].Name)), jsbody);
}
catch (Exception ex) {
_errorReporter.InternalError(ex);
return JsExpression.FunctionDefinition(new string[0], JsBlockStatement.EmptyStatement);
}
}
示例2: CompileMethod
public JsFunctionDefinitionExpression CompileMethod(IList<IParameter> parameters, IDictionary<IVariable, VariableData> variables, BlockStatement body, bool staticMethodWithThisAsFirstArgument, bool expandParams, StateMachineType stateMachineType, IType iteratorBlockYieldTypeOrAsyncTaskGenericArgument = null) {
SetRegion(body.GetRegion());
try {
_result = MethodCompiler.PrepareParameters(parameters, variables, expandParams: expandParams, staticMethodWithThisAsFirstArgument: staticMethodWithThisAsFirstArgument);
VisitChildren(body);
JsBlockStatement jsbody;
if (_result.Count == 1 && _result[0] is JsBlockStatement)
jsbody = (JsBlockStatement)_result[0];
else
jsbody = JsStatement.Block(_result);
var result = JsExpression.FunctionDefinition((staticMethodWithThisAsFirstArgument ? new[] { _namer.ThisAlias } : new string[0]).Concat(parameters.Where((p, i) => i != parameters.Count - 1 || !expandParams).Select(p => variables[p].Name)), jsbody);
switch (stateMachineType) {
case StateMachineType.NormalMethod:
result = StateMachineRewriteNormalMethod(result);
break;
case StateMachineType.IteratorBlockReturningIEnumerable:
case StateMachineType.IteratorBlockReturningIEnumerator:
result = StateMachineRewriteIteratorBlock(result, stateMachineType == StateMachineType.IteratorBlockReturningIEnumerable, iteratorBlockYieldTypeOrAsyncTaskGenericArgument);
break;
case StateMachineType.AsyncVoid:
case StateMachineType.AsyncTask:
result = StateMachineRewriteAsyncMethod(result, stateMachineType == StateMachineType.AsyncTask, iteratorBlockYieldTypeOrAsyncTaskGenericArgument);
break;
default:
throw new ArgumentException("stateMachineType");
}
return result;
}
catch (Exception ex) {
_errorReporter.InternalError(ex);
return JsExpression.FunctionDefinition(new string[0], JsStatement.EmptyBlock);
}
}
示例3: CompileMethod
public JsFunctionDefinitionExpression CompileMethod(IList<IParameter> parameters, IDictionary<IVariable, VariableData> variables, BlockStatement body)
{
_filename = body.GetRegion().FileName;
try {
_result = MethodCompiler.FixByRefParameters(parameters, variables);
VisitChildren(body);
JsBlockStatement jsbody;
if (_result.Count == 1 && _result[0] is JsBlockStatement)
jsbody = (JsBlockStatement)_result[0];
else
jsbody = new JsBlockStatement(_result);
return JsExpression.FunctionDefinition(parameters.Select(p => variables[p].Name), jsbody);
}
catch (Exception ex) {
_errorReporter.InternalError(ex, _filename, _location);
return JsExpression.FunctionDefinition(new string[0], JsBlockStatement.EmptyStatement);
}
}