Package joust.utils.tree.evaluation

Examples of joust.utils.tree.evaluation.Value


        }

        mHasMadeAChange = true;

        // To Values...
        Value operand = Value.of(((AJCLiteral) expr).getValue());
        AJCLiteral replacement = Value.unary(nodeTag, operand).toLiteral();

        try {
            tree.swapFor(replacement);
        } catch (NoSuchElementException e) {
View Full Code Here


        }

        mHasMadeAChange = true;

        // To Values...
        Value lValue = Value.of(((AJCLiteral) leftOperand).getValue());
        Value rValue = Value.of(((AJCLiteral) rightOperand).getValue());

        AJCLiteral replacement = Value.binary(nodeTag, lValue, rValue).toLiteral();

        try {
            tree.swapFor(replacement);
View Full Code Here

    protected void visitArrayAccess(AJCArrayAccess that) {
        super.visitArrayAccess(that);

        // If the index is something we can evaluate at compile-time, we're okay.
        EvaluationContext context = new EvaluationContext();
        Value index = context.evaluate(that.index);

        if (index == Value.UNKNOWN) {
            failureInducing = true;
            return;
        }

        // Might as well optimise it while we're at it...
        if (that.index instanceof AJCLiteral) {
            return;
        }

        that.index.swapFor(index.toLiteral());
    }
View Full Code Here

        }

        // Attempt to evaluate the loop management code ahead of time.
        EvaluationContext context = new EvaluationContext();
        context.evaluateStatements(tree.init);
        Value condition = context.evaluate(tree.cond);
        if (condition == Value.UNKNOWN) {
            log.debug("Abort: Condition unknown.");
            return;
        }

        if (!((Boolean) condition.getValue())) {
            log.debug("Instantly false for condition...");
            // Special case - the loop condition is initially false.
            // We can replace the loop with the init statements (Killing any that are variable initialisers or
            // depend thereon.
            AJCBlock block = tree.getEnclosingBlock();
            block.insertBefore(tree, tree.init);
            block.remove(tree);
            return;
        }

        int iterations = 0;
        while (iterations < UNROLL_LIMIT && condition != Value.UNKNOWN && (Boolean) condition.getValue()) {
            context.evaluateExpressionStatements(tree.step);
            log.debug("Status: \n{}", context);
            condition = context.evaluate(tree.cond);
            iterations++;
        }
View Full Code Here

        Symbol sym = tree.getTargetSymbol();
        if (!(sym instanceof VarSymbol)) {
            return;
        }

        Value knownValue = currentAssignments.get(sym);
        if (knownValue == null || knownValue == Value.UNKNOWN) {
            return;
        }

        AJCLiteral result = knownValue.toLiteral();
        mHasMadeAChange = true;
        log.info("Replacing {} with {}", tree, result);

        try {
            tree.swapFor(result);
View Full Code Here

             && (vSym.flags() & Flags.FINAL) != 0) {

                // Try to evaluate the initialiser expression now.
                // If the index is something we can evaluate at compile-time, we're okay.
                EvaluationContext context = new EvaluationContext();
                Value index = context.evaluate(varDef.getInit());

                if (index != Value.UNKNOWN) {
                    values.put(vSym, index);
                }
            }
View Full Code Here

TOP

Related Classes of joust.utils.tree.evaluation.Value

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.