public Bpl.Function CreateTypeFunction(ITypeReference type, int parameterCount)
        {
            System.Diagnostics.Debug.Assert(parameterCount >= 0);
            string typename = TypeHelper.GetTypeName(type, NameFormattingOptions.DocumentationId);

            typename = TranslationHelper.TurnStringIntoValidIdentifier(typename);
            Bpl.IToken          tok    = type.Token();
            List <Bpl.Variable> inputs = new List <Bpl.Variable>();

            //for (int i = 0; i < parameterCount; i++) {
            //  inputs.Add(new Bpl.Formal(tok, new Bpl.TypedIdent(tok, "arg"+i, this.TypeType), true));
            //}
            foreach (var t in TranslationHelper.ConsolidatedGenericParameters(type))
            {
                var n  = t.Name.Value;
                var n2 = TranslationHelper.TurnStringIntoValidIdentifier(n);
                inputs.Add(new Bpl.Formal(Bpl.Token.NoToken, new Bpl.TypedIdent(Bpl.Token.NoToken, n2, this.TypeType), true));
            }
            Bpl.Variable output = new Bpl.Formal(tok, new Bpl.TypedIdent(tok, "result", this.TypeType), false);
            Bpl.Function func   = new Bpl.Function(tok, typename, inputs, output);
            var          attrib = new Bpl.QKeyValue(Bpl.Token.NoToken, "constructor", new List <object>(1), null);

            func.Attributes = attrib;
            return(func);
        }
        /// <summary>
        /// Creates a fresh BPL variable to represent <paramref name="type"/>, deciding
        /// on its type based on the heap representation. I.e., the value of this
        /// variable represents the value of the expression "typeof(type)".
        /// </summary>
        public Bpl.Variable CreateTypeVariable(ITypeReference type, List <Bpl.ConstantParent> parents)
        {
            string typename = TypeHelper.GetTypeName(type, NameFormattingOptions.DocumentationId);

            typename = TranslationHelper.TurnStringIntoValidIdentifier(typename);
            Bpl.IToken     tok    = type.Token();
            Bpl.TypedIdent tident = new Bpl.TypedIdent(tok, typename, this.TypeType);
            Bpl.Constant   v      = new Bpl.Constant(tok, tident, true /*unique*/, parents, false, null);
            return(v);
        }
 public Bpl.Function CreateTypeFunction(ITypeReference type, int parameterCount) {
   System.Diagnostics.Debug.Assert(parameterCount >= 0);
   string typename = TypeHelper.GetTypeName(type, NameFormattingOptions.DocumentationId);
   typename = TranslationHelper.TurnStringIntoValidIdentifier(typename);
   Bpl.IToken tok = type.Token();
   List<Bpl.Variable> inputs = new List<Bpl.Variable>();
   //for (int i = 0; i < parameterCount; i++) {
   //  inputs.Add(new Bpl.Formal(tok, new Bpl.TypedIdent(tok, "arg"+i, this.TypeType), true));
   //}
   foreach (var t in TranslationHelper.ConsolidatedGenericParameters(type)) {
     var n = t.Name.Value;
     var n2 = TranslationHelper.TurnStringIntoValidIdentifier(n);
     inputs.Add(new Bpl.Formal(Bpl.Token.NoToken, new Bpl.TypedIdent(Bpl.Token.NoToken, n2, this.TypeType), true));
   }
   Bpl.Variable output = new Bpl.Formal(tok, new Bpl.TypedIdent(tok, "result", this.TypeType), false);
   Bpl.Function func = new Bpl.Function(tok, typename, inputs, output);
   var attrib = new Bpl.QKeyValue(Bpl.Token.NoToken, "constructor", new List<object>(1), null);
   func.Attributes = attrib;
   return func;
 }
 /// <summary>
 /// Creates a fresh BPL variable to represent <paramref name="type"/>, deciding
 /// on its type based on the heap representation. I.e., the value of this
 /// variable represents the value of the expression "typeof(type)".
 /// </summary>
 public Bpl.Variable CreateTypeVariable(ITypeReference type, List<Bpl.ConstantParent> parents)
 {
   string typename = TypeHelper.GetTypeName(type, NameFormattingOptions.DocumentationId);
     typename = TranslationHelper.TurnStringIntoValidIdentifier(typename);
     Bpl.IToken tok = type.Token();
     Bpl.TypedIdent tident = new Bpl.TypedIdent(tok, typename, this.TypeType);
     Bpl.Constant v = new Bpl.Constant(tok, tident, true /*unique*/, parents, false, null);
     return v;
 }