本文整理汇总了C#中NewExpression类的典型用法代码示例。如果您正苦于以下问题:C# NewExpression类的具体用法?C# NewExpression怎么用?C# NewExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NewExpression类属于命名空间,在下文中一共展示了NewExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: E
ISemantic E(NewExpression nex)
{
// http://www.d-programming-language.org/expression.html#NewExpression
ISemantic[] possibleTypes = null;
if (nex.Type is IdentifierDeclaration)
possibleTypes = TypeDeclarationResolver.Resolve((IdentifierDeclaration)nex.Type, ctxt, filterForTemplateArgs: false);
else
possibleTypes = TypeDeclarationResolver.Resolve(nex.Type, ctxt);
var ctors = new Dictionary<DMethod, TemplateIntermediateType>();
if (possibleTypes == null)
return null;
foreach (var t in possibleTypes)
{
var ct = DResolver.StripAliasSymbol(t as AbstractType) as TemplateIntermediateType;
if (ct!=null &&
!ct.Definition.ContainsAttribute(DTokens.Abstract))
foreach (var ctor in GetConstructors(ct))
ctors.Add(ctor, ct);
}
MemberSymbol finalCtor = null;
var kvArray = ctors.ToArray();
/*
* TODO: Determine argument types and filter out ctor overloads.
*/
if (kvArray.Length != 0)
finalCtor = new MemberSymbol(kvArray[0].Key, kvArray[0].Value, nex);
else if (possibleTypes.Length != 0)
return AbstractType.Get(possibleTypes[0]);
return finalCtor;
}
开发者ID:DinrusGroup,项目名称:DinrusIDE,代码行数:39,代码来源:Evaluation.UnaryExpressions.cs
示例2: Update
/// <summary>
/// Creates a new expression that is like this one, but using the
/// supplied children. If all of the children are the same, it will
/// return this expression.
/// </summary>
/// <param name="newExpression">The <see cref="NewExpression" /> property of the result.</param>
/// <param name="bindings">The <see cref="Bindings" /> property of the result.</param>
/// <returns>This expression if no children changed, or an expression with the updated children.</returns>
public MemberInitExpression Update(NewExpression newExpression, IEnumerable<MemberBinding> bindings) {
if (newExpression == NewExpression && bindings == Bindings) {
return this;
}
return Expression.MemberInit(newExpression, bindings);
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:14,代码来源:MemberInitExpression.cs
示例3: PostWalk
protected internal virtual void PostWalk(NewExpression node) { }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:1,代码来源:Walker.Generated.cs
示例4: PostWalk
public virtual void PostWalk(NewExpression node)
{
}
开发者ID:Alxandr,项目名称:IronTotem,代码行数:3,代码来源:TotemWalker.cs
示例5: HandleNewExpression_Ctor
private static void HandleNewExpression_Ctor(NewExpression nex, IBlockNode curBlock, List<AbstractType> _ctors, AbstractType t)
{
var udt = t as TemplateIntermediateType;
if (udt is ClassType || udt is StructType)
{
bool explicitCtorFound = false;
var constructors = new List<DMethod>();
//TODO: Mixed-in ctors? --> Convert to AbstractVisitor/use NameScan
foreach (var member in udt.Definition)
{
var dm = member as DMethod;
if (dm != null && dm.SpecialType == DMethod.MethodType.Constructor)
{
explicitCtorFound = true;
if (!dm.IsPublic)
{
var curNode = curBlock;
bool pass = false;
do
{
if (curNode == udt.Definition)
{
pass = true;
break;
}
}
while ((curNode = curNode.Parent as IBlockNode) != curNode);
if (!pass)
continue;
}
constructors.Add(dm);
}
}
if (constructors.Count == 0)
{
if (explicitCtorFound)
{
// TODO: Somehow inform the user that the current class can't be instantiated
}
else
{
// Introduce default constructor
constructors.Add(new DMethod(DMethod.MethodType.Constructor)
{
Description = "Default constructor for " + udt.Name,
Parent = udt.Definition
});
}
}
// Wrapp all ctor members in MemberSymbols
foreach (var ctor in constructors)
_ctors.Add(new MemberSymbol(ctor, t, nex.Type));
}
}
开发者ID:Extrawurst,项目名称:D_Parser,代码行数:60,代码来源:ParameterInsightResolution.cs
示例6: CalculateCurrentArgument
static void CalculateCurrentArgument(NewExpression nex,
ArgumentsResolutionResult res,
CodeLocation caretLocation,
ResolutionContext ctxt,
IEnumerable<AbstractType> resultBases=null)
{
if (nex.Arguments != null)
res.CurrentlyTypedArgumentIndex = nex.Arguments.Length;
/*{
int i = 0;
foreach (var arg in nex.Arguments)
{
if (caretLocation >= arg.Location && caretLocation <= arg.EndLocation)
{
res.CurrentlyTypedArgumentIndex = i;
break;
}
i++;
}
}*/
}
开发者ID:Extrawurst,项目名称:D_Parser,代码行数:21,代码来源:ParameterInsightResolution.cs
示例7: HandleNewExpression
static void HandleNewExpression(NewExpression nex,
ArgumentsResolutionResult res,
IEditorData Editor,
ResolverContextStack ctxt,
IBlockNode curBlock)
{
res.MethodIdentifier = nex;
CalculateCurrentArgument(nex, res, Editor.CaretLocation, ctxt);
var type = TypeDeclarationResolver.ResolveSingle(nex.Type, ctxt) as ClassType;
//TODO: Inform the user that only classes can be instantiated
if (type != null)
{
var constructors = new List<DMethod>();
bool explicitCtorFound = false;
foreach (var member in type.Definition)
{
var dm = member as DMethod;
if (dm != null && dm.SpecialType == DMethod.MethodType.Constructor)
{
explicitCtorFound = true;
if (!dm.IsPublic)
{
var curNode = curBlock;
bool pass = false;
do
{
if (curNode == type.Definition)
{
pass = true;
break;
}
}
while ((curNode = curNode.Parent as IBlockNode) != curNode);
if (!pass)
continue;
}
constructors.Add(dm);
}
}
if (constructors.Count == 0)
{
if (explicitCtorFound)
{
// TODO: Somehow inform the user that the current class can't be instantiated
}
else
{
// Introduce default constructor
constructors.Add(new DMethod(DMethod.MethodType.Constructor)
{
Description = "Default constructor for " + type.Name,
Parent = type.Definition
});
}
}
// Wrapp all ctor members in MemberSymbols
var _ctors = new List<AbstractType>();
foreach (var ctor in constructors)
_ctors.Add(new MemberSymbol(ctor, type, nex.Type));
res.ResolvedTypesOrMethods = _ctors.ToArray();
//TODO: Probably pre-select the current ctor by handling previously typed arguments etc.
}
}
开发者ID:gavin-norman,项目名称:Mono-D,代码行数:72,代码来源:ParameterInsightResolution.cs
示例8: Update
/// <summary>
/// Creates a new expression that is like this one, but using the
/// supplied children. If all of the children are the same, it will
/// return this expression.
/// </summary>
/// <param name="newExpression">The <see cref="NewExpression" /> property of the result.</param>
/// <param name="initializers">The <see cref="Initializers" /> property of the result.</param>
/// <returns>This expression if no children changed, or an expression with the updated children.</returns>
public ListInitExpression Update(NewExpression newExpression, IEnumerable<ElementInit> initializers) {
if (newExpression == NewExpression && initializers == Initializers) {
return this;
}
return Expression.ListInit(newExpression, initializers);
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:14,代码来源:ListInitExpression.cs
示例9: Visit
public void Visit(NewExpression nex)
{
res.MethodIdentifier = nex;
CalculateCurrentArgument(nex, res, Editor.CaretLocation, ctxt);
var type = TypeDeclarationResolver.ResolveSingle(nex.Type, ctxt);
var _ctors = new List<AbstractType>();
if (type is AmbiguousType)
foreach (var t in (type as AmbiguousType).Overloads)
HandleNewExpression_Ctor(nex, curScope, _ctors, t);
else
HandleNewExpression_Ctor(nex, curScope, _ctors, type);
res.ResolvedTypesOrMethods = _ctors.ToArray();
}
开发者ID:DinrusGroup,项目名称:D_Parser,代码行数:17,代码来源:ParameterInsightResolution.cs
示例10: HandleNewExpression_Ctor
private static void HandleNewExpression_Ctor(NewExpression nex, IBlockNode curBlock, List<AbstractType> _ctors, AbstractType t)
{
var udt = t as TemplateIntermediateType;
if (udt is ClassType || udt is StructType)
{
bool explicitCtorFound;
if (!CtorScan.ScanForConstructors(nex, curBlock, udt, _ctors, out explicitCtorFound))
{
if (explicitCtorFound)
{
// TODO: Somehow inform the user that the current class can't be instantiated
}
else
{
// Introduce default constructor
_ctors.Add(new MemberSymbol(new DMethod(DMethod.MethodType.Constructor)
{
Description = "Default constructor for " + udt.Name,
Parent = udt.Definition
}, udt));
}
}
}
}
开发者ID:DinrusGroup,项目名称:D_Parser,代码行数:25,代码来源:ParameterInsightResolution.cs
示例11: ScanForConstructors
public static bool ScanForConstructors(NewExpression sr, IBlockNode scope, UserDefinedType udt, List<AbstractType> _ctors, out bool explicitCtorFound)
{
explicitCtorFound = false;
var ct = new CtorScan(sr, new ResolutionContext(new Misc.LegacyParseCacheView(new RootPackage[] {}), null, scope));
ct.DeepScanClass(udt, new ItemCheckParameters(MemberFilter.Methods), false);
_ctors.AddRange(ct.matches_types);
var rawList = (udt.Definition as DClassLike)[DMethod.ConstructorIdentifierHash];
if(rawList != null)
{
foreach(var n in rawList)
{
var dm = n as DMethod;
if(dm == null || dm.IsStatic || dm.SpecialType != DMethod.MethodType.Constructor)
continue;
explicitCtorFound = true;
break;
}
}
return ct.matches_types.Count != 0;
}
开发者ID:DinrusGroup,项目名称:D_Parser,代码行数:24,代码来源:ParameterInsightResolution.cs
示例12: MemberInitExpression
internal MemberInitExpression(NewExpression newExpression, ReadOnlyCollection<MemberBinding> bindings) {
_newExpression = newExpression;
_bindings = bindings;
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:4,代码来源:MemberInitExpression.cs
示例13: MemberInit
///<summary>Creates a <see cref="T:System.Linq.Expressions.MemberInitExpression" />.</summary>
///<returns>A <see cref="T:System.Linq.Expressions.MemberInitExpression" /> that has the <see cref="P:System.Linq.Expressions.Expression.NodeType" /> property equal to <see cref="F:System.Linq.Expressions.ExpressionType.MemberInit" /> and the <see cref="P:System.Linq.Expressions.MemberInitExpression.NewExpression" /> and <see cref="P:System.Linq.Expressions.MemberInitExpression.Bindings" /> properties set to the specified values.</returns>
///<param name="newExpression">A <see cref="T:System.Linq.Expressions.NewExpression" /> to set the <see cref="P:System.Linq.Expressions.MemberInitExpression.NewExpression" /> property equal to.</param>
///<param name="bindings">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> that contains <see cref="T:System.Linq.Expressions.MemberBinding" /> objects to use to populate the <see cref="P:System.Linq.Expressions.MemberInitExpression.Bindings" /> collection.</param>
///<exception cref="T:System.ArgumentNullException">
///<paramref name="newExpression" /> or <paramref name="bindings" /> is null.</exception>
///<exception cref="T:System.ArgumentException">The <see cref="P:System.Linq.Expressions.MemberBinding.Member" /> property of an element of <paramref name="bindings" /> does not represent a member of the type that <paramref name="newExpression" />.Type represents.</exception>
public static MemberInitExpression MemberInit(NewExpression newExpression, IEnumerable<MemberBinding> bindings) {
ContractUtils.RequiresNotNull(newExpression, "newExpression");
ContractUtils.RequiresNotNull(bindings, "bindings");
var roBindings = bindings.ToReadOnly();
ValidateMemberInitArgs(newExpression.Type, roBindings);
return new MemberInitExpression(newExpression, roBindings);
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:14,代码来源:MemberInitExpression.cs
示例14: ListInit
/// <summary>
/// Creates a <see cref="ListInitExpression"/> that uses a method named "Add" to add elements to a collection.
/// </summary>
/// <param name="newExpression">A <see cref="NewExpression"/> to set the <see cref="P:ListInitExpression.NewExpression"/> property equal to.</param>
/// <param name="initializers">An array of <see cref="Expression"/> objects to use to populate the <see cref="ListInitExpression.Initializers"/> collection.</param>
/// <returns>A <see cref="ListInitExpression"/> that has the <see cref="P:ListInitExpression.NodeType"/> property equal to ListInit and the <see cref="P:ListInitExpression.NewExpression"/> property set to the specified value.</returns>
public static ListInitExpression ListInit(NewExpression newExpression, params Expression[] initializers) {
ContractUtils.RequiresNotNull(newExpression, "newExpression");
ContractUtils.RequiresNotNull(initializers, "initializers");
return ListInit(newExpression, initializers as IEnumerable<Expression>);
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:11,代码来源:ListInitExpression.cs
示例15: Visit
public void Visit(NewExpression expression)
{
outStream.Write("new ");
expression.Function.Accept(this);
outStream.Write("(");
if (expression.Arguments.Count > 0)
{
expression.Arguments.First().Accept(this);
foreach (var a in expression.Arguments.Skip(1))
{
outStream.Write(", ");
a.Accept(this);
}
}
outStream.Write(")");
}
开发者ID:reshadi2,项目名称:mcjs,代码行数:19,代码来源:AstWriter.cs
示例16: NewExpressionProxy
public NewExpressionProxy(NewExpression node) {
_node = node;
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:3,代码来源:Expression.DebuggerProxy.cs
示例17: HandleNewExpression
static void HandleNewExpression(NewExpression nex,
ArgumentsResolutionResult res,
IEditorData Editor,
ResolutionContext ctxt,
IBlockNode curBlock,
IEnumerable<AbstractType> resultBases = null)
{
res.MethodIdentifier = nex;
CalculateCurrentArgument(nex, res, Editor.CaretLocation, ctxt);
var type = TypeDeclarationResolver.ResolveSingle(nex.Type, ctxt);
var _ctors = new List<AbstractType>();
if (type is AmbiguousType)
foreach (var t in (type as AmbiguousType).Overloads)
HandleNewExpression_Ctor(nex, curBlock, _ctors, t);
else
HandleNewExpression_Ctor(nex, curBlock, _ctors, type);
res.ResolvedTypesOrMethods = _ctors.ToArray();
}
开发者ID:Extrawurst,项目名称:D_Parser,代码行数:22,代码来源:ParameterInsightResolution.cs
示例18: Walk
// NewExpression
public virtual bool Walk(NewExpression node)
{
return true;
}
开发者ID:Alxandr,项目名称:IronTotem,代码行数:5,代码来源:TotemWalker.cs
示例19: Walk
// NewExpression
protected internal virtual bool Walk(NewExpression node) { return true; }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:2,代码来源:Walker.Generated.cs
示例20: ListInitExpression
internal ListInitExpression(NewExpression newExpression, ReadOnlyCollection<ElementInit> initializers) {
_newExpression = newExpression;
_initializers = initializers;
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:4,代码来源:ListInitExpression.cs
注:本文中的NewExpression类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论