public ILanguageExpressionBasic Generate_BinaryEuclideanScalarProduct(GMacOpInfo opInfo, ILanguageExpression expr1, ILanguageExpression expr2) { SetOperands(expr1, expr2); VerifyOperation_ScalarProduct(); //The Euclidean products are metric-independent and the result is the same for orthogonal and non-orthogonal frames of the same dimension return (BasicBinary .CreatePrimitive(_resultType, opInfo.OpName, _atomicOperand1, _atomicOperand2)); }
public TreeNode Visit(BasicBinary expr) { var node = new TreeNode("<BINARY>" + expr.Operator.OperatorName) { Tag = expr }; node.Nodes.Add(expr.Operand1.AcceptVisitor(this)); node.Nodes.Add(expr.Operand2.AcceptVisitor(this)); return(node); }
public void Visit(BasicBinary expr) { Log.Append(expr.Operator.OperatorName); Log.Append("("); expr.Operand1.AcceptVisitor(this); Log.Append(", "); expr.Operand2.AcceptVisitor(this); Log.Append(")"); }
public ILanguageExpressionBasic Generate_OrthogonalBinaryProduct(GMacOpInfo opInfo) { var operandsMvType = _atomicOperand1.ExpressionType as GMacFrameMultivector; if (!( opInfo.IsMetricIndependent == false && GMacCompilerOptions.ForceOrthogonalMetricProducts && ReferenceEquals(operandsMvType, null) == false && operandsMvType.ParentFrame.IsDerivedFrame && operandsMvType.ParentFrame.AssociatedSymbolicFrame.IsNonOrthogonal )) { return(BasicBinary.CreatePrimitive(_resultType, opInfo.OpName, _atomicOperand1, _atomicOperand2)); } var omv1 = Context.ActiveParentCommandBlock.NonOrthogonalToOrthogonalMultivector( operandsMvType.ParentFrame, _atomicOperand1 ); var omv2 = Context.ActiveParentCommandBlock.NonOrthogonalToOrthogonalMultivector( operandsMvType.ParentFrame, _atomicOperand2 ); var mv = Context.ActiveParentCommandBlock.ExpressionToAtomicExpression( BasicBinary.CreatePrimitive( operandsMvType.ParentFrame.BaseFrame.MultivectorType, opInfo.OpName, omv1, omv2 ) ); return (Context.ActiveParentCommandBlock.OrthogonalToNonOrthogonalMultivectorTransform( operandsMvType.ParentFrame, mv )); }
public IEnumerable <SymbolLValue> GetLValues(BasicBinary expr) { var lvalues = GetLValues(expr.Operator); var operand1 = expr.Operand1 as LanguageValueAccess; if (operand1 != null) { lvalues = lvalues.Concat(operand1.AccessLValues); } var operand2 = expr.Operand2 as LanguageValueAccess; if (operand2 != null) { lvalues = lvalues.Concat(operand2.AccessLValues); } return(lvalues); }
public ILanguageExpression Generate_OrthogonalScalarProduct(GMacOpInfo opInfo) { var operandsMvType = _atomicOperand1.ExpressionType as GMacFrameMultivector; if (!( opInfo.IsMetricIndependent == false && GMacCompilerOptions.ForceOrthogonalMetricProducts && ReferenceEquals(operandsMvType, null) == false && operandsMvType.ParentFrame.IsDerivedFrame && operandsMvType.ParentFrame.AssociatedSymbolicFrame.IsNonOrthogonal )) { return(BasicBinary.CreatePrimitive(_resultType, opInfo.OpName, _atomicOperand1, _atomicOperand2)); } var omv1 = Context.ActiveParentCommandBlock.NonOrthogonalToOrthogonalMultivector( operandsMvType.ParentFrame, _atomicOperand1 ); var omv2 = Context.ActiveParentCommandBlock.NonOrthogonalToOrthogonalMultivector( operandsMvType.ParentFrame, _atomicOperand2 ); //There is no need to apply the base-to-derived outermorphsm because the scalar product always gives a scalar // and the outer morphism of any scalar is itself return (Context.ActiveParentCommandBlock.ExpressionToAtomicExpression( BasicBinary.CreatePrimitive( ScalarType, opInfo.OpName, omv1, omv2 ) )); }
internal static AstBinaryExpression ToAstBinaryExpression(this BasicBinary expr) { return(new AstBinaryExpression(expr)); }
/// <summary> /// Compute the value of the given language expression /// </summary> /// <param name="expr"></param> /// <returns></returns> public abstract ILanguageValue Visit(BasicBinary expr);
internal AstBinaryExpression(BasicBinary expr) { AssociatedBinaryExpression = expr; }