Package org.openquark.cal.compiler.SourceModel

Examples of org.openquark.cal.compiler.SourceModel.Expr


        if (marshaler == null) {
            throw (new NullPointerException ("The marshaler must be non-null for an OutputPolicy."));
        }
       
        //parse the marshaler
        Expr marshalerExpr = SourceModelUtilities.TextParsing.parseExprIntoSourceModel(marshaler);
       
        if (marshalerExpr == null) {
            throw (new IllegalArgumentException("The marshaler cannot be parsed: " + marshaler));
        }
       
View Full Code Here


        /** {@inheritDoc} */
        @Override
        public Void visit_Expr_Lambda(Lambda lambda, Object arg) {
            boolean isRedundant = false;

            Expr lambdaExp = getExprWithoutParen(lambda.getDefiningExpr());
           
            if(lambdaExp instanceof Application) {
                Application definingExpr = (Application)lambdaExp;
                isRedundant = (definingExpr.getNExpressions() >= lambda.getNParameters() + 1);
               
View Full Code Here

         * @param functionName name of the function to check
         * @param functionEntity Function corresponding to the function to check
         */
        private void checkForMismatchedAliasPlings(Algebraic algebraic, String functionName, Function functionEntity) {
           
            Expr definingExpr = algebraic.getDefiningExpr();
            Expr aliasedEntityExpr = null;
           
            boolean isPotentialAlias = false;
            if(definingExpr instanceof Application) {
                Application application = (Application)definingExpr;
                aliasedEntityExpr = application.getNthExpression(0);
View Full Code Here

       
        /** {@inheritDoc} */
        @Override
        public Void visit_Expr_Application(Application application, Object arg) {

            Expr consumerExpr = application.getNthExpression(0);
            Name.Qualifiable consumerName = getTopLevelConsumerName(consumerExpr);
            FunctionalAgent consumerEntity = null;
           
            if(consumerName != null && consumerExpr instanceof Var) {
                consumerEntity = super.getFunctionalAgent(consumerName);
            }
           
            // Process the standard case where an expression with a statically-identifiable consumer name
            // accepts some arguments
            if(consumerName != null) {
                for(int i = 1; i < application.getNExpressions(); i++) {
                    processArgumentExpression(consumerName, i, application.getNthExpression(i));
                }
            }
           
            // Special cases for apply and compose calls
            if(consumerEntity != null) {
               
                // `apply arg1 arg2` is effectively `arg1 arg2`
                if(consumerEntity.getName().equals(APPLY)) {
                    Expr effectiveConsumer = application.getNthExpression(1);
                    Name.Qualifiable effectiveConsumerName = getTopLevelConsumerName(effectiveConsumer);
                   
                    if(effectiveConsumerName != null) {
                        processArgumentExpression(effectiveConsumerName, 1, application.getNthExpression(2));
                    }
                }
               
                // `compose arg1 arg2 arg3 ... argn` is effectively `arg1 (arg2 arg3 ... argn)`
                if(consumerEntity.getName().equals(COMPOSE)) {
                    Expr effectiveConsumer1 = application.getNthExpression(1);
                    Name.Qualifiable effectiveConsumer1Name = getTopLevelConsumerName(effectiveConsumer1);
                    Expr effectiveConsumer2 = application.getNthExpression(2);
                    Name.Qualifiable effectiveConsumer2Name = getTopLevelConsumerName(effectiveConsumer2);
                   
                    if(effectiveConsumer1Name != null) {
                        processArgumentExpression(effectiveConsumer1Name, 1, effectiveConsumer2);
                    }
View Full Code Here

        }
       
        /** {@inheritDoc} */
        @Override
        public Void visit_Expr_BinaryOp_BackquotedOperator_Var(BackquotedOperator.Var backquotedOperator, Object arg) {
            Expr consumerExpr = backquotedOperator.getOperatorVarExpr();
            Name.Qualifiable consumerName = getTopLevelConsumerName(consumerExpr);

            processArgumentExpression(consumerName, 1, backquotedOperator.getLeftExpr());
            processArgumentExpression(consumerName, 2, backquotedOperator.getRightExpr());
           
View Full Code Here

        }
       
        /** {@inheritDoc} */
        @Override
        public Void visit_Expr_BinaryOp_BackquotedOperator_DataCons(BackquotedOperator.DataCons backquotedOperator, Object arg) {
            Expr consumerExpr = backquotedOperator.getOperatorDataConsExpr();
            Name.Qualifiable consumerName = getTopLevelConsumerName(consumerExpr);

            processArgumentExpression(consumerName, 1, backquotedOperator.getLeftExpr());
            processArgumentExpression(consumerName, 2, backquotedOperator.getRightExpr());
           
View Full Code Here

         * @return Name of the consumer represented by the expression if statically determinable,
         *          or null otherwise. 
         */
        private Name.Qualifiable getTopLevelConsumerName(Expr arg) {
           
            Expr potentialConsumer;
            //we ignore paren expressions and just consider their contents           
            if (arg instanceof Parenthesized) {
                potentialConsumer = ((Parenthesized)arg).getExpression();
            } else {
                potentialConsumer = arg;
View Full Code Here

        private void processArgumentExpression(Name.Qualifiable consumerName, int argumentNumber, Expr argument) {
           
            FunctionalAgent producer = null;
            FunctionalAgent consumer = super.getFunctionalAgent(consumerName);
           
            Expr argumentExpression;
            //we ignore paren expressions and just consider their contents           
            if (argument instanceof Parenthesized) {
                argumentExpression = ((Parenthesized)argument).getExpression();
            } else {
                argumentExpression = argument;
View Full Code Here

            }
            TypeExpr[] dcFieldTypes = getFieldTypesForDC(dc);

            SourceModel.Expr.Var input = Expr.Var.make(CAL_Prelude.Functions.input);
           
            Expr unsafeCoerce = Expr.Var.make(Name.Function.make(CAL_Prelude.Functions.unsafeCoerce));

            // We need a cast function from JObject to the foreign inner class if there are fields
            // in the inner class.
            SourceModel.LocalDefn localDefns[] = null;
            Expr.Var argCastToInnerJType = null;
View Full Code Here

                        TypeSignature.make(foreignTypeExprDefn));
           
           
            String castFunctionName = makeCastFunction(outerForeignTypeName, innerForeignTypeName);

            Expr letVarDef =
                Expr.Application.make(
                        new Expr[]{
                                Expr.Var.make(Name.Function.makeUnqualified(castFunctionName)),
                                Expr.Var.makeUnqualified(outerTypeVarName)});
           
View Full Code Here

TOP

Related Classes of org.openquark.cal.compiler.SourceModel.Expr

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.