本文整理汇总了C#中JSBinaryOperatorExpression类的典型用法代码示例。如果您正苦于以下问题:C# JSBinaryOperatorExpression类的具体用法?C# JSBinaryOperatorExpression怎么用?C# JSBinaryOperatorExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JSBinaryOperatorExpression类属于命名空间,在下文中一共展示了JSBinaryOperatorExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: VisitNode
public void VisitNode(JSBinaryOperatorExpression boe)
{
var leftType = boe.Left.GetExpectedType(TypeSystem);
var leftIsEnum = ILBlockTranslator.IsEnum(leftType);
var rightType = boe.Right.GetExpectedType(TypeSystem);
var rightIsEnum = ILBlockTranslator.IsEnum(rightType);
if ((leftIsEnum || rightIsEnum) && LogicalOperators.Contains(boe.Operator)) {
if (leftIsEnum) {
var cast = JSInvocationExpression.InvokeMethod(
new JSFakeMethod("valueOf", TypeSystem.Int32, leftType), boe.Left, null, true
);
boe.ReplaceChild(boe.Left, cast);
}
if (rightIsEnum) {
var cast = JSInvocationExpression.InvokeMethod(
new JSFakeMethod("valueOf", TypeSystem.Int32, rightType), boe.Right, null, true
);
boe.ReplaceChild(boe.Right, cast);
}
}
VisitChildren(boe);
}
开发者ID:Caspeco,项目名称:JSIL,代码行数:27,代码来源:IntroduceEnumCasts.cs
示例2: VisitNode
public void VisitNode(JSBinaryOperatorExpression boe)
{
if (boe.Operator == JSOperator.Assignment)
SeenAssignments.Add(boe);
VisitChildren(boe);
}
开发者ID:poizan42,项目名称:JSIL,代码行数:7,代码来源:OptimizeArrayEnumerators.cs
示例3: DeconstructMutationAssignment
public static JSExpression DeconstructMutationAssignment (
JSNode parentNode, JSBinaryOperatorExpression boe, TypeSystem typeSystem, TypeReference intermediateType
) {
var assignmentOperator = boe.Operator as JSAssignmentOperator;
if (assignmentOperator == null)
return null;
JSBinaryOperator replacementOperator;
if (!IntroduceEnumCasts.ReverseCompoundAssignments.TryGetValue(assignmentOperator, out replacementOperator))
return null;
var leftType = boe.Left.GetActualType(typeSystem);
var newBoe = new JSBinaryOperatorExpression(
JSOperator.Assignment, MakeLhsForAssignment(boe.Left),
new JSBinaryOperatorExpression(
replacementOperator, boe.Left, boe.Right, intermediateType
),
leftType
);
var result = ConvertReadExpressionToWriteExpression(newBoe, typeSystem);
if (parentNode is JSExpressionStatement) {
return result;
} else {
var comma = new JSCommaExpression(
newBoe, boe.Left
);
return comma;
}
}
开发者ID:TukekeSoft,项目名称:JSIL,代码行数:31,代码来源:DecomposeMutationOperators.cs
示例4: IsPropertyAccess
public bool IsPropertyAccess(
JSBinaryOperatorExpression boe, out JSPropertyAccess pa
)
{
pa = boe.Left as JSPropertyAccess;
return pa != null;
}
开发者ID:nateleroux,项目名称:JSIL,代码行数:7,代码来源:OptimizePropertyMutationAssignments.cs
示例5: VisitNode
public void VisitNode(JSBinaryOperatorExpression boe)
{
var leftType = boe.Left.GetActualType(TypeSystem);
var rightType = boe.Right.GetActualType(TypeSystem);
var leftIsBool = (leftType.FullName == "System.Boolean");
var rightIsBool = (rightType.FullName == "System.Boolean");
var leftIsNumeric = TypeUtil.IsNumericOrEnum(leftType);
var rightIsNumeric = TypeUtil.IsNumericOrEnum(rightType);
if (
(leftIsBool != rightIsBool) &&
(leftIsNumeric || rightIsNumeric) &&
!(boe.Operator is JSAssignmentOperator)
) {
JSBinaryOperatorExpression replacement;
if (leftIsBool)
replacement = new JSBinaryOperatorExpression(
boe.Operator, CastToInteger(boe.Left), boe.Right, boe.ActualType
);
else
replacement = new JSBinaryOperatorExpression(
boe.Operator, boe.Left, CastToInteger(boe.Right), boe.ActualType
);
ParentNode.ReplaceChild(boe, replacement);
VisitReplacement(replacement);
} else {
VisitChildren(boe);
}
}
开发者ID:shreedharcva,项目名称:JSIL,代码行数:33,代码来源:HandleBooleanAsInteger.cs
示例6: IsPropertySetterInvocation
public static bool IsPropertySetterInvocation(JSNode parentNode, JSBinaryOperatorExpression boe, out JSPropertyAccess pa)
{
var isValidParent =
(parentNode is JSExpressionStatement);
pa = boe.Left as JSPropertyAccess;
return (pa != null) &&
pa.IsWrite &&
(boe.Operator == JSOperator.Assignment) &&
isValidParent &&
CanConvertToInvocation(pa);
}
开发者ID:snuderl,项目名称:JSIL,代码行数:13,代码来源:ConvertPropertyAccessesToInvocations.cs
示例7: ConvertReadExpressionToWriteExpression
// Decomposing a compound assignment can leave us with a read expression on the left-hand side
// if the compound assignment was targeting a pointer or a reference.
// We fix this by converting the mundane binary operator expression representing the assignment
// into a specialized one that represents a pointer write or reference write.
private static JSBinaryOperatorExpression ConvertReadExpressionToWriteExpression (
JSBinaryOperatorExpression boe, TypeSystem typeSystem
) {
var rtpe = boe.Left as JSReadThroughPointerExpression;
if (rtpe != null)
return new JSWriteThroughPointerExpression(rtpe.Pointer, boe.Right, boe.ActualType, rtpe.OffsetInBytes);
var rtre = boe.Left as JSReadThroughReferenceExpression;
if (rtre != null)
return new JSWriteThroughReferenceExpression(rtre.Variable, boe.Right);
return boe;
}
开发者ID:TukekeSoft,项目名称:JSIL,代码行数:18,代码来源:DecomposeMutationOperators.cs
示例8: MakeUnaryMutation
private JSBinaryOperatorExpression MakeUnaryMutation (
JSExpression expressionToMutate, JSBinaryOperator mutationOperator,
TypeReference type
) {
var newValue = new JSBinaryOperatorExpression(
mutationOperator, expressionToMutate, JSLiteral.New(1),
type
);
var assignment = new JSBinaryOperatorExpression(
JSOperator.Assignment,
MakeLhsForAssignment(expressionToMutate), newValue, type
);
return assignment;
}
开发者ID:BrainSlugs83,项目名称:JSIL,代码行数:15,代码来源:DecomposeMutationOperators.cs
示例9: VisitNode
public void VisitNode (JSBinaryOperatorExpression boe) {
JSPropertyAccess pa;
JSAssignmentOperator assignmentOperator;
JSBinaryOperator newOperator;
if (
IsPropertyAccess(boe, out pa) &&
((assignmentOperator = boe.Operator as JSAssignmentOperator) != null) &&
IntroduceEnumCasts.ReverseCompoundAssignments.TryGetValue(assignmentOperator, out newOperator)
) {
// FIXME: Terrible hack
var type = pa.GetActualType(TypeSystem);
var tempVariable = TemporaryVariable.ForFunction(
Stack.Last() as JSFunctionExpression, type
);
var replacement = new JSCommaExpression(
new JSBinaryOperatorExpression(
JSOperator.Assignment, tempVariable,
new JSBinaryOperatorExpression(
newOperator,
new JSPropertyAccess(
pa.ThisReference, pa.Property, false,
pa.TypeQualified,
pa.OriginalType, pa.OriginalMethod,
pa.IsVirtualCall
),
boe.Right, boe.GetActualType(TypeSystem)
), type
),
new JSBinaryOperatorExpression(
JSOperator.Assignment,
new JSPropertyAccess(
pa.ThisReference, pa.Property, true,
pa.TypeQualified,
pa.OriginalType, pa.OriginalMethod,
pa.IsVirtualCall
), tempVariable, type
),
tempVariable
);
ParentNode.ReplaceChild(boe, replacement);
VisitReplacement(replacement);
} else {
VisitChildren(boe);
}
}
开发者ID:Don191,项目名称:JSIL,代码行数:47,代码来源:OptimizePropertyMutationAssignments.cs
示例10: MakeUnaryMutation
public static JSBinaryOperatorExpression MakeUnaryMutation (
JSExpression expressionToMutate, JSBinaryOperator mutationOperator,
TypeReference type, TypeSystem typeSystem
) {
var newValue = new JSBinaryOperatorExpression(
mutationOperator, expressionToMutate, JSLiteral.New(1),
type
);
var assignment = new JSBinaryOperatorExpression(
JSOperator.Assignment,
MakeLhsForAssignment(expressionToMutate), newValue, type
);
assignment = ConvertReadExpressionToWriteExpression(assignment, typeSystem);
return assignment;
}
开发者ID:TukekeSoft,项目名称:JSIL,代码行数:17,代码来源:DecomposeMutationOperators.cs
示例11: VisitNode
public void VisitNode(JSBinaryOperatorExpression boe)
{
var resultType = boe.GetActualType(TypeSystem);
var resultIsIntegral = TypeUtil.Is32BitIntegral(resultType);
JSExpression replacement;
if (
resultIsIntegral &&
((replacement = DeconstructMutationAssignment(boe, TypeSystem, resultType)) != null)
) {
ParentNode.ReplaceChild(boe, replacement);
VisitReplacement(replacement);
return;
}
VisitChildren(boe);
}
开发者ID:poizan42,项目名称:JSIL,代码行数:18,代码来源:DecomposeMutationOperators.cs
示例12: VisitNode
public void VisitNode(JSUnaryOperatorExpression uoe)
{
var isBoolean = TypeUtil.IsBoolean(uoe.GetActualType(TypeSystem));
if (isBoolean) {
if (uoe.Operator == JSOperator.IsTrue) {
ParentNode.ReplaceChild(
uoe, uoe.Expression
);
VisitReplacement(uoe.Expression);
return;
} else if (uoe.Operator == JSOperator.LogicalNot) {
var nestedUoe = uoe.Expression as JSUnaryOperatorExpression;
var boe = uoe.Expression as JSBinaryOperatorExpression;
JSBinaryOperator newOperator;
if ((boe != null) &&
InvertedOperators.TryGetValue(boe.Operator, out newOperator)
) {
var newBoe = new JSBinaryOperatorExpression(
newOperator, boe.Left, boe.Right, boe.ActualType
);
ParentNode.ReplaceChild(uoe, newBoe);
VisitReplacement(newBoe);
return;
} else if (
(nestedUoe != null) &&
(nestedUoe.Operator == JSOperator.LogicalNot)
) {
var nestedExpression = nestedUoe.Expression;
ParentNode.ReplaceChild(uoe, nestedExpression);
VisitReplacement(nestedExpression);
return;
}
}
}
VisitChildren(uoe);
}
开发者ID:nateleroux,项目名称:JSIL,代码行数:44,代码来源:SimplifyOperators.cs
示例13: VisitNode
public void VisitNode (JSWriteThroughPointerExpression wtpe) {
JSExpression newPointer, offset;
if (ExtractOffsetFromPointerExpression(wtpe.Left, TypeSystem, out newPointer, out offset)) {
// HACK: Is this right?
if (wtpe.OffsetInBytes != null)
offset = new JSBinaryOperatorExpression(JSOperator.Add, wtpe.OffsetInBytes, offset, TypeSystem.Int32);
var replacement = new JSWriteThroughPointerExpression(newPointer, wtpe.Right, wtpe.ActualType, offset);
ParentNode.ReplaceChild(wtpe, replacement);
VisitReplacement(replacement);
} else if (JSPointerExpressionUtil.UnwrapExpression(wtpe.Pointer) is JSBinaryOperatorExpression) {
var replacement = new JSUntranslatableExpression("Write through confusing pointer " + wtpe.Pointer);
ParentNode.ReplaceChild(wtpe, replacement);
VisitReplacement(replacement);
} else {
VisitChildren(wtpe);
}
}
开发者ID:TukekeSoft,项目名称:JSIL,代码行数:19,代码来源:UnsafeCodeTransforms.cs
示例14: VisitNode
public void VisitNode (JSBinaryOperatorExpression boe) {
var isAssignment = boe.Operator == JSOperator.Assignment;
var leftVar = boe.Left as JSVariable;
if (
(leftVar != null) && isAssignment && !leftVar.IsParameter
) {
if (ToDeclare.Contains(leftVar) && !CouldntDeclare.Contains(leftVar) && !SeenAlready.Contains(leftVar)) {
var superParent = Stack.Skip(2).FirstOrDefault();
if ((superParent != null) && (ParentNode is JSStatement)) {
ToDeclare.Remove(leftVar);
ToReplace.Add(new KeyValuePair<JSNode, JSNode>(ParentNode, new JSVariableDeclarationStatement(boe)));
VisitChildren(boe);
return;
} else {
CouldntDeclare.Add(leftVar);
}
}
}
VisitChildren(boe);
}
开发者ID:GlennSandoval,项目名称:JSIL,代码行数:23,代码来源:IntroduceVariableDeclarations.cs
示例15: DeconstructMutationAssignment
public static JSBinaryOperatorExpression DeconstructMutationAssignment(
JSBinaryOperatorExpression boe, TypeSystem typeSystem, TypeReference intermediateType
)
{
var assignmentOperator = boe.Operator as JSAssignmentOperator;
if (assignmentOperator == null)
return null;
JSBinaryOperator replacementOperator;
if (!IntroduceEnumCasts.ReverseCompoundAssignments.TryGetValue(assignmentOperator, out replacementOperator))
return null;
var leftType = boe.Left.GetActualType(typeSystem);
var newBoe = new JSBinaryOperatorExpression(
JSOperator.Assignment, boe.Left,
new JSBinaryOperatorExpression(
replacementOperator, boe.Left, boe.Right, intermediateType
),
leftType
);
return ConvertReadExpressionToWriteExpression(newBoe, typeSystem);
}
开发者ID:poizan42,项目名称:JSIL,代码行数:24,代码来源:DecomposeMutationOperators.cs
示例16: VisitNode
public void VisitNode(JSBinaryOperatorExpression boe)
{
var leftType = boe.Left.GetExpectedType(TypeSystem);
var rightType = boe.Right.GetExpectedType(TypeSystem);
bool isArithmetic = !(boe.Operator is JSAssignmentOperator);
if ((leftType.FullName == "System.Char") && isArithmetic)
boe.ReplaceChild(boe.Left, CastToInteger(boe.Left));
if ((rightType.FullName == "System.Char") && isArithmetic)
boe.ReplaceChild(boe.Right, CastToInteger(boe.Right));
var parentInvocation = ParentNode as JSInvocationExpression;
JSDotExpression parentInvocationDot = (parentInvocation != null) ? parentInvocation.Method as JSDotExpression : null;
if (
isArithmetic &&
(boe.GetExpectedType(TypeSystem).FullName == "System.Char") &&
!(
(parentInvocation != null) &&
(parentInvocationDot != null) &&
(parentInvocationDot.Target is JSStringIdentifier) &&
(((JSStringIdentifier)parentInvocationDot.Target).Identifier == "String") &&
(parentInvocationDot.Member is JSFakeMethod) &&
(((JSFakeMethod)parentInvocationDot.Member).Name == "fromCharCode")
)
) {
var castBoe = CastToChar(boe);
ParentNode.ReplaceChild(boe, castBoe);
VisitReplacement(castBoe);
} else {
VisitChildren(boe);
}
}
开发者ID:Caspeco,项目名称:JSIL,代码行数:36,代码来源:IntroduceCharCasts.cs
示例17: VisitNode
public void VisitNode(JSBinaryOperatorExpression boe)
{
JSExpression left;
if (!JSReferenceExpression.TryDereference(JSIL, boe.Left, out left))
left = boe.Left;
var leftVar = left as JSVariable;
var leftChangeType = left as JSChangeTypeExpression;
if (leftChangeType != null)
leftVar = leftChangeType.Expression as JSVariable;
if (
!(ParentNode is JSVariableDeclarationStatement) &&
(leftVar != null) &&
(leftVar.Identifier == Variable.Identifier)
) {
if (boe.Operator is JSAssignmentOperator) {
var replacement = new JSWriteThroughReferenceExpression(
Variable, boe.Right
);
ParentNode.ReplaceChild(boe, replacement);
VisitReplacement(replacement);
} else {
VisitChildren(boe);
}
} else if (ParentNode is JSVariableDeclarationStatement) {
// Don't walk through the left-hand side of variable declarations.
VisitChildren(
boe,
(node, name) => name != "Left"
);
} else {
VisitChildren(boe);
}
}
开发者ID:poizan42,项目名称:JSIL,代码行数:37,代码来源:IntroduceVariableReferences.cs
示例18: VisitNode
public void VisitNode(JSInvocationExpression ie)
{
var type = ie.JSType;
var method = ie.JSMethod;
var thisExpression = ie.ThisReference;
if (method != null) {
if (
(type != null) &&
(type.Type.FullName == "System.Object")
) {
switch (method.Method.Member.Name) {
case "GetType":
JSNode replacement;
var thisType = JSExpression.DeReferenceType(thisExpression.GetExpectedType(TypeSystem), false);
if ((thisType is GenericInstanceType) && thisType.FullName.StartsWith("System.Nullable")) {
replacement = new JSType(thisType);
} else {
replacement = JSIL.GetType(thisExpression);
}
ParentNode.ReplaceChild(ie, replacement);
VisitReplacement(replacement);
return;
}
} else if (
(type != null) &&
(type.Type.FullName.StartsWith("System.Nullable")) &&
(type.Type is GenericInstanceType)
) {
var t = (type.Type as GenericInstanceType).GenericArguments[0];
var @null = JSLiteral.Null(t);
var @default = new JSDefaultValueLiteral(t);
switch (method.Method.Member.Name) {
case ".ctor":
JSExpression value;
if (ie.Arguments.Count == 0) {
value = @null;
} else {
value = ie.Arguments[0];
}
var boe = new JSBinaryOperatorExpression(
JSOperator.Assignment, ie.ThisReference, value, type.Type
);
ParentNode.ReplaceChild(ie, boe);
VisitReplacement(boe);
break;
case "GetValueOrDefault":
var isNull = new JSBinaryOperatorExpression(
JSOperator.Equal, ie.ThisReference, @null, TypeSystem.Boolean
);
JSTernaryOperatorExpression ternary;
if (ie.Arguments.Count == 0) {
ternary = new JSTernaryOperatorExpression(
isNull, @default, ie.ThisReference, type.Type
);
} else {
ternary = new JSTernaryOperatorExpression(
isNull, ie.Arguments[0], ie.ThisReference, type.Type
);
}
ParentNode.ReplaceChild(ie, ternary);
VisitReplacement(ternary);
break;
default:
throw new NotImplementedException(method.Method.Member.FullName);
}
return;
} else if (
(type != null) &&
ILBlockTranslator.TypesAreEqual(TypeSystem.String, type.Type) &&
(method.Method.Name == "Concat")
) {
if (ie.Arguments.Count > 2) {
if (ie.Arguments.All(
(arg) => ILBlockTranslator.TypesAreEqual(
TypeSystem.String, arg.GetExpectedType(TypeSystem)
)
)) {
var boe = JSBinaryOperatorExpression.New(
JSOperator.Add,
ie.Arguments,
TypeSystem.String
);
ParentNode.ReplaceChild(
ie,
boe
);
VisitReplacement(boe);
//.........这里部分代码省略.........
开发者ID:secretrobotron,项目名称:JSIL,代码行数:101,代码来源:ReplaceMethodCalls.cs
示例19: VisitNode
public void VisitNode (JSBinaryOperatorExpression boe) {
if ((boe.Operator == JSOperator.Assignment) && (boe.Left.Equals(Variable))) {
// This is important because we could be eliminating an assignment that looks like:
// x = y = 5;
// And if we simply replace 'y = 5' with an null, everything is ruined.
if ((ParentNode is JSExpressionStatement) || (ParentNode is JSVariableDeclarationStatement))
ParentNode.ReplaceChild(boe, new JSNullExpression());
else if (ParentNode != null)
ParentNode.ReplaceChild(boe, boe.Right);
} else {
VisitChildren(boe);
}
}
开发者ID:Don191,项目名称:JSIL,代码行数:13,代码来源:EliminateSingleUseTemporaries.cs
示例20: VisitNode
public void VisitNode (JSBinaryOperatorExpression boe) {
if (boe.Operator != JSOperator.Assignment) {
base.VisitNode(boe);
return;
}
GenericParameter relevantParameter;
if (IsCopyNeeded(boe.Right, out relevantParameter)) {
var rightVars = boe.Right.SelfAndChildrenRecursive.OfType<JSVariable>().ToArray();
// Even if the assignment target is never modified, if the assignment *source*
// gets modified, we need to make a copy here, because the target is probably
// being used as a back-up copy.
var rightVarsModified = (rightVars.Any((rv) => SecondPass.ModifiedVariables.Contains(rv.Name)));
var rightVarsAreReferences = rightVars.Any((rv) => rv.IsReference);
if (
(rightVarsModified ||
IsCopyNeededForAssignmentTarget(boe.Left) ||
rightVarsAreReferences) &&
!IsCopyAlwaysUnnecessaryForAssignmentTarget(boe.Left)
) {
if (Tracing)
Debug.WriteLine(String.Format("struct copy introduced for assignment rhs {0}", boe.Right));
boe.Right = MakeCopyForExpression(boe.Right, relevantParameter);
} else {
if (Tracing)
Debug.WriteLine(String.Format("struct copy elided for assignment rhs {0}", boe.Right));
}
} else {
if (Tracing)
Debug.WriteLine(String.Format("no copy needed for assignment rhs {0}", boe.Right));
}
VisitChildren(boe);
}
开发者ID:rangerofthewest,项目名称:JSIL,代码行数:38,代码来源:EmulateStructAssignment.cs
注:本文中的JSBinaryOperatorExpression类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论