Package caltrop.interpreter.ast

Examples of caltrop.interpreter.ast.Expression


        if (decls != null) {
            ExprEvaluator eval = new ExprEvaluator(_theContext, env);

            for (int i = 0; i < decls.length; i++) {
                String var = decls[i].getName();
                Expression valExpr = decls[i].getInitialValue();

                // Note: this assumes that declarations are
                // ordered by eager dependency
                Object value = (valExpr == null) ? _theContext.createNull()
                        : eval.evaluate(valExpr);
View Full Code Here


        Map result = new HashMap();

        for (int i = 0; i < inputPatterns.length; i++) {
            InputPattern inputPattern = inputPatterns[i];
            int repeatVal = -1; // no repeat expression.
            Expression repeatExpr = inputPattern.getRepeatExpr();
            boolean isList = ((repeatExpr == null) ? false : true);

            if (isList) {
                repeatVal = _context.intValue(_eval.evaluate(repeatExpr));
View Full Code Here

        final InputPattern[] inputPatterns = action.getInputPatterns();

        for (int i = 0; i < inputPatterns.length; i++) {
            final InputPattern inputPattern = inputPatterns[i];
            final String[] vars = inputPattern.getVariables();
            final Expression repExpr = inputPattern.getRepeatExpr();

            if (repExpr == null) {
                for (int j = 0; j < vars.length; j++) {
                    final InputChannel channel = ((InputPort) (inputPortMap
                            .get(inputPattern.getPortname()))).getChannel(0); // FIXME
                    local.bind(vars[j], new SingleTokenReaderThunk(channel, j));
                }
            } else {
                SimpleThunk repExprThunk = new SimpleThunk(repExpr, context,
                        local);
                local.bind(new EnvironmentKey(inputPattern.getPortname()),
                        repExprThunk);

                for (int j = 0; j < vars.length; j++) {
                    final InputChannel channel = ((InputPort) (inputPortMap
                            .get(inputPattern.getPortname()))).getChannel(0); // FIXME
                    local.bind(vars[j], new MultipleTokenReaderThunk(channel,
                            j, vars.length, repExprThunk, context));
                }
            }
        }

        final Decl[] decls = action.getDecls();

        for (int i = 0; i < decls.length; i++) {
            final Expression v = decls[i].getInitialValue();

            if (v == null) {
                local.bind(decls[i].getName(), null);
            } else {
                local.bind(decls[i].getName(), new SimpleThunk(v, context,
View Full Code Here

                .getOutputExpressions();

        for (int i = 0; i < outputExpressions.length; i++) {
            final OutputExpression outputExpression = outputExpressions[i];
            final Expression[] expressions = outputExpression.getExpressions();
            final Expression repeatExpr = outputExpression.getRepeatExpr();

            final OutputChannel channel = ((OutputPort) (outputPortMap
                    .get(outputExpression.getPortname()))).getChannel(0);

            // FIXME: handle multiports
View Full Code Here

    private Environment _bindActionStateVars(Decl[] decls, Environment env) {
        ExprEvaluator eval = new ExprEvaluator(_context, env);

        for (int i = 0; i < decls.length; i++) {
            Expression v = decls[i].getInitialValue();

            if (v == null) {
                env.bind(decls[i].getName(), null);
            } else {
                env.bind(decls[i].getName(), eval.evaluate(v));
View Full Code Here

            Map inputData, Environment env) {
        for (int i = 0; i < inputPatterns.length; i++) {
            InputPattern inputPattern = inputPatterns[i];
            ChannelID chID = new ChannelID(inputPattern.getPortname(), 0);
            List data = (List) inputData.get(chID);
            Expression repeatExpr = inputPattern.getRepeatExpr();

            if (repeatExpr == null) {
                String[] vars = inputPattern.getVariables();

                for (int j = 0; j < vars.length; j++) {
View Full Code Here

        Map data = new HashMap();
        ExprEvaluator eval = new ExprEvaluator(_context, env);

        for (int i = 0; i < outputExprs.length; i++) {
            OutputExpression outputExpr = outputExprs[i];
            Expression repeatExpr = outputExpr.getRepeatExpr();
            List results = new ArrayList();
            Expression[] exprs = outputExpr.getExpressions();

            if (repeatExpr == null) {
                for (int j = 0; j < exprs.length; j++) {
                    Expression expr = exprs[j];
                    results.add(eval.evaluate(expr));
                }
            } else {
                int repeatVal = _context.intValue(eval.evaluate(repeatExpr));
                List[] values = new List[exprs.length];
View Full Code Here

        return inputProfile;
    }

    private int numTokensNeeded(InputPattern ip) {
        int repeatVal = 1;
        Expression repeatExpr = ip.getRepeatExpr();

        if (repeatExpr != null) {
            repeatVal = _context.intValue(_eval.evaluate(repeatExpr));
        }
View Full Code Here

                Environment env = new DataMapEnvironment(inputPatterns,
                        dataSoFar, _env, _context);
                ExprEvaluator eval = new ExprEvaluator(_context, env);

                for (int j = 0; j < guardExprs.length; j++) {
                    Expression guardExpr = guardExprs[j];

                    try {
                        if (!_context.booleanValue(eval.evaluate(guardExpr))) {
                            guardVal = false;
                            break;
View Full Code Here

        InputPattern[] inputPatterns = action.getInputPatterns();

        for (int j = 0; j < inputPatterns.length; j++) {
            InputPattern inputPattern = inputPatterns[j];
            Expression repeatExpr = inputPattern.getRepeatExpr();
            int repeatVal = _computeRepeatExpression(repeatExpr, action);
            signature.addInputRate(inputPattern.getPortname(), inputPattern
                    .getVariables().length
                    * repeatVal);
        }

        OutputExpression[] outputexps = action.getOutputExpressions();

        for (int j = 0; j < outputexps.length; j++) {
            OutputExpression outputexp = outputexps[j];
            Expression repeatExpr = outputexp.getRepeatExpr();
            int repeatVal = _computeRepeatExpression(repeatExpr, action);
            signature.addOutputRate(outputexp.getPortname(), outputexp
                    .getExpressions().length
                    * repeatVal);
        }
View Full Code Here

TOP

Related Classes of caltrop.interpreter.ast.Expression

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.