Package org.openquark.cal.internal.machine.g

Examples of org.openquark.cal.internal.machine.g.Node


    public Node doEvaluation (Node[] arguments, Executor executor)
            throws CALExecutorException {
      
        // Evaluate the 3 arguments.
        NRecordValue recordDictionary = (NRecordValue) executor.internalEvaluate(arguments[0]);
        Node genParams = executor.internalEvaluate(arguments[1]);
        Node independent = executor.internalEvaluate(arguments[2]);
       
        NValInt arbitraryMethodIndex = getIndexOfGenerateClassMethod(executor);
      
        List<String> fieldNames = recordDictionary.fieldNames();
        final int nFields = fieldNames.size();

        NRecordValue result=new NRecordValue(nFields);

        /*
         * Loops through all fields in the record dictionary and
         * invokes the arbitrary class method to
         * construct each record field
         */
        for (int i = 0; i < nFields; ++i) {
            genParams=executor.internalEvaluate(independent.apply( new NValInt(i)).apply(genParams));
           
            String fieldName = fieldNames.get(i);
            Node valueDictionaryThunk = recordDictionary.getValue(fieldName);
           
            result= result.insertRecordField(fieldName,
                executor.internalEvaluate(valueDictionaryThunk.apply(arbitraryMethodIndex).apply(genParams)));
        }
       
        return result;
    }
View Full Code Here


       
        // Evaluate the 3 arguments.
        NRecordValue recordDictionary = (NRecordValue) executor.internalEvaluate(arguments[0]);
        NRecordValue inputRecord = (NRecordValue) executor.internalEvaluate(arguments[1]);
        Node generator = executor.internalEvaluate(arguments[2]);
       
        NValInt coarbitraryMethodIndex = getIndexOfCoArbitraryClassMethod(executor);
      
        List<String> fieldNames = recordDictionary.fieldNames();
        final int nFields = fieldNames.size();

        Node result=generator;

        /*
         * loop through each element in the record and apply the coarbitrary
         * method to vary the input generator so that the resulting generator will be
         * depenedant on each of the fields in the input record.
         */
        for (int i = 0; i < nFields; ++i) {
           
            String fieldName = fieldNames.get(i);
            Node valueDictionaryThunk = recordDictionary.getValue(fieldName);
            Node value = inputRecord.getValue(fieldName);
           
            result=executor.internalEvaluate(valueDictionaryThunk.apply(coarbitraryMethodIndex).apply(value).apply(result));
        }
       
        return result;
View Full Code Here

       
        RecordValue resultMap = RecordValueImpl.make();
        for (int i = 0; i < nFields; ++i) {
           
            String fieldName = fieldNames.get(i);
            Node valueDictionaryThunk = recordDictionary.getValue(fieldName);
            Node xValueThunk = x.getValue(fieldName);           
           
            //compute "Prelude.output valueDictionaryThunk xValueThunk"
            //this is just (after inlining Prelude.output d = d"
            //valueDictionaryThunk xValueThunk
           
View Full Code Here

        ListParam(Node list) {
            calListValue = list;
        }

        Node getNext(Executor $ec) throws CALExecutorException {
            Node listItem; // this is the item used to generate the record
            // value
            calListValue = $ec.internalEvaluate(calListValue);
            switch (calListValue.getOrdinalValue()) {
            case 0: {
                // Prelude.Nil
View Full Code Here

       
        List<Object> resultList = new ArrayList<Object>(nFields);
        for (int i = 0; i < nFields; ++i) {
           
            String fieldName = fieldNames.get(i);
            Node valueDictionaryThunk = recordDictionary.getValue(fieldName);
            Node xValueThunk = x.getValue(fieldName);           
           
            //compute "Prelude.output valueDictionaryThunk xValueThunk"
            //this is just (after inlining Prelude.output d = d"
            //valueDictionaryThunk xValueThunk
           
View Full Code Here

        NRecordValue recordDictionary = (NRecordValue) executor.internalEvaluate(arguments[0]);
        NRecordValue x = (NRecordValue) executor.internalEvaluate(arguments[1]);
        NRecordValue y = (NRecordValue) executor.internalEvaluate(arguments[2]);
       
        // Get the index of the compare class method in the Ord type class.
        Node classMethodIndex = getIndexOfCompareClassMethod(executor);
       
        List<String> fieldNames = recordDictionary.fieldNames();
        final int nFields = fieldNames.size();
       
        for (int i = 0; i < nFields; ++i) {
           
            String fieldName = fieldNames.get(i);
            Node valueDictionaryThunk = recordDictionary.getValue(fieldName);
            Node xValueThunk = x.getValue(fieldName);
            Node yValueThunk = y.getValue(fieldName);
           
            Node ap = valueDictionaryThunk.apply(classMethodIndex).apply(xValueThunk).apply(yValueThunk);
           
            int compareResult = executor.internalEvaluate(ap).getOrdinalValue ();
           
            switch (compareResult) {
                case 0 :
View Full Code Here

        //extendRecordOrdinalPrimitive recordValue fieldName fieldValue
        NRecordValue recordValue = (NRecordValue) executor.internalEvaluate(arguments[0]);
        int fieldOrdinal = ((NValInt)executor.internalEvaluate(arguments[1])).getIntValue();
        String fieldName = "#" + fieldOrdinal;
        Node fieldValue = arguments[2];
       
        return recordValue.insertRecordField(fieldName, fieldValue);
    }
View Full Code Here

            paramSources.add(RecordParamHelper.create(recordValue.getNthValue(i), executor));
        }
        for (int i = 0; i < nFields; ++i) {
           
            Node fieldDict = recordDict.getNthValue(i);           
            Node elem;

            if (index.getIntValue() == -1)
                elem = fieldDict;
            else
                elem = fieldDict.apply(index);
           
            //fill f's arguments using the param sources.
            for(RecordParamHelper param : paramSources) {
                elem = elem.apply(param.getNext(executor));
            }
            String fieldName = fieldNames.get(i);
            result= result.insertRecordField(fieldName, executor.internalEvaluate(elem));
        }
       
View Full Code Here

        final int nFields = fieldNames.size();
       
        for (int i = 0; i < nFields; ++i) {
           
            String fieldName = fieldNames.get(i);
            Node valueDictionaryThunk = recordDictionary.getValue(fieldName);
            Node xValueThunk = x.getValue(fieldName);
            Node yValueThunk = y.getValue(fieldName);
           
            //compute "Prelude.equals valueDictionaryThunk xValueThunk yValueThunk"
            //this is just (after inlining Prelude.equals d = d classMethodIndex"
           
            if (!((NValBoolean)executor.internalEvaluate(valueDictionaryThunk.apply(classMethodIndex).apply(xValueThunk).apply(yValueThunk))).getBooleanValue()) {
View Full Code Here

        final int nFields = fieldNames.size();
               
        for (int i = 0; i < nFields; ++i) {
           
            final String fieldName = fieldNames.get(i);
            final Node fieldValue = record.getValue(fieldName);
            final Node evaluatedFieldValue = executor.internalEvaluate(fieldValue);
            if (fieldValue != evaluatedFieldValue) {
                //remove indirections
                record.putValue(fieldName, evaluatedFieldValue);
            }
        }
View Full Code Here

TOP

Related Classes of org.openquark.cal.internal.machine.g.Node

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.