Exemplo n.º 1
0
        // Trace mode entry point
        public TypeDefinitionCompiler(AssemblyCompiler parent, TypeTrace typeTrace)
        {
            Env = parent.Env;
            Parent = parent;
            TyconEnv = parent.AssmEnv.AddType(typeTrace.Type);
            this.TypeTrace = typeTrace;

            if (typeTrace.IncludeType && typeTrace.Parent.Parent.Flavor == TraceFlavor.Remainder)
            {
                // Create a self-loader fragment file
                NameSupply = new JST.NameSupply(Constants.Globals);
                // Will be bound by function passed to root's BindType
                RootId = NameSupply.GenSym();
                AssemblyId = NameSupply.GenSym();
                TypeDefinitionId = NameSupply.GenSym();
            }
            else {
                // Possibly inline type definition and/or method definitions into trace
                NameSupply = parent.NameSupply;
                // Already bound by parent
                RootId = parent.RootId;
                AssemblyId = parent.AssemblyId;
                // Will be bound locally
                TypeDefinitionId = NameSupply.GenSym();
            }
        }
        public static TypeCompilerEnvironment EnterType
            (CompilerEnvironment env,
            JST.NameSupply nameSupply,
            JST.Identifier rootId,
            JST.Identifier assemblyId,
            JST.Identifier typeId,
            CST.TypeEnvironment typeEnv,
            TypeTrace typeTrace)
        {
            var typeBoundTypeParameterIds = new Seq <JST.Identifier>();

            for (var i = 0; i < typeEnv.Type.Arity; i++)
            {
                typeBoundTypeParameterIds.Add(nameSupply.GenSym());
            }

            var res = new TypeCompilerEnvironment
                          (typeEnv.Global,
                          typeEnv.SkolemDefs,
                          typeEnv.Assembly,
                          typeEnv.Type,
                          typeEnv.TypeBoundArguments,
                          env,
                          nameSupply,
                          rootId,
                          assemblyId,
                          typeId,
                          typeBoundTypeParameterIds,
                          typeTrace);

            res.BindSpecial();

            return(res);
        }
 private TypeCompilerEnvironment
     (CST.Global global,
     IImSeq <CST.SkolemDef> skolemDefs,
     CST.AssemblyDef assembly,
     CST.TypeDef type,
     IImSeq <CST.TypeRef> typeBoundArguments,
     CompilerEnvironment env,
     JST.NameSupply nameSupply,
     JST.Identifier rootId,
     JST.Identifier assemblyId,
     JST.Identifier typeId,
     IImSeq <JST.Identifier> typeBoundTypeParameterIds,
     TypeTrace typeTrace)
     : base(
         global,
         skolemDefs,
         assembly,
         type,
         typeBoundArguments)
 {
     this.env                  = env;
     NameSupply                = nameSupply;
     this.rootId               = rootId;
     this.assemblyId           = assemblyId;
     this.typeId               = typeId;
     TypeBoundTypeParameterIds = typeBoundTypeParameterIds;
     boundAssemblies           = new Map <CST.AssemblyName, JST.Expression>();
     boundTypes                = new Map <CST.TypeRef, ExpressionAndPhase>();
     this.typeTrace            = typeTrace;
 }
Exemplo n.º 4
0
 private TypeCompilerEnvironment
     (CST.Global global,
      IImSeq<CST.SkolemDef> skolemDefs,
      CST.AssemblyDef assembly,
      CST.TypeDef type,
      IImSeq<CST.TypeRef> typeBoundArguments,
      CompilerEnvironment env,
      JST.NameSupply nameSupply,
      JST.Identifier rootId,
      JST.Identifier assemblyId,
      JST.Identifier typeId,
      IImSeq<JST.Identifier> typeBoundTypeParameterIds,
      TypeTrace typeTrace)
     : base(
         global,
         skolemDefs,
         assembly,
         type,
         typeBoundArguments)
 {
     this.env = env;
     NameSupply = nameSupply;
     this.rootId = rootId;
     this.assemblyId = assemblyId;
     this.typeId = typeId;
     TypeBoundTypeParameterIds = typeBoundTypeParameterIds;
     boundAssemblies = new Map<CST.AssemblyName, JST.Expression>();
     boundTypes = new Map<CST.TypeRef, ExpressionAndPhase>();
     this.typeTrace = typeTrace;
 }
Exemplo n.º 5
0
        // Trace mode entry point
        public TypeDefinitionCompiler(AssemblyCompiler parent, TypeTrace typeTrace)
        {
            Env            = parent.Env;
            Parent         = parent;
            TyconEnv       = parent.AssmEnv.AddType(typeTrace.Type);
            this.TypeTrace = typeTrace;

            if (typeTrace.IncludeType && typeTrace.Parent.Parent.Flavor == TraceFlavor.Remainder)
            {
                // Create a self-loader fragment file
                NameSupply = new JST.NameSupply(Constants.Globals);
                // Will be bound by function passed to root's BindType
                RootId           = NameSupply.GenSym();
                AssemblyId       = NameSupply.GenSym();
                TypeDefinitionId = NameSupply.GenSym();
            }
            else
            {
                // Possibly inline type definition and/or method definitions into trace
                NameSupply = parent.NameSupply;
                // Already bound by parent
                RootId     = parent.RootId;
                AssemblyId = parent.AssemblyId;
                // Will be bound locally
                TypeDefinitionId = NameSupply.GenSym();
            }
        }
Exemplo n.º 6
0
        private TypeTrace ResolveTypeTrace(CST.TypeDef typeDef)
        {
            var name      = typeDef.EffectiveName(Parent.Parent.Env.Global);
            var typeTrace = default(TypeTrace);

            if (!TypeMap.TryGetValue(name, out typeTrace))
            {
                typeTrace = new TypeTrace(this, typeDef);
                TypeMap.Add(name, typeTrace);
            }
            return(typeTrace);
        }
Exemplo n.º 7
0
 // Collecting mode entry point
 public TypeDefinitionCompiler(AssemblyCompiler parent, CST.TypeDef typeDef)
 {
     Env = parent.Env;
     Parent = parent;
     TyconEnv = parent.AssmEnv.AddType(typeDef);
     TypeTrace = null;
     // Inline type definition and method definitions into overall assembly
     NameSupply = parent.NameSupply;
     // Already bound by parent
     RootId = parent.RootId;
     AssemblyId = parent.AssemblyId;
     // Will be bound locally
     TypeDefinitionId = NameSupply.GenSym();
 }
Exemplo n.º 8
0
 // Collecting mode entry point
 public TypeDefinitionCompiler(AssemblyCompiler parent, CST.TypeDef typeDef)
 {
     Env       = parent.Env;
     Parent    = parent;
     TyconEnv  = parent.AssmEnv.AddType(typeDef);
     TypeTrace = null;
     // Inline type definition and method definitions into overall assembly
     NameSupply = parent.NameSupply;
     // Already bound by parent
     RootId     = parent.RootId;
     AssemblyId = parent.AssemblyId;
     // Will be bound locally
     TypeDefinitionId = NameSupply.GenSym();
 }
Exemplo n.º 9
0
 private MethodCompilerEnvironment
     (CST.Global global,
     IImSeq <CST.SkolemDef> skolemDefs,
     CST.AssemblyDef assembly,
     CST.TypeDef type,
     IImSeq <CST.TypeRef> typeBoundArguments,
     CST.MethodDef method,
     IImSeq <CST.TypeRef> methodBoundArguments,
     IMap <JST.Identifier, CST.Variable> variables,
     IImSeq <JST.Identifier> valueParameterIds,
     IImSeq <JST.Identifier> localIds,
     CompilerEnvironment env,
     JST.NameSupply nameSupply,
     JST.Identifier rootId,
     JST.Identifier assemblyId,
     JST.Identifier typeDefinitionId,
     JST.Identifier methodId,
     IImSeq <JST.Identifier> typeBoundTypeParameterIds,
     IImSeq <JST.Identifier> methodBoundTypeParameterIds,
     TypeTrace typeTrace)
     : base(
         global,
         skolemDefs,
         assembly,
         type,
         typeBoundArguments,
         method,
         methodBoundArguments,
         variables,
         valueParameterIds,
         localIds)
 {
     this.env                    = env;
     NameSupply                  = nameSupply;
     this.rootId                 = rootId;
     this.assemblyId             = assemblyId;
     this.typeDefinitionId       = typeDefinitionId;
     MethodId                    = methodId;
     TypeBoundTypeParameterIds   = typeBoundTypeParameterIds;
     MethodBoundTypeParameterIds = methodBoundTypeParameterIds;
     boundAssemblies             = new Map <CST.AssemblyName, JST.Expression>();
     boundTypes                  = new Map <CST.TypeRef, JST.Expression>();
     boundVariablePointers       = new Map <JST.Identifier, JST.Expression>();
     this.typeTrace              = typeTrace;
 }
Exemplo n.º 10
0
 public static MethodCompilerEnvironment EnterUntranslatedMethod
     (CompilerEnvironment env,
     JST.NameSupply outerNameSupply,
     JST.NameSupply nameSupply,
     JST.Identifier rootId,
     JST.Identifier assemblyId,
     JST.Identifier typeDefinitonId,
     CST.MethodEnvironment methEnv,
     TypeTrace typeTrace)
 {
     return(EnterMethod
                (env,
                outerNameSupply,
                nameSupply,
                rootId,
                assemblyId,
                typeDefinitonId,
                methEnv.AddVariables(nameSupply, i => false),
                typeTrace));
 }
Exemplo n.º 11
0
        public static TypeCompilerEnvironment EnterType
            (CompilerEnvironment env,
             JST.NameSupply nameSupply,
             JST.Identifier rootId,
             JST.Identifier assemblyId,
             JST.Identifier typeId,
             CST.TypeEnvironment typeEnv,
             TypeTrace typeTrace)
        {
            var typeBoundTypeParameterIds = new Seq<JST.Identifier>();
            for (var i = 0; i < typeEnv.Type.Arity; i++)
                typeBoundTypeParameterIds.Add(nameSupply.GenSym());

            var res = new TypeCompilerEnvironment
                (typeEnv.Global,
                 typeEnv.SkolemDefs,
                 typeEnv.Assembly,
                 typeEnv.Type,
                 typeEnv.TypeBoundArguments,
                 env,
                 nameSupply,
                 rootId,
                 assemblyId,
                 typeId,
                 typeBoundTypeParameterIds,
                 typeTrace);

            res.BindSpecial();

            return res;
        }
Exemplo n.º 12
0
 private TypeTrace ResolveTypeTrace(CST.TypeDef typeDef)
 {
     var name = typeDef.EffectiveName(Parent.Parent.Env.Global);
     var typeTrace = default(TypeTrace);
     if (!TypeMap.TryGetValue(name, out typeTrace))
     {
         typeTrace = new TypeTrace(this, typeDef);
         TypeMap.Add(name, typeTrace);
     }
     return typeTrace;
 }
Exemplo n.º 13
0
        public static MethodCompilerEnvironment EnterMethod
            (CompilerEnvironment env,
            JST.NameSupply outerNameSupply,
            JST.NameSupply nameSupply,
            JST.Identifier rootId,
            JST.Identifier assemblyId,
            JST.Identifier typeDefinitonId,
            CST.CompilationEnvironment compEnv,
            TypeTrace typeTrace)
        {
            // BUG: IE messes up scoping for function identifiers. To compensate we must allocate its
            //      identifier in the outer scope
            var methodId = outerNameSupply.GenSym();

            if (env.DebugMode)
            {
                var sb = new StringBuilder();
                sb.Append(methodId.Value);
                sb.Append('_');
                var namedTypeDef = compEnv.Type as CST.NamedTypeDef;
                if (namedTypeDef != null)
                {
                    if (namedTypeDef.Name.Namespace.Length > 0)
                    {
                        JST.Lexemes.AppendStringToIdentifier(sb, namedTypeDef.Name.Namespace.Replace('.', '_'));
                        sb.Append('_');
                    }
                    foreach (var n in namedTypeDef.Name.Types)
                    {
                        JST.Lexemes.AppendStringToIdentifier(sb, n);
                        sb.Append('_');
                    }
                }
                JST.Lexemes.AppendStringToIdentifier(sb, compEnv.Method.Name);
                methodId = new JST.Identifier(sb.ToString());
            }

            var typeBoundTypeParameterIds = new Seq <JST.Identifier>();

            for (var i = 0; i < compEnv.Type.Arity; i++)
            {
                typeBoundTypeParameterIds.Add(nameSupply.GenSym());
            }

            var methodBoundTypeParameterIds = new Seq <JST.Identifier>();

            for (var i = 0; i < compEnv.Method.TypeArity; i++)
            {
                methodBoundTypeParameterIds.Add(nameSupply.GenSym());
            }

            var res = new MethodCompilerEnvironment
                          (compEnv.Global,
                          compEnv.SkolemDefs,
                          compEnv.Assembly,
                          compEnv.Type,
                          compEnv.TypeBoundArguments,
                          compEnv.Method,
                          compEnv.MethodBoundArguments,
                          compEnv.Variables,
                          compEnv.ValueParameterIds,
                          compEnv.LocalIds,
                          env,
                          nameSupply,
                          rootId,
                          assemblyId,
                          typeDefinitonId,
                          methodId,
                          typeBoundTypeParameterIds,
                          methodBoundTypeParameterIds,
                          typeTrace);

            res.BindSpecial();

            return(res);
        }