本文整理汇总了C#中MSA类的典型用法代码示例。如果您正苦于以下问题:C# MSA类的具体用法?C# MSA怎么用?C# MSA使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MSA类属于命名空间,在下文中一共展示了MSA类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TransformConcatentation
internal static MSA.Expression/*!*/ TransformConcatentation(AstGenerator/*!*/ gen, List<Expression>/*!*/ parts,
Func<string, MethodInfo>/*!*/ opFactory, MSA.Expression additionalArg) {
var opSuffix = new StringBuilder(Math.Min(parts.Count, 4));
List<MSA.Expression> merged = ConcatLiteralsAndTransform(gen, parts, opSuffix);
if (merged.Count <= RubyOps.MakeStringParamCount) {
if (merged.Count == 0) {
merged.Add(Ast.Constant(String.Empty));
opSuffix.Append(RubyOps.SuffixBinary);
}
if (opSuffix.IndexOf(RubyOps.SuffixEncoded) != -1) {
merged.Add(Ast.Constant(RubyEncoding.GetCodePage(gen.Encoding)));
}
if (additionalArg != null) {
merged.Add(additionalArg);
}
return opFactory(opSuffix.ToString()).OpCall(merged);
} else {
var paramArray = Ast.NewArrayInit(typeof(object), merged);
var codePage = Ast.Constant(RubyEncoding.GetCodePage(gen.Encoding));
return (additionalArg != null) ?
opFactory("N").OpCall(paramArray, codePage, additionalArg) :
opFactory("N").OpCall(paramArray, codePage);
}
}
示例2: TransformRead
// arguments: complex arguments (expressions, maplets, splat, block)
// singleArgument: siple argument (complex are not used)
// assignmentRhsArgument: rhs of the assignment: target.method=(rhs)
internal static MSA.Expression/*!*/ TransformRead(Expression/*!*/ node, AstGenerator/*!*/ gen, bool hasImplicitSelf,
string/*!*/ methodName, MSA.Expression/*!*/ transformedTarget,
Arguments arguments, Block block, MSA.Expression singleArgument, MSA.Expression assignmentRhsArgument) {
Debug.Assert(assignmentRhsArgument == null || block == null, "Block not allowed in assignment");
Debug.Assert(singleArgument == null || arguments == null && assignmentRhsArgument == null);
Assert.NotNull(gen, transformedTarget);
Assert.NotEmpty(methodName);
// Pass args in this order:
// 1. instance
// 2. block (if present)
// 3. passed args: normal args, maplets, array
// 4. RHS of assignment (if present)
CallBuilder callBuilder = new CallBuilder(gen);
callBuilder.Instance = transformedTarget;
MSA.Expression blockArgVariable = null;
MSA.Expression transformedBlock = null;
if (block != null) {
blockArgVariable = gen.CurrentScope.DefineHiddenVariable("#block-def", typeof(Proc));
transformedBlock = block.Transform(gen);
callBuilder.Block = blockArgVariable;
}
if (arguments != null) {
arguments.TransformToCall(gen, callBuilder);
} else if (singleArgument != null) {
callBuilder.Add(singleArgument);
}
MSA.Expression rhsVariable = null;
if (assignmentRhsArgument != null) {
rhsVariable = gen.CurrentScope.DefineHiddenVariable("#rhs", assignmentRhsArgument.Type);
callBuilder.RhsArgument = Ast.Assign(rhsVariable, assignmentRhsArgument);
}
var dynamicSite = callBuilder.MakeCallAction(methodName, hasImplicitSelf);
if (gen.Context.CallSiteCreated != null) {
gen.Context.CallSiteCreated(node, dynamicSite);
}
MSA.Expression result = gen.DebugMark(dynamicSite, methodName);
if (block != null) {
result = gen.DebugMark(MakeCallWithBlockRetryable(gen, result, blockArgVariable, transformedBlock, block.IsDefinition),
"#RB: method call with a block ('" + methodName + "')");
}
if (assignmentRhsArgument != null) {
result = AstFactory.Block(result, rhsVariable);
}
return result;
}
示例3: TransformRead
internal static MSA.Expression/*!*/ TransformRead(AstGenerator/*!*/ gen, MSA.Expression/*!*/ left, MSA.Expression/*!*/ right) {
MSA.ParameterExpression temp;
MSA.Expression result = AstUtils.CoalesceFalse(
AstFactory.Box(left),
AstFactory.Box(right),
Methods.IsTrue,
out temp
);
gen.CurrentScope.AddHidden(temp);
return result;
}
示例4: ScopeBuilder
public ScopeBuilder(MSA.ParameterExpression/*!*/[] parameters, int firstClosureParam, int localCount,
ScopeBuilder parent, LexicalScope/*!*/ lexicalScope) {
Debug.Assert(parent == null || parent.LexicalScope == lexicalScope.OuterScope);
#if DEBUG
_id = Interlocked.Increment(ref _Id);
#endif
_parent = parent;
_parameters = parameters;
_localCount = localCount;
_firstClosureParam = firstClosureParam;
_lexicalScope = lexicalScope;
_hiddenVariables = new ReadOnlyCollectionBuilder<MSA.ParameterExpression>();
_localsTuple = DefineHiddenVariable("#locals", MakeLocalsTupleType());
_outermostClosureReferredTo = this;
}
示例5: TransformQualifier
internal StaticScopeKind TransformQualifier(AstGenerator/*!*/ gen, out MSA.Expression transformedQualifier) {
if (_qualifier != null) {
Debug.Assert(_explicitlyBound);
// qualifier.Foo
transformedQualifier = _qualifier.TransformRead(gen);
return StaticScopeKind.Explicit;
} else if (_explicitlyBound) {
// ::Foo
transformedQualifier = null;
return StaticScopeKind.Global;
} else if (gen.CurrentModule != null) {
// statically (lexically) implicitly bound to the enclosing module:
transformedQualifier = gen.CurrentModule.SelfVariable; // TODO: remove, should be retrieved from code context/scope
return StaticScopeKind.EnclosingModule;
} else {
// statically (lexically) implicitly bound to top declaring module:
transformedQualifier = null;
return StaticScopeKind.EnclosingModule;
}
}
示例6: EnterSourceUnit
public void EnterSourceUnit(
ScopeBuilder/*!*/ locals,
MSA.Expression/*!*/ selfParameter,
MSA.Expression/*!*/ runtimeScopeVariable,
MSA.Expression blockParameter,
MSA.Expression/*!*/ rfcVariable,
MSA.Expression currentMethodVariable,
string methodName,
Parameters parameters) {
Assert.NotNull(locals, selfParameter, runtimeScopeVariable, rfcVariable);
Debug.Assert(_currentElement == null && _currentLoop == null && _currentRescue == null &&
_currentVariableScope == null && _currentModule == null && _currentBlock == null && _currentMethod == null);
EnterMethodDefinition(
locals,
selfParameter,
runtimeScopeVariable,
blockParameter,
rfcVariable,
currentMethodVariable,
methodName,
parameters);
}
示例7: EnterModuleDefinition
public void EnterModuleDefinition(
ScopeBuilder/*!*/ locals,
MSA.Expression/*!*/ selfVariable,
MSA.Expression/*!*/ runtimeScopeVariable,
bool isSingleton) {
Assert.NotNull(locals, selfVariable, runtimeScopeVariable);
ModuleScope module = new ModuleScope(locals, selfVariable, runtimeScopeVariable, isSingleton);
module.Parent = _currentElement;
module.ParentVariableScope = _currentVariableScope;
module.ParentModule = _currentModule;
_currentElement = module;
_currentVariableScope = module;
_currentModule = module;
}
示例8: EnterMethodDefinition
public void EnterMethodDefinition(
ScopeBuilder/*!*/ locals,
MSA.Expression/*!*/ selfParameter,
MSA.Expression/*!*/ runtimeScopeVariable,
MSA.Expression blockParameter,
MSA.Expression/*!*/ rfcVariable,
MSA.Expression currentMethodVariable,
string/*!*/ methodName,
Parameters parameters) {
Assert.NotNull(locals, selfParameter, runtimeScopeVariable, rfcVariable);
MethodScope method = new MethodScope(
locals,
selfParameter,
runtimeScopeVariable,
blockParameter,
rfcVariable,
currentMethodVariable,
methodName,
parameters
);
method.Parent = _currentElement;
method.ParentRescue = _currentRescue;
method.ParentLoop = _currentLoop;
method.ParentBlock = _currentBlock;
method.ParentVariableScope = _currentVariableScope;
method.ParentMethod = _currentMethod;
_currentElement = method;
_currentRescue = null;
_currentLoop = null;
_currentBlock = null;
_currentVariableScope = method;
_currentMethod = method;
}
示例9: TransformRead
internal static MSA.Expression/*!*/ TransformRead(AstGenerator/*!*/ gen, List<MSA.Expression>/*!*/ rightValues,
MSA.Expression splattedValue, bool doSplat) {
Assert.NotNull(gen, rightValues);
MSA.Expression result;
// We need to distinguish various special cases here.
// For parallel assignment specification, see "Ruby Language.docx/Runtime/Parallel Assignment".
// R(0,*)?
bool rightNoneSplat = rightValues.Count == 0 && splattedValue != null;
// R(1,-)?
bool rightOneNone = rightValues.Count == 1 && splattedValue == null;
if (rightNoneSplat) {
result = (doSplat ? Methods.Splat : Methods.Unsplat).OpCall(AstFactory.Box(splattedValue));
} else if (rightOneNone && doSplat) {
result = rightValues[0];
} else {
result = Methods.MakeArrayOpCall(rightValues);
if (splattedValue != null) {
result = Methods.SplatAppend.OpCall(result, AstFactory.Box(splattedValue));
}
}
return result;
}
示例10: TraceCallSite
internal virtual void TraceCallSite(Expression/*!*/ expression, MSA.DynamicExpression/*!*/ callSite) {
}
示例11: AddDebugInfo
internal MSA.Expression/*!*/ AddDebugInfo(MSA.Expression/*!*/ expression, SourceSpan location) {
return Microsoft.Scripting.Ast.Utils.AddDebugInfo(expression, _document, location.Start, location.End);
}
示例12: AddReturnTarget
internal MSA.Expression/*!*/ AddReturnTarget(MSA.Expression/*!*/ expression) {
return CurrentFrame.AddReturnTarget(expression);
}
示例13: MethodScope
public MethodScope(
ScopeBuilder/*!*/ builder,
MSA.Expression/*!*/ selfVariable,
MSA.Expression/*!*/ runtimeScopeVariable,
MSA.Expression blockVariable,
MSA.Expression/*!*/ rfcVariable,
MSA.Expression currentMethodVariable,
string methodName,
Parameters parameters)
: base(builder, selfVariable, runtimeScopeVariable) {
Assert.NotNull(rfcVariable);
_blockVariable = blockVariable;
_rfcVariable = rfcVariable;
_methodName = methodName;
_parameters = parameters;
_currentMethodVariable = currentMethodVariable;
}
示例14: BlockScope
public BlockScope(ScopeBuilder/*!*/ builder, MSA.Expression/*!*/ selfVariable, MSA.Expression/*!*/ runtimeScopeVariable,
MSA.Expression/*!*/ bfcVariable, MSA.LabelTarget/*!*/ redoLabel)
: base(builder, selfVariable, runtimeScopeVariable) {
Assert.NotNull(bfcVariable, redoLabel);
_bfcVariable = bfcVariable;
_redoLabel = redoLabel;
}
示例15: FrameScope
public FrameScope(ScopeBuilder/*!*/ builder, MSA.Expression/*!*/ selfVariable, MSA.Expression/*!*/ runtimeScopeVariable)
: base(builder, selfVariable, runtimeScopeVariable) {
_uniqueId = Interlocked.Increment(ref _UniqueId);
}