Package caltrop.interpreter

Examples of caltrop.interpreter.ChannelID


        if (pvi != null) {
            // try to find it. if we don't find it,
            // throw an UnboundPortVarException.
            String portName = pvi.getPortName();
            List data = (List) _dataFromInputPorts.get(new ChannelID(portName,
                    0));

            if (data == null) {
                throw new UnboundPortVarException(varName + "unbound.");
            }
View Full Code Here


        int i = 0;

        for (Iterator iterator = profile.keySet().iterator(); iterator
                .hasNext();) {
            ChannelID chID = (ChannelID) iterator.next();
            _indexToChannelID[i] = chID;
            _channelIDToIndex.put(chID, Integer.valueOf(i));
            i++;
        }
View Full Code Here

        }
    }

    private void updateState(Map data) {
        for (Iterator iterator = data.keySet().iterator(); iterator.hasNext();) {
            ChannelID channelID = (ChannelID) iterator.next();
            List l = (List) data.get(channelID);

            for (Iterator i2 = l.iterator(); i2.hasNext();) {
                Object o = i2.next();
                assert o instanceof Token;
            }
        }

        _data = data;
        _indexToChannelID = new ChannelID[data.keySet().size()];
        _channelIDToIndex.clear();
        _count = new int[_indexToChannelID.length];
        _resetCount();

        int i = 0;

        for (Iterator iterator = data.keySet().iterator(); iterator.hasNext();) {
            ChannelID chID = (ChannelID) iterator.next();
            _indexToChannelID[i] = chID;
            _channelIDToIndex.put(chID, Integer.valueOf(i));
            i++;
        }
    }
View Full Code Here

    private Environment _bindInputPatternVars(InputPattern[] inputPatterns,
            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();
View Full Code Here

                        results.add(values[k].get(j));
                    }
                }
            }

            data.put(new ChannelID(outputExprs[i].getPortname(), 0), results);
        }

        return data;
    }
View Full Code Here

            for (int i = 0; i < inputPatterns.length; i++) {
                InputPattern inputPattern = inputPatterns[i];
                numNeeded = numTokensNeeded(inputPattern);

                List data = (List) dataSoFar.get(new ChannelID(inputPattern
                        .getPortname(), 0));

                if (data != null) {
                    numNeeded = numNeeded - data.size();
                }

                if (numNeeded > 0) {
                    inputProfile.put(new ChannelID(inputPattern.getPortname(),
                            0), Integer.valueOf(numNeeded));
                }
            }

            return inputProfile;
        }

        InputPattern[] inputPatterns = actions[0].getInputPatterns();

        if (inputPatterns.length == 0) {
            // if the first action has no input patterns,
            // then the "intersection" will be empty.
            return inputProfile;
        }

        for (int i = 0; i < inputPatterns.length; i++) {
            InputPattern inputPattern = inputPatterns[i];
            numNeeded = numTokensNeeded(inputPattern);

            for (int j = 1; j < actions.length; j++) {
                InputPattern ip = getInputPattern(inputPattern.getPortname(),
                        actions[j]);

                if (ip == null) {
                    numNeeded = 0;
                    break;
                } else {
                    numNeeded = Math.min(numNeeded, numTokensNeeded(ip));

                    List data = (List) dataSoFar.get(new ChannelID(inputPattern
                            .getPortname(), 0));

                    if (data != null) {
                        numNeeded = numNeeded - data.size();
                    }
                }
            }

            if (numNeeded > 0) {
                inputProfile.put(new ChannelID(inputPattern.getPortname(), 0),
                        Integer.valueOf(numNeeded));
            }
        }

        return inputProfile;
View Full Code Here

    // oldData and newData are both Map: ChannelID -> List[Object]
    private void mergeData(Map oldData, Map newData) {
        for (Iterator iterator = newData.keySet().iterator(); iterator
                .hasNext();) {
            ChannelID chID = (ChannelID) iterator.next();

            if (oldData.containsKey(chID)) {
                ((List) oldData.get(chID)).addAll((List) newData.get(chID));
            } else {
                oldData.put(chID, newData.get(chID));
View Full Code Here

        for (int i = 0; i < actions.length; i++) {
            Action action = actions[i];

            for (int j = 0; j < action.getInputPatterns().length; j++) {
                InputPattern inputPattern = action.getInputPatterns()[j];
                ChannelID chID = new ChannelID(inputPattern.getPortname(), 0);
                int numNeeded = numTokensNeeded(inputPattern);
                int numHave = 0;
                List data = (List) dataSoFar.get(chID);

                if (data != null) {
View Full Code Here

            boolean encountered = false;

            for (int j = 0; j < inputPatterns.length; j++) {
                InputPattern inputPattern = inputPatterns[j];
                String name = inputPattern.getPortname();
                ChannelID chID = new ChannelID(name, 0);

                if (inputProfile.containsKey(chID)) {
                    if (!encountered) {
                        encountered = true;
                    } else {
View Full Code Here

            return;
        }

        CSPTokenReader reader = new CSPTokenReader(inputProfile, _ioPorts, _cbc);
        CSPTokenReader.DataChannelID dchID = reader.getOne();
        ChannelID chID = dchID.getChannelID();
        Object newData = dchID.getData();
        List data = (List) dataSoFar.get(chID);

        if (data == null) {
            List l = new ArrayList();
View Full Code Here

TOP

Related Classes of caltrop.interpreter.ChannelID

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.