本文整理汇总了C#中Mono.CSharp.SimpleName类的典型用法代码示例。如果您正苦于以下问题:C# SimpleName类的具体用法?C# SimpleName怎么用?C# SimpleName使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SimpleName类属于Mono.CSharp命名空间,在下文中一共展示了SimpleName类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoResolve
public override Expression DoResolve (ResolveContext ec)
{
eclass = ExprClass.Value;
// TODO: ec.GetSignatureForError ()
ConstructorBuilder caller_builder = ((Constructor) ec.MemberContext).ConstructorBuilder;
if (argument_list != null) {
bool dynamic;
//
// Spec mandates that constructor initializer will not have `this' access
//
using (ec.Set (ResolveContext.Options.BaseInitializer)) {
argument_list.Resolve (ec, out dynamic);
}
if (dynamic) {
SimpleName ctor = new SimpleName (ConstructorBuilder.ConstructorName, loc);
return new DynamicInvocation (ctor, argument_list, loc).Resolve (ec) as ExpressionStatement;
}
}
type = ec.CurrentType;
if (this is ConstructorBaseInitializer) {
if (ec.CurrentType.BaseType == null)
return this;
type = ec.CurrentType.BaseType;
if (TypeManager.IsStruct (ec.CurrentType)) {
ec.Report.Error (522, loc,
"`{0}': Struct constructors cannot call base constructors", TypeManager.CSharpSignature (caller_builder));
return this;
}
} else {
//
// It is legal to have "this" initializers that take no arguments
// in structs, they are just no-ops.
//
// struct D { public D (int a) : this () {}
//
if (TypeManager.IsStruct (ec.CurrentType) && argument_list == null)
return this;
}
base_constructor_group = MemberLookupFinal (
ec, null, type, ConstructorBuilder.ConstructorName, MemberTypes.Constructor,
BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly,
loc) as MethodGroupExpr;
if (base_constructor_group == null)
return this;
base_constructor_group = base_constructor_group.OverloadResolve (
ec, ref argument_list, false, loc);
if (base_constructor_group == null)
return this;
if (!ec.IsStatic)
base_constructor_group.InstanceExpression = ec.GetThis (loc);
ConstructorInfo base_ctor = (ConstructorInfo)base_constructor_group;
if (base_ctor == caller_builder){
ec.Report.Error (516, loc, "Constructor `{0}' cannot call itself", TypeManager.CSharpSignature (caller_builder));
}
return this;
}
示例2: Visit
public override object Visit(SimpleName simpleName)
{
var result = new IdentifierExpression();
result.AddChild(Identifier.Create(simpleName.Name, Convert(simpleName.Location)), Roles.Identifier);
AddTypeArguments(result, simpleName);
return result;
}
示例3: DoResolve
protected override Expression DoResolve (ResolveContext ec)
{
Expression clone = source.Clone (new CloneContext ());
clone = clone.Resolve (ec);
if (clone == null)
return null;
//
// A useful feature for the REPL: if we can resolve the expression
// as a type, Describe the type;
//
if (ec.Module.Evaluator.DescribeTypeExpressions && !(ec.CurrentAnonymousMethod is AsyncInitializer)) {
var old_printer = ec.Report.SetPrinter (new SessionReportPrinter ());
Expression tclone;
try {
// Note: clone context cannot be shared otherwise block mapping would leak
tclone = source.Clone (new CloneContext ());
tclone = tclone.Resolve (ec, ResolveFlags.Type);
if (ec.Report.Errors > 0)
tclone = null;
} finally {
ec.Report.SetPrinter (old_printer);
}
if (tclone is TypeExpr) {
Arguments args = new Arguments (1);
args.Add (new Argument (new TypeOf ((TypeExpr) clone, Location)));
return new Invocation (new SimpleName ("Describe", Location), args).Resolve (ec);
}
}
// This means its really a statement.
if (clone.Type.Kind == MemberKind.Void || clone is DynamicInvocation || clone is Assign) {
return clone;
}
source = clone;
var host = (Method) ec.MemberContext.CurrentMemberDefinition;
if (host.ParameterInfo.IsEmpty) {
eclass = ExprClass.Value;
type = InternalType.FakeInternalType;
return this;
}
target = new SimpleName (host.ParameterInfo[0].Name, Location);
return base.DoResolve (ec);
}
示例4: case_423
void case_423()
#line 3204 "cs-parser.jay"
{
var lt = (LocatedToken) yyVals[-1+yyTop];
yyVal = new SimpleName (lt.Value, (TypeArguments)yyVals[0+yyTop], lt.Location);
}
示例5: case_745
void case_745()
#line 5156 "cs-parser.jay"
{
Error_SyntaxError (yyToken);
var lt =(LocatedToken) yyVals[-1+yyTop];
var sn = new SimpleName (lt.Value, lt.Location);
current_block.AddStatement(new StatementErrorExpression (sn));
yyVal = null;
}
示例6: Create
public static AnonymousTypeClass Create (CompilerContext ctx, TypeContainer parent, IList<AnonymousTypeParameter> parameters, Location loc)
{
string name = ClassNamePrefix + types_counter++;
SimpleName [] t_args = new SimpleName [parameters.Count];
TypeParameterName [] t_params = new TypeParameterName [parameters.Count];
Parameter [] ctor_params = new Parameter [parameters.Count];
for (int i = 0; i < parameters.Count; ++i) {
AnonymousTypeParameter p = (AnonymousTypeParameter) parameters [i];
t_args [i] = new SimpleName ("<" + p.Name + ">__T", p.Location);
t_params [i] = new TypeParameterName (t_args [i].Name, null, p.Location);
ctor_params [i] = new Parameter (t_args [i], p.Name, 0, null, p.Location);
}
//
// Create generic anonymous type host with generic arguments
// named upon properties names
//
AnonymousTypeClass a_type = new AnonymousTypeClass (parent.NamespaceEntry.SlaveDeclSpace,
new MemberName (name, new TypeArguments (t_params), loc), parameters, loc);
if (parameters.Count > 0)
a_type.SetParameterInfo (null);
Constructor c = new Constructor (a_type, name, Modifiers.PUBLIC | Modifiers.DEBUGGER_HIDDEN,
null, new AnonymousParameters (ctx, ctor_params), null, loc);
c.Block = new ToplevelBlock (ctx, c.ParameterInfo, loc);
//
// Create fields and contructor body with field initialization
//
bool error = false;
for (int i = 0; i < parameters.Count; ++i) {
AnonymousTypeParameter p = (AnonymousTypeParameter) parameters [i];
Field f = new Field (a_type, t_args [i], Modifiers.PRIVATE | Modifiers.READONLY,
new MemberName ("<" + p.Name + ">", p.Location), null);
if (!a_type.AddField (f)) {
error = true;
continue;
}
c.Block.AddStatement (new StatementExpression (
new SimpleAssign (new MemberAccess (new This (p.Location), f.Name),
c.Block.GetParameterReference (p.Name, p.Location))));
ToplevelBlock get_block = new ToplevelBlock (ctx, p.Location);
get_block.AddStatement (new Return (
new MemberAccess (new This (p.Location), f.Name), p.Location));
Property prop = new Property (a_type, t_args [i], Modifiers.PUBLIC,
new MemberName (p.Name, p.Location), null);
prop.Get = new Property.GetMethod (prop, 0, null, p.Location);
prop.Get.Block = get_block;
a_type.AddProperty (prop);
}
if (error)
return null;
a_type.AddConstructor (c);
return a_type;
}
示例7: case_60
void case_60()
#line 746 "cs-parser.jay"
{
Error_SyntaxError (yyToken);
var lt = (LocatedToken) yyVals[-1+yyTop];
var tne = new SimpleName (lt.Value, null, lt.Location);
yyVal = new List<Attribute> () {
new Attribute (null, tne, null, GetLocation (yyVals[-1+yyTop]), false)
};
}
示例8: ResolveMemberAccess
public override MemberExpr ResolveMemberAccess (EmitContext ec, Expression left, Location loc, SimpleName original)
{
constant = TypeManager.GetGenericFieldDefinition (constant);
IConstant ic = TypeManager.GetConstant (constant);
if (ic == null) {
if (constant.IsLiteral) {
ic = new ExternalConstant (constant);
} else {
ic = ExternalConstant.CreateDecimal (constant);
// HACK: decimal field was not resolved as constant
if (ic == null)
return new FieldExpr (constant, loc).ResolveMemberAccess (ec, left, loc, original);
}
TypeManager.RegisterConstant (constant, ic);
}
return base.ResolveMemberAccess (ec, left, loc, original);
}
示例9: case_736
void case_736()
{
if (yyVals[-1+yyTop] is VarExpr)
yyVals[-1+yyTop] = new SimpleName ("var", ((VarExpr) yyVals[-1+yyTop]).Location);
yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]);
}
示例10: MakeTypeNameExpression
public ATypeNameExpression MakeTypeNameExpression(Location loc)
{
string[] names = Name.Split(new [] {'.'});
ATypeNameExpression exp = null;
for (var i = 0; i < names.Length; i++) {
var name = names[i];
if (exp == null) {
exp = new SimpleName (name, loc);
} else {
exp = new MemberAccess(exp, name, loc);
}
}
return exp;
}
示例11: case_526
void case_526()
{
var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
yyVal = new SimpleName (lt.Value, (int) yyVals[0+yyTop], lt.Location);
}
示例12: case_416
void case_416()
{
var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
yyVal = new SimpleName (lt.Value, (TypeArguments)yyVals[0+yyTop], lt.Location);
}
示例13: case_352
void case_352()
{
var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop];
yyVal = new SimpleName (lt.Value, (TypeArguments) yyVals[-1+yyTop], lt.Location);
lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop]));
}
示例14: case_527
void case_527()
#line 3805 "cs-parser.jay"
{
var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
yyVal = new SimpleName (lt.Value, (int) yyVals[0+yyTop], lt.Location);
}
示例15: Visit
public virtual object Visit (SimpleName simpleName)
{
return null;
}