本文整理汇总了C#中XSpect.Yacq.Symbols.SymbolTable.Resolve方法的典型用法代码示例。如果您正苦于以下问题:C# SymbolTable.Resolve方法的具体用法?C# SymbolTable.Resolve怎么用?C# SymbolTable.Resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XSpect.Yacq.Symbols.SymbolTable
的用法示例。
在下文中一共展示了SymbolTable.Resolve方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Clear
public static Expression Clear(DispatchExpression e, SymbolTable s, Type t)
{
return YacqExpression.Dispatch(
s,
DispatchTypes.Method,
s.Resolve("*textbox*"),
"Clear"
);
}
示例2: Write
public static Expression Write(DispatchExpression e, SymbolTable s, Type t)
{
return YacqExpression.Dispatch(
s,
DispatchTypes.Method,
s.Resolve("*textbox*"),
"AppendText",
YacqExpression.Dispatch(
s,
DispatchTypes.Method,
e.Left,
"ToString"
)
);
}
示例3: Global
public static Expression Global(DispatchExpression e, SymbolTable s, Type t)
{
return YacqExpression.SymbolTable(s.Resolve("$global").Const<SymbolTable>());
}
示例4: HereSymbol
public static Expression HereSymbol(DispatchExpression e, SymbolTable s, Type t)
{
return s.Resolve("$global");
}
示例5: Import
public static Expression Import(DispatchExpression e, SymbolTable s, Type t)
{
return s.Resolve(DispatchTypes.Member, ModuleIdentifier)(e, s, t)
.Method(s, "import", e.Arguments);
}
示例6: Module
public static Expression Module(DispatchExpression e, SymbolTable s, Type t)
{
return (e.Arguments[0].List().Null(_ => _.IsEmpty())
? new SymbolTable().Apply(s_ => s_.MarkAsModule())
: ModuleLoader.CreatePathSymbols(
s.Resolve(DispatchTypes.Member, ModuleIdentifier)(e, s, t).Const<SymbolTable>(),
GetIdentifierFragments(e.Arguments[0])
)
).Let(s_ => YacqExpression.Function(s_, "$",
e.Arguments
.Skip(1)
.StartWith(YacqExpression.Vector(s_))
));
}
示例7: CreateType
public static Expression CreateType(DispatchExpression e, SymbolTable s, Type t)
{
var type = (e.Arguments[0].List(":") ?? new [] { e.Arguments[0], YacqExpression.TypeCandidate(typeof(Object)), })
.Let(es => s.Resolve("*assembly*").Const<YacqAssembly>().DefineType(
String.Join(".", GetIdentifierFragments(es.First())),
(es.Last() is VectorExpression
? ((VectorExpression) es.Last()).Elements
: EnumerableEx.Return(es.Last())
)
.ReduceAll(s)
.Cast<TypeCandidateExpression>()
.Select(_ => _.ElectedType)
.ToArray()
));
e.Arguments
.Skip(1)
.OfType<ListExpression>()
.ForEach(l =>
{
var rest = l.Elements
.SkipWhile(_ => _.Id().Let(i => i != "member" && i != "method"))
.Skip(1)
.ToArray();
var attributes = l.Elements
.SkipLast(rest.Length)
.OfType<IdentifierExpression>()
.Select(_ => _.Name)
.ToArray()
.Let(_ =>
(_.Last() == "method"
? MemberTypes.Method
: rest
.OfType<IdentifierExpression>()
.Any(i => i.Name == "get" || i.Name == "set")
? MemberTypes.Property
: MemberTypes.Field
)
.Let(mt => Tuple.Create(mt, _.Any()
? Enum.Parse(
mt == MemberTypes.Field
? typeof(FieldAttributes)
: typeof(MethodAttributes),
String.Join(",", _.SkipLast(1)),
true
)
: null
))
)
.If(
_ => _.Item1 == MemberTypes.Method && rest.First().Id() == "new",
_ => Tuple.Create(MemberTypes.Constructor, _.Item2)
);
switch (attributes.Item1)
{
case MemberTypes.Field:
rest[0].List(":").Let(es => type.DefineField(
es.First().Id(),
((TypeCandidateExpression) es.Last().Reduce(s)).ElectedType,
(FieldAttributes) (attributes.Item2 ?? FieldAttributes.Public),
rest.ElementAtOrDefault(1)
));
break;
case MemberTypes.Property:
rest[0].List(":").Let(es => type.DefineProperty(
es.First().Id(),
((TypeCandidateExpression) es.Last().Reduce(s)).ElectedType,
(MethodAttributes) (attributes.Item2 ?? MethodAttributes.Public),
rest[1].Id().Let(i => i != "get" && i != "set") ? rest[1] : null,
rest.Any(_ => _.Id() == "get")
? rest
.SkipWhile(_ => _.Id() != "get")
.Skip(1)
.If(
_ => _.Any() && _.First().Id() != "set",
_ => _.First(),
_ => YacqExpression.Ignore()
)
: null,
rest.Any(_ => _.Id() == "set")
? rest
.SkipWhile(_ => _.Id() != "set")
.Skip(1)
.If(
_ => _.Any() && _.First().Id() != "get",
_ => _.First(),
_ => YacqExpression.Ignore()
)
: null
));
break;
case MemberTypes.Method:
(rest[0].List(":") ?? new [] { rest[0], YacqExpression.TypeCandidate(typeof(void)), })
.Let(es => type.DefineMethod(
es.First().Id(),
(MethodAttributes) (attributes.Item2 ?? MethodAttributes.Public),
((TypeCandidateExpression) es.Last().Reduce(s)).ElectedType,
((VectorExpression) rest[1]).Elements
.ReduceAll(s)
.OfType<TypeCandidateExpression>()
.Select(_ => _.ElectedType)
//.........这里部分代码省略.........
示例8: CreateAnonymousInstance
public static Expression CreateAnonymousInstance(DispatchExpression e, SymbolTable s, Type t)
{
return e.Arguments
.Share(_ => _.Zip(_, (i, v) => Tuple.Create(i.Id(), v.Reduce(s))))
.Let(ms => s.Resolve("*assembly*").Const<YacqAssembly>()
.TryDefineType(ms.ToDictionary(_ => _.Item1, _ => _.Item2.Type))
.Create(s)
.Let(nt => Expression.New(
nt.GetConstructors()[0],
ms.Select(_ => _.Item2),
ms.Select(_ => nt.GetProperty(_.Item1))
#if SILVERLIGHT
.Cast<MemberInfo>()
#endif
))
);
}