本文整理汇总了C#中CastExpression类的典型用法代码示例。如果您正苦于以下问题:C# CastExpression类的具体用法?C# CastExpression怎么用?C# CastExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CastExpression类属于命名空间,在下文中一共展示了CastExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: VisitCastExpression
public override void VisitCastExpression (CastExpression castExpression)
{
base.VisitCastExpression (castExpression);
VisitTypeCastExpression (castExpression, ctx.Resolve (castExpression.Expression).Type,
ctx.ResolveType (castExpression.Type));
}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:7,代码来源:CastExpressionOfIncompatibleTypeIssue.cs
示例2: VisitCastExpression
public override void VisitCastExpression (CastExpression castExpression)
{
base.VisitCastExpression (castExpression);
CheckTypeCast (castExpression, castExpression.Expression, castExpression.StartLocation,
castExpression.Expression.StartLocation);
}
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:7,代码来源:RedundantTypeCastIssue.cs
示例3: Visit
public ISymbolValue Visit(CastExpression ce)
{
var toCast = ce.UnaryExpression != null ? ce.UnaryExpression.Accept (this) : null;
var targetType = ce.Type != null ? TypeDeclarationResolver.ResolveSingle(ce.Type, ctxt) : null;
var pv = toCast as PrimitiveValue;
var pt = targetType as PrimitiveType;
if (pv != null && pt != null) {
//TODO: Truncate value bytes if required and/or treat Value/ImaginaryPart in any way!
return new PrimitiveValue(pt.TypeToken, pv.Value, pv.ImaginaryPart, pt.Modifier);
}
// TODO: Convert actual object
return null;
}
开发者ID:DinrusGroup,项目名称:D_Parser,代码行数:15,代码来源:Evaluation.UnaryExpressions.cs
示例4: VisitCastExpression
public override void VisitCastExpression(CastExpression castExpression)
{
base.VisitCastExpression(castExpression);
var expression = castExpression.Expression;
if (expression is ParenthesizedExpression)
expression = (expression as ParenthesizedExpression).Expression;
object value = null;
if (expression is PrimitiveExpression)
value = (expression as PrimitiveExpression).Value;
else if (expression is UnaryOperatorExpression &&
(expression as UnaryOperatorExpression).Expression is PrimitiveExpression)
{
var primitive = (expression as UnaryOperatorExpression).Expression as PrimitiveExpression;
value = primitive.Value;
}
if (value != null)
{
var type = (castExpression.Type as PrimitiveType).KnownTypeCode;
if ((type == KnownTypeCode.Int16 && value is short) ||
(type == KnownTypeCode.Int32 && value is int) ||
(type == KnownTypeCode.Int64 && value is long) ||
(type == KnownTypeCode.UInt16 && value is ushort) ||
(type == KnownTypeCode.UInt32 && value is uint) ||
(type == KnownTypeCode.UInt64 && value is ulong) ||
(type == KnownTypeCode.Double && value is double) ||
(type == KnownTypeCode.Single && value is float) ||
(type == KnownTypeCode.String && value is string) ||
(type == KnownTypeCode.Boolean && value is bool) ||
(type == KnownTypeCode.Char && value is char) ||
(type == KnownTypeCode.Byte && value is byte) ||
(type == KnownTypeCode.SByte && value is sbyte) ||
(type == KnownTypeCode.Decimal && value is decimal))
{
castExpression.ReplaceWith(expression);
}
}
}
开发者ID:TreeSeed,项目名称:Tychaia,代码行数:40,代码来源:RemoveRedundantPrimitiveCastsVisitor.cs
示例5: Visit
public override object Visit (Cast castExpression)
{
var result = new CastExpression ();
var location = LocationsBag.GetLocations (castExpression);
result.AddChild (new CSharpTokenNode (Convert (castExpression.Location), 1), CastExpression.Roles.LPar);
if (castExpression.TargetType != null)
result.AddChild ((INode)castExpression.TargetType.Accept (this), CastExpression.Roles.ReturnType);
if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), CastExpression.Roles.RPar);
if (castExpression.Expr != null)
result.AddChild ((INode)castExpression.Expr.Accept (this), CastExpression.Roles.Expression);
return result;
}
开发者ID:pgoron,项目名称:monodevelop,代码行数:14,代码来源:CSharpParser.cs
示例6: VisitCastExpression
public virtual void VisitCastExpression (CastExpression castExpression)
{
VisitChildren (castExpression);
}
开发者ID:modulexcite,项目名称:ICSharpCode.Decompiler-retired,代码行数:4,代码来源:DepthFirstAstVisitor.cs
示例7: VisitCastExpression
public virtual void VisitCastExpression(CastExpression castExpression)
{
if (this.ThrowException)
{
throw (Exception)this.CreateException(castExpression);
}
}
开发者ID:fabriciomurta,项目名称:BridgeUnified,代码行数:7,代码来源:Visitor.Exception.cs
示例8: VisitCastExpression
public override void VisitCastExpression(CastExpression castExpression)
{
if (castExpression.RParToken != null) {
ForceSpacesAfter(castExpression.LParToken, policy.SpacesWithinCastParentheses);
ForceSpacesBefore(castExpression.RParToken, policy.SpacesWithinCastParentheses);
ForceSpacesAfter(castExpression.RParToken, policy.SpaceAfterTypecast);
}
base.VisitCastExpression(castExpression);
}
开发者ID:txdv,项目名称:monodevelop,代码行数:10,代码来源:AstFormattingVisitor.cs
示例9: Visit
public void Visit(CastExpression x)
{
}
开发者ID:DinrusGroup,项目名称:D_Parser,代码行数:4,代码来源:ParameterInsightResolution.cs
示例10: UnaryExpression
IExpression UnaryExpression(IBlockNode Scope = null)
{
switch (laKind)
{
// Note: PowExpressions are handled in PowExpression()
case BitwiseAnd:
case Increment:
case Decrement:
case Times:
case Minus:
case Plus:
case Not:
case Tilde:
Step();
SimpleUnaryExpression sue;
switch (t.Kind)
{
case BitwiseAnd:
sue = new UnaryExpression_And();
break;
case Increment:
sue = new UnaryExpression_Increment();
break;
case Decrement:
sue = new UnaryExpression_Decrement();
break;
case Times:
sue = new UnaryExpression_Mul();
break;
case Minus:
sue = new UnaryExpression_Sub();
break;
case Plus:
sue = new UnaryExpression_Add();
break;
case Tilde:
sue = new UnaryExpression_Cat();
break;
case Not:
sue = new UnaryExpression_Not();
break;
default:
SynErr(t.Kind, "Illegal token for unary expressions");
return null;
}
sue.Location = t.Location;
sue.UnaryExpression = UnaryExpression(Scope);
return sue;
// CastExpression
case Cast:
Step();
var ce = new CastExpression { Location= t.Location };
if (Expect(OpenParenthesis))
{
if (laKind != CloseParenthesis) // Yes, it is possible that a cast() can contain an empty type!
ce.Type = Type();
Expect(CloseParenthesis);
}
ce.UnaryExpression = UnaryExpression(Scope);
ce.EndLocation = t.EndLocation;
return ce;
// DeleteExpression
case Delete:
Step();
return new DeleteExpression() { UnaryExpression = UnaryExpression(Scope) };
// PowExpression
default:
var left = PostfixExpression(Scope);
if (laKind != Pow)
return left;
Step();
var pe = new PowExpression();
pe.LeftOperand = left;
pe.RightOperand = UnaryExpression(Scope);
return pe;
}
}
开发者ID:rainers,项目名称:D_Parser,代码行数:84,代码来源:Parser_Impl.cs
示例11: VisitCastExpression
public abstract StringBuilder VisitCastExpression(CastExpression castExpression, int data);
开发者ID:hach-que,项目名称:SLSharp,代码行数:1,代码来源:VisitorBase.Abstract.cs
示例12: Visit
public ISymbolValue Visit(CastExpression ce)
{
// TODO: Convert actual object
return null;
}
开发者ID:rainers,项目名称:D_Parser,代码行数:5,代码来源:Evaluation.UnaryExpressions.cs
示例13: VisitCastExpression
public override void VisitCastExpression(CastExpression castExpression)
{
new CastBlock(this, castExpression).Emit();
}
开发者ID:yindongfei,项目名称:bridge.lua,代码行数:4,代码来源:Emitter.Visitor.cs
示例14: UnaryExpression
IExpression UnaryExpression(IBlockNode Scope = null)
{
// Note: PowExpressions are handled in PowExpression()
if (laKind == (BitwiseAnd) || laKind == (Increment) ||
laKind == (Decrement) || laKind == (Times) ||
laKind == (Minus) || laKind == (Plus) ||
laKind == (Not) || laKind == (Tilde))
{
Step();
SimpleUnaryExpression ae = null;
switch (t.Kind)
{
case BitwiseAnd:
ae = new UnaryExpression_And();
break;
case Increment:
ae = new UnaryExpression_Increment();
break;
case Decrement:
ae = new UnaryExpression_Decrement();
break;
case Times:
ae = new UnaryExpression_Mul();
break;
case Minus:
ae = new UnaryExpression_Sub();
break;
case Plus:
ae = new UnaryExpression_Add();
break;
case Tilde:
ae = new UnaryExpression_Cat();
break;
case Not:
ae = new UnaryExpression_Not();
break;
}
LastParsedObject = ae;
ae.Location = t.Location;
ae.UnaryExpression = UnaryExpression(Scope);
return ae;
}
// ( Type ) . Identifier
if (laKind == OpenParenthesis)
{
var wkParsing = AllowWeakTypeParsing;
AllowWeakTypeParsing = true;
var curLA = la;
Step();
var td = Type();
AllowWeakTypeParsing = wkParsing;
if (td!=null && ((t.Kind!=OpenParenthesis && laKind == CloseParenthesis && Peek(1).Kind == Dot && Peek(2).Kind == Identifier) ||
(IsEOF || Peek(1).Kind==EOF || Peek(2).Kind==EOF))) // Also take it as a type declaration if there's nothing following (see Expression Resolving)
{
Step(); // Skip to )
Step(); // Skip to .
Step(); // Skip to identifier
var accExpr = new UnaryExpression_Type() { Type=td, AccessIdentifier=t.Value };
accExpr.Location = curLA.Location;
accExpr.EndLocation = t.EndLocation;
return accExpr;
}
else
{
// Reset the current token with the earlier one to enable Expression parsing
la = curLA;
Peek(1);
}
}
// CastExpression
if (laKind == (Cast))
{
Step();
var ae = new CastExpression { Location= t.Location };
if (Expect(OpenParenthesis))
{
if (laKind != CloseParenthesis) // Yes, it is possible that a cast() can contain an empty type!
ae.Type = Type();
Expect(CloseParenthesis);
}
ae.UnaryExpression = UnaryExpression(Scope);
ae.EndLocation = t.EndLocation;
//.........这里部分代码省略.........
开发者ID:gavin-norman,项目名称:Mono-D,代码行数:101,代码来源:Parser_Impl.cs
示例15: SimpleNonInvocationExpression
//.........这里部分代码省略.........
#line 1688 "VBNET.ATG"
pexpr = expr;
break;
}
case 81: case 93: case 204: {
#line 1690 "VBNET.ATG"
CastType castType = CastType.Cast;
if (la.kind == 93) {
lexer.NextToken();
} else if (la.kind == 81) {
lexer.NextToken();
#line 1692 "VBNET.ATG"
castType = CastType.Conversion;
} else if (la.kind == 204) {
lexer.NextToken();
#line 1693 "VBNET.ATG"
castType = CastType.TryCast;
} else SynErr(259);
Expect(25);
Expr(
#line 1695 "VBNET.ATG"
out expr);
Expect(12);
TypeName(
#line 1695 "VBNET.ATG"
out type);
Expect(26);
#line 1696 "VBNET.ATG"
pexpr = new CastExpression(type, expr, castType);
break;
}
case 63: case 64: case 65: case 66: case 67: case 68: case 70: case 72: case 73: case 77: case 78: case 79: case 80: case 82: case 83: case 84: {
CastTarget(
#line 1697 "VBNET.ATG"
out type);
Expect(25);
Expr(
#line 1697 "VBNET.ATG"
out expr);
Expect(26);
#line 1697 "VBNET.ATG"
pexpr = new CastExpression(type, expr, CastType.PrimitiveConversion);
break;
}
case 44: {
lexer.NextToken();
Expr(
#line 1698 "VBNET.ATG"
out expr);
#line 1698 "VBNET.ATG"
pexpr = new AddressOfExpression(expr);
break;
}
case 116: {
lexer.NextToken();
Expect(25);
GetTypeTypeName(
#line 1699 "VBNET.ATG"
out type);
开发者ID:mgagne-atman,项目名称:Projects,代码行数:67,代码来源:Parser.cs
示例16: VisitCXXMethodDecl
//.........这里部分代码省略.........
//
// Marshal from C# to C and the C support to call into C++
//
var invoke = new InvocationExpression(new IdentifierExpression(pinvoke_name));
if (!decl.IsStatic && !isConstructor)
invoke.Arguments.Add(new IdentifierExpression("handle"));
bool first = true;
int anonymousParameterNameCount = 1;
int currentParamCount = -1;
foreach (var param in decl.Parameters) {
currentParamCount++;
AstType pinvokeParameter, parameter;
WrapKind wrapKind;
if (!first) {
cinvoke.Append(", ");
cmethodBuilder.Append(", ");
} else
first = false;
LookupMarshalTypes(param.QualType, out pinvokeParameter, out pinvokeMod, out parameter, out methodMod, out wrapKind);
string paramName = param.Name;
if (string.IsNullOrEmpty(paramName))
paramName = "param" + (anonymousParameterNameCount++);
Expression parameterReference = new IdentifierExpression (paramName);
switch (currentType.Name) {
case "Input":
switch (decl.Name) {
case "GetMouseButtonDown":
case "GetMouseButtonPress":
parameter = new SimpleType ("MouseButton");
parameterReference = new CastExpression (new PrimitiveType ("int"), parameterReference);
break;
case "GetKeyPress":
case "GetKeyDown":
case "GetScancodeFromKey":
case "GetKeyName":
if (currentParamCount == 0 && paramName == "key") {
parameter = new SimpleType ("Key");
parameterReference = new CastExpression (new PrimitiveType ("int"), parameterReference);
}
break;
}
break;
case "VertexBuffer":
switch (decl.Name) {
case "SetSize":
if (currentParamCount == 1 && paramName == "elementMask") {
parameter = new SimpleType ("ElementMask");
parameterReference = new CastExpression (new PrimitiveType ("uint"), parameterReference);
}
break;
case "GetVertexSize":
if (currentParamCount == 0 && paramName == "elementMask") {
parameter = new SimpleType ("ElementMask");
parameterReference = new CastExpression (new PrimitiveType ("uint"), parameterReference);
}
break;
case "GetElementOffset":
if (currentParamCount == 0 && paramName == "elementMask") {
parameter = new SimpleType ("ElementMask");
parameterReference = new CastExpression (new PrimitiveType ("uint"), parameterReference);
}
break;
开发者ID:corefan,项目名称:urho,代码行数:67,代码来源:CxxBinder.cs
示例17: GenerateProperties
public void GenerateProperties()
{
foreach (var typeKV in ScanBaseTypes.allProperties) {
foreach (var propNameKV in typeKV.Value) {
foreach (var gs in propNameKV.Value.Values) {
Expression valueReference = new IdentifierExpression ("value");
Expression invokeGetter = new InvocationExpression (new IdentifierExpression (RemapMemberName (gs.Getter.Parent.Name, gs.Getter.Name)));
string pname = gs.Name;
Modifiers mods = 0;
switch (typeKV.Key) {
case "UIElement":
if (pname == "BringToFront")
pname = "BringToFrontOnFocus";
if (pname == "BringToBack")
pname = "BringToBackOnFocus";
if (pname == "SortChildren")
pname = "ShouldSortChildren";
break;
case "Menu":
if (pname == "ShowPopup")
pname = "IsPopupShown";
break;
case "File":
if (pname == "Handle")
pname = "FileHandle";
break;
case "Text":
if (pname == "Text")
pname = "Value";
break;
case "Sprite":
switch (pname) {
case "Position":
pname = "PositionFloat";
break;
default:
break;
}
break;
case "View":
#if false
// if false -> temporarily moved the apis to Application, not RefCounted, so there is currently
// no conflict
// View.Graphics is the Urho C++ strong type to GetSubssytem(Graphics)
if (pname == "Graphics" || pname == "Renderer")
mods = Modifiers.New;
#endif
break;
case "Camera":
switch (pname) {
case "ViewOverrideFlags":
gs.MethodReturn = new SimpleType ("ViewOverrideFlags");
valueReference = new CastExpression (new PrimitiveType ("uint"), valueReference);
invokeGetter = new CastExpression (new SimpleType ("ViewOverrideFlags"), invokeGetter);
break;
}
break;
case "VertexBuffer":
switch (pname) {
case "ElementMask":
gs.MethodReturn = new SimpleType ("ElementMask");
valueReference = new CastExpression (new PrimitiveType ("uint"), valueReference);
invokeGetter = new CastExpression (new SimpleType ("ElementMask"), invokeGetter);
break;
}
break;
}
var p = new PropertyDeclaration()
{
Name = pname,
ReturnType = gs.MethodReturn,
Modifiers = Modifiers.Public | (gs.Getter.IsStatic ? Modifiers.Static : 0) | mods
};
p.Getter = new Accessor()
{
Body = new BlockStatement() {
new ReturnStatement (invokeGetter)
}
};
if (gs.Setter != null) {
p.Setter = new Accessor()
{
Body = new BlockStatement()
{
new InvocationExpression (new IdentifierExpression (gs.Setter.Name), valueReference)
}
};
}
// We are unable to bind
if (gs.HostType == null)
continue;
gs.HostType.Members.Add(p);
var comments = StringUtil.GetMethodComments(gs.Getter);
//.........这里部分代码省略.........
开发者ID:corefan,项目名称:urho,代码行数:101,代码来源:CxxBinder.cs
示例18: VisitCastExpression
public void VisitCastExpression(CastExpression castExpression)
{
StartNode(castExpression);
WriteToken ("<", Roles.LPar);
Space(policy.SpacesWithinCastParentheses);
castExpression.Type.AcceptVisitor(this);
Space(policy.SpacesWithinCastParentheses);
WriteToken (">", Roles.LPar);
Space(policy.SpaceAfterTypecast);
castExpression.Expression.AcceptVisitor(this);
EndNode(castExpression);
}
开发者ID:cbsistem,项目名称:Netjs,代码行数:12,代码来源:TsOutputVisitor.cs
示例19: VisitCastExpression
public override StringBuilder VisitCastExpression(CastExpression castExpression, int data)
{
// TODO: validate the cast operation, this unfortunateley needs a way to evalulate
// the cast expressions type, which we still cant do properly with IC#..
// unlike c/c++ GLSL uses constructor syntax as float(intExpression) rather than
// a cast like expression as (float)intExpression.
var s = castExpression.Type.AcceptVisitor(this, data);
return s.Append("(").Append(castExpression.Expression.AcceptVisitor(this, data)).Append(")");
}
开发者ID:hach-que,项目名称:SLSharp,代码行数:10,代码来源:GlslVisitor.cs
示例20: CastBlock
public CastBlock(IEmitter emitter, CastExpression castExpression)
: base(emitter, castExpression)
{
this.Emitter = emitter;
this.CastExpression = castExpression;
}
开发者ID:Cestbienmoi,项目名称:Bridge,代码行数:6,代码来源:CastBlock.cs
注:本文中的CastExpression类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论