Exemplo n.º 1
0
        bool IDfirNodeVisitor <bool> .VisitBuildTupleNode(BuildTupleNode buildTupleNode)
        {
            TypeVariableReference[] elementTypes = new TypeVariableReference[buildTupleNode.InputTerminals.Count];
            for (int i = 0; i < buildTupleNode.InputTerminals.Count; ++i)
            {
                Terminal inputTerminal = buildTupleNode.InputTerminals[i];
                // TODO: constrain these to be unbounded lifetime
                TypeVariableReference elementType = _typeVariableSet.CreateReferenceToNewTypeVariable();
                _nodeFacade[inputTerminal] = new SimpleTerminalFacade(inputTerminal, elementType);
                elementTypes[i]            = elementType;
            }
            TypeVariableReference tupleType = _typeVariableSet.CreateReferenceToTupleType(elementTypes);
            Terminal outputTerminal         = buildTupleNode.OutputTerminals[0];

            _nodeFacade[outputTerminal] = new SimpleTerminalFacade(outputTerminal, tupleType);
            return(true);
        }
Exemplo n.º 2
0
        private static void CreateFacadesForDecomposeTupleNode(this DecomposeTupleNode decomposeTupleNode, TypeVariableSet typeVariableSet)
        {
            if (decomposeTupleNode.DecomposeMode == DecomposeMode.Borrow)
            {
                throw new NotSupportedException();
            }
            TypeVariableReference[] elementTypes = new TypeVariableReference[decomposeTupleNode.OutputTerminals.Count];
            AutoBorrowNodeFacade    nodeFacade   = AutoBorrowNodeFacade.GetNodeFacade(decomposeTupleNode);

            for (int i = 0; i < decomposeTupleNode.OutputTerminals.Count; ++i)
            {
                Terminal outputTerminal           = decomposeTupleNode.OutputTerminals[i];
                TypeVariableReference elementType = typeVariableSet.CreateReferenceToNewTypeVariable();
                nodeFacade[outputTerminal] = new SimpleTerminalFacade(outputTerminal, elementType);
                elementTypes[i]            = elementType;
            }

            TypeVariableReference tupleType = typeVariableSet.CreateReferenceToTupleType(elementTypes);
            Terminal inputTerminal          = decomposeTupleNode.InputTerminals[0];

            nodeFacade[inputTerminal] = new SimpleTerminalFacade(inputTerminal, tupleType);
        }