本文整理汇总了C#中Scope.LookupMixin方法的典型用法代码示例。如果您正苦于以下问题:C# Scope.LookupMixin方法的具体用法?C# Scope.LookupMixin怎么用?C# Scope.LookupMixin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scope
的用法示例。
在下文中一共展示了Scope.LookupMixin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindParameter
private static void BindParameter(Scope scope, Dictionary<string, MixinBlock> mixinReferences, Dictionary<string, Value> boundVariables, MixinParameter @param, Value value)
{
if (value is IncludeSelectorValue)
{
var toMap = (IncludeSelectorValue)value;
mixinReferences[@param.Name] = CreateAnonMixin(toMap);
return;
}
if (!(value is FuncValue))
{
boundVariables[@param.Name] = value.Bind(scope);
return;
}
var funcVal = value as FuncValue;
var asMixin = scope.LookupMixin(funcVal.Name);
if (asMixin == null)
{
var val = scope.LookupVariable(funcVal.Name, -1, -1, null);
if (val is IncludeSelectorValue)
{
var toMap = (IncludeSelectorValue)val;
mixinReferences[@param.Name] = CreateAnonMixin(toMap);
return;
}
boundVariables[@param.Name] = funcVal.Bind(scope);
}
else
{
mixinReferences[@param.Name] = asMixin;
}
}
示例2: BindAndEvaluateMixins
internal SelectorAndBlock BindAndEvaluateMixins(Scope scope = null, int depth = 0, LinkedList<MixinApplicationProperty> invokationChain = null)
{
if (depth > Scope.MAX_DEPTH)
{
Current.RecordError(ErrorType.Compiler, invokationChain.Last.Value, "Scope max depth exceeded, probably infinite recursion");
throw new StoppedCompilingException();
}
var injectReset = IsReset && scope == null;
scope = scope ?? Current.GlobalScope;
if (injectReset)
{
var vars = new Dictionary<string, Value>();
foreach (var var in ResetContext)
{
vars[var.Name] = var.Value.Bind(scope);
}
scope = scope.Push(vars, new Dictionary<string, MixinBlock>(), Position.NoSite);
}
invokationChain = invokationChain ?? new LinkedList<MixinApplicationProperty>();
var retRules = new List<Property>();
var nestedBlocks = Properties.OfType<NestedBlockProperty>();
var mixinApplications = Properties.OfType<MixinApplicationProperty>();
var nameValueRules = Properties.OfType<NameValueProperty>().ToList();
var inclRules = Properties.OfType<IncludeSelectorProperty>();
var resetRules = Properties.Where(w => w is ResetProperty || w is ResetSelfProperty);
var variableRules = Properties.OfType<VariableProperty>();
if (variableRules.Count() > 0)
{
var vars = new Dictionary<string, Value>();
foreach (var var in variableRules)
{
vars[var.Name] = var.Value.Bind(scope);
}
scope = scope.Push(vars, new Dictionary<string, MixinBlock>(), this);
}
foreach (var nameValue in nameValueRules)
{
retRules.Add(new NameValueProperty(nameValue.Name, nameValue.Value.Bind(scope), nameValue.Start, nameValue.Stop, nameValue.FilePath));
}
// Do the overrides last, so they can override everything
foreach (var rule in mixinApplications.OrderBy(k => k.DoesOverride ? 1 : 0))
{
var mixin = scope.LookupMixin(rule.Name);
if (mixin == null)
{
if (!rule.IsOptional)
{
Current.RecordError(ErrorType.Compiler, rule, "No mixin of the name [" + rule.Name + "] found");
}
// We can keep going, to possibly find more errors, so do so!
continue;
}
var @params = rule.Parameters.ToList();
var passedCount = @params.Count;
var maximum = mixin.Parameters.Count();
var minimum = mixin.Parameters.Count(c => c.DefaultValue is NotFoundValue);
var iLastRaw = @params.FindLastIndex(a => a.Name.IsNullOrEmpty());
var iFirstByName = @params.FindIndex(a => a.Name.HasValue());
var byNames = @params.Where(s => s.Name.HasValue());
if (iFirstByName != -1 && iLastRaw > iFirstByName)
{
Current.RecordError(ErrorType.Compiler, rule, "Arguments passed by name must appear after those passed without");
continue;
}
var outerContinue = false;
foreach (var byName in byNames)
{
bool found = false;
int index = -1;
for (var i = 0; i < mixin.Parameters.Count(); i++)
{
var p = mixin.Parameters.ElementAt(i);
if (p.Name == byName.Name)
{
found = true;
index = i;
}
}
if (!found)
{
Current.RecordError(ErrorType.Compiler, rule, "Argument to mixin [" + rule.Name + "] passed with name [" + byName.Name + "] but no parameter with that name exists.");
outerContinue = true;
//.........这里部分代码省略.........