本文整理汇总了C#中Mono.CSharp.TypeOf类的典型用法代码示例。如果您正苦于以下问题:C# TypeOf类的具体用法?C# TypeOf怎么用?C# TypeOf使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeOf类属于Mono.CSharp命名空间,在下文中一共展示了TypeOf类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Visit
public override object Visit(TypeOf typeOfExpression)
{
var result = new TypeOfExpression();
var location = LocationsBag.GetLocations(typeOfExpression);
result.AddChild(new CSharpTokenNode(Convert(typeOfExpression.Location), TypeOfExpression.TypeofKeywordRole), TypeOfExpression.TypeofKeywordRole);
if (location != null)
result.AddChild(new CSharpTokenNode(Convert(location [0]), Roles.LPar), Roles.LPar);
if (typeOfExpression.TypeExpression != null)
result.AddChild(ConvertToType(typeOfExpression.TypeExpression), Roles.Type);
if (location != null && location.Count > 1)
result.AddChild(new CSharpTokenNode(Convert(location [1]), Roles.RPar), Roles.RPar);
return result;
}
示例2: Visit
public override object Visit (TypeOf typeOfExpression)
{
var result = new TypeOfExpression ();
var location = LocationsBag.GetLocations (typeOfExpression);
result.AddChild (new CSharpTokenNode (Convert (typeOfExpression.Location), "typeof".Length), TypeOfExpression.Roles.Keyword);
result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), TypeOfExpression.Roles.LPar);
result.AddChild ((INode)typeOfExpression.TypeExpression.Accept (this), TypeOfExpression.Roles.ReturnType);
result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), TypeOfExpression.Roles.RPar);
return result;
}
示例3: Visit
public virtual object Visit (TypeOf typeOfExpression)
{
return null;
}
示例4: case_530
void case_530()
#line 3837 "cs-parser.jay"
{
lexer.TypeOfParsing = false;
yyVal = new TypeOf ((FullNamedExpression) yyVals[-1+yyTop], GetLocation (yyVals[-4+yyTop]));
lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop]));
}
示例5: yyparse
//.........这里部分代码省略.........
break;
case 522:
#line 3616 "cs-parser.jay"
{
yyVal = new ArrayInitializer ((List<Expression>) yyVals[-2+yyTop], GetLocation (yyVals[-3+yyTop]));
}
break;
case 523:
#line 3623 "cs-parser.jay"
{
var list = new List<Expression> (4);
list.Add ((Expression) yyVals[0+yyTop]);
yyVal = list;
}
break;
case 524:
#line 3629 "cs-parser.jay"
{
var list = (List<Expression>) yyVals[-2+yyTop];
list.Add ((Expression) yyVals[0+yyTop]);
yyVal = list;
}
break;
case 525:
#line 3635 "cs-parser.jay"
{
Error_SyntaxError (yyToken);
yyVal = new List<Expression> ();
}
break;
case 526:
#line 3643 "cs-parser.jay"
{
lexer.TypeOfParsing = true;
}
break;
case 527:
#line 3647 "cs-parser.jay"
{
lexer.TypeOfParsing = false;
Expression type = (Expression)yyVals[-1+yyTop];
if (type == TypeManager.system_void_expr)
yyVal = new TypeOfVoid (GetLocation (yyVals[-4+yyTop]));
else
yyVal = new TypeOf (type, GetLocation (yyVals[-4+yyTop]));
}
break;
case 530:
#line 3661 "cs-parser.jay"
{
Error_TypeExpected (lexer.Location);
yyVal = null;
}
break;
case 531:
#line 3669 "cs-parser.jay"
{
var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
yyVal = new SimpleName (lt.Value, (int) yyVals[0+yyTop], lt.Location);
}
break;
case 532:
#line 3675 "cs-parser.jay"
{
var lt1 = (Tokenizer.LocatedToken) yyVals[-2+yyTop];
示例6: case_522
void case_522()
{
lexer.TypeOfParsing = false;
yyVal = new TypeOf ((FullNamedExpression) yyVals[-1+yyTop], GetLocation (yyVals[-4+yyTop]));
lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop]));
}
示例7: yyparse
//.........这里部分代码省略.........
isInteraction = false;
}
var method = Method.Create (current_class, generic, (FullNamedExpression) yyVals[-7+yyTop], modifiers,
name, current_local_parameters, (Attributes) yyVals[-9+yyTop], yyVals[0+yyTop] != null);
if(current_container.Kind == MemberKind.Interface && current_extensionContainer != null){
var parameters = new List<Parameter>();
var typeExpression = new TypeExpression (compiler.BuiltinTypes.Object, GetLocation (yyVals[-9+yyTop]));
var parameter = new Parameter(typeExpression, "self", Parameter.Modifier.This, null, GetLocation(yyVals[-9+yyTop]));
parameters.Add(parameter);
parameters.Add(new Parameter(typeExpression, "ctx", Parameter.Modifier.NONE, null, GetLocation(yyVals[-9+yyTop])));
var clone = current_local_parameters.Clone();
for(var i = 0; i < clone.Count; i++){
parameters.Add(clone[i]);
}
var parameterTypeExpressions = parameters.Select(p=>p.TypeExpression).ToList();
var key = current_namespace.NS.Name + "," + name.Name + "," + string.Join(",",parameterTypeExpressions.Select(p => p.ToString()));
if(roleExtensionMethodDummies.Add(key)){
var returnType = (FullNamedExpression) yyVals[-7+yyTop];
var parametersCompiled = new ParametersCompiled(parameters.ToArray(),false);
var dummy = Method.Create (current_extensionContainer, generic, (FullNamedExpression) yyVals[-7+yyTop], Modifiers.PUBLIC | Modifiers.STATIC,
name, parametersCompiled, (Attributes) yyVals[-9+yyTop], yyVals[0+yyTop] != null);
var location = GetLocation(yyVals[-9+yyTop]);
var parameterName = new SimpleName("self", null, location);
var getTypeAccess = new MemberAccess(parameterName, "GetType", null, location);
var getTypeExpression = new Invocation(getTypeAccess, new Arguments(0));
var argCount = parameterTypeExpressions.Count-1;
var argumentsForGetMethod = new Arguments(2);
var stringLiteral = new StringLiteral(compiler.BuiltinTypes,name.Name,location);
argumentsForGetMethod.Add(new Argument(stringLiteral));
var typeName = new SimpleName("Type", null, location);
var types = parameterTypeExpressions.Skip(2)
.Select(t =>(Expression)(t.Type != null
? new TypeOf(t.Type,location)
: new TypeOf(t,location))
).ToList();
var initializer = new ArrayInitializer(types,location);
var parameterTypes = new ImplicitlyTypedArrayCreation (
new ComposedTypeSpecifier (1, location),
initializer,
location);
lbag.AddLocation (parameterTypes, location, location);
argumentsForGetMethod.Add(new Argument(parameterTypes));
var getMethodExpression = new Invocation(new MemberAccess(getTypeExpression,"GetMethod"),argumentsForGetMethod);
var argumentsForMethod = new Arguments(2);
var delegatedArguments = parameters.Skip(2).Select(p =>
(Expression)new Cast(
new TypeExpression(compiler.BuiltinTypes.Object,location),
new SimpleName(p.Name,location),
location)).ToList();
argumentsForMethod.Add(new Argument(new SimpleName("self", null, location)));
if(delegatedArguments.Any()){
initializer = new ArrayInitializer(delegatedArguments,location);
argumentsForMethod.Add(new Argument(new ImplicitlyTypedArrayCreation(
new ComposedTypeSpecifier (1, location),
initializer,
location)));
} else {
argumentsForMethod.Add(new Argument(new ArrayCreation(new TypeExpression(compiler.BuiltinTypes.Object,location),new ArrayInitializer(0,location))));
}
var invocation = new Invocation(new MemberAccess(getMethodExpression,"Invoke"),argumentsForMethod);
Statement statement = new StatementExpression(invocation);
示例8: case_528
void case_528()
#line 3607 "C:\Projects\Junk\mono\mcs\class\Mono.CSharp\..\..\mcs\cs-parser.jay"
{
lexer.TypeOfParsing = false;
yyVal = new TypeOf ((FullNamedExpression) yyVals[-1+yyTop], GetLocation (yyVals[-4+yyTop]));
lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop]));
}
示例9: case_557
void case_557()
#line 4042 "cs-parser.jay"
{
yyVal = new TypeOf ((FullNamedExpression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop]));
lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop]));
}