private ICompileUnit TryToLoadAssemblyContainingNamespace(string @namespace) { ICompileUnit asm = Parameters.LoadAssembly(@namespace, false); if (asm != null) { return(asm); } //try to load assemblies name after the parent namespaces var namespaces = @namespace.Split('.'); if (namespaces.Length == 1) { return(null); } for (var level = namespaces.Length - 1; level > 0; level--) { var parentNamespace = string.Join(".", namespaces, 0, level); var existingReference = Parameters.FindAssembly(parentNamespace); if (existingReference != null) { return(null); } var parentNamespaceAssembly = Parameters.LoadAssembly(parentNamespace, false); if (parentNamespaceAssembly != null) { return(parentNamespaceAssembly); } } return(null); }
public SourceMethodBuilder(ICompileUnit comp_unit, int ns_id, IMethodDef method) { this._comp_unit = comp_unit; this._method = method; this._ns_id = ns_id; method_lines = new List <LineNumberEntry> (); }
public GlobalNamespace() { var internalTypeSystemProvider = My <InternalTypeSystemProvider> .Instance; _compileUnit = internalTypeSystemProvider.EntityFor(My <CompileUnit> .Instance); _references = My <CompilerParameters> .Instance.References; }
public void CloningPreservesTypeIdentityAccrossProviders() { var type = typeof(int); ICompileUnit original = _subject.ForAssembly(type.Assembly); IReflectionTypeSystemProvider clone = _subject.Clone(); Assert.AreSame(_subject.Map(type), clone.Map(type)); }
public SourceMethodBuilder OpenMethod(ICompileUnit file, int ns_id, IMethodDef method) { SourceMethodBuilder builder = new SourceMethodBuilder(file, ns_id, method); current_method_stack.Push(current_method); current_method = builder; return(builder); }
public override void SetUp() { base.SetUp(); RunInCompilerContextEnvironment(() => { _subject = My<InternalTypeSystemProvider>.Instance.EntityFor(Context.CompileUnit); }); }
public override void SetUp() { base.SetUp(); RunInCompilerContextEnvironment(() => { _subject = My <InternalTypeSystemProvider> .Instance.EntityFor(Context.CompileUnit); }); }
public void ReferencesToSameAssemblyAreEqual() { ICompileUnit ref1 = _subject.ForAssembly(GetType().Assembly); ICompileUnit ref2 = _subject.ForAssembly(GetType().Assembly); Assert.IsNotNull(ref1); Assert.IsNotNull(ref2); Assert.AreEqual(ref1, ref2); }
public void ClonePreservesOriginalReferences() { ICompileUnit original = _subject.ForAssembly(GetType().Assembly); IReflectionTypeSystemProvider clone = _subject.Clone(); Assert.AreNotSame(_subject, clone); ICompileUnit referenceFromClone = clone.ForAssembly(GetType().Assembly); Assert.AreSame(original, referenceFromClone); }
public static SourceMethodBuilder OpenMethod(ICompileUnit file, IMethodDef method) { if (symwriter != null) { return(symwriter.OpenMethod(file, -1 /* Not used */, method)); } else { return(null); } }
public ICompileUnit EntityFor(CompileUnit unit) { ICompileUnit compileUnit = (ICompileUnit)unit.Entity; if (null != compileUnit) { return(compileUnit); } return(Bind(unit, new InternalCompileUnit(unit))); }
public static SourceMethodBuilder OpenMethod(ICompileUnit file, int ns_id, IMethodDef method) { if (symwriter != null) { return(symwriter.OpenMethod(file, ns_id, method)); } else { return(null); } }
public void RootNamespace() { ICompileUnit reference = _subject.ForAssembly(GetType().Assembly); INamespace root = reference.RootNamespace; Assert.IsFalse(root.Resolve(new List <IEntity>(), "XXX", EntityType.Any)); IEntity type = NamespaceAssert.ResolveQualifiedNameToSingle(root, GetType().FullName); Assert.AreEqual(EntityType.Type, type.EntityType); Assert.AreEqual(type.FullName, GetType().FullName); }
private bool TryAutoAddAssemblyReference(Boo.Lang.Compiler.Ast.Import import) { ICompileUnit asm = Parameters.FindAssembly(import.Namespace); if (asm != null) { return(false); //name resolution already failed earlier, don't try twice } asm = Parameters.LoadAssembly(import.Namespace, false); if (asm == null) { //try generalized namespaces string[] namespaces = import.Namespace.Split(new char[] { '.', }); if (namespaces.Length == 1) { return(false); } string ns; int level = namespaces.Length - 1; while (level > 0) { ns = string.Join(".", namespaces, 0, level); asm = Parameters.FindAssembly(ns); if (asm != null) { return(false); //name resolution already failed earlier, don't try twice } asm = Parameters.LoadAssembly(ns, false); if (asm != null) { break; } level--; } } if (asm != null) { Parameters.References.Add(asm); import.AssemblyReference = new ReferenceExpression(import.LexicalInfo, asm.FullName); import.AssemblyReference.Entity = asm; NameResolutionService.ClearResolutionCacheFor(asm.Name); return(true); } return(false); }
private ICompileUnit ResolveAssemblyReference(ReferenceExpression reference) { ICompileUnit existing = Parameters.FindAssembly(reference.Name); if (null != existing) { return(existing); } ICompileUnit newAssembly = Parameters.LoadAssembly(reference.Name); if (null != newAssembly) { Parameters.References.Add(newAssembly); return(newAssembly); } return(null); }
public void SetMethodUnit (ICompileUnit file) { current_method._comp_unit = file; }
public SourceMethodBuilder (ICompileUnit comp_unit, int ns_id, IMethodDef method) { this._comp_unit = comp_unit; this._method = method; this._ns_id = ns_id; method_lines = new LineNumberEntry [50]; }
public void SetMethodUnit(ICompileUnit file) { current_method._comp_unit = file; }
public SourceMethodBuilder OpenMethod (ICompileUnit file, int ns_id, IMethodDef method) { SourceMethodBuilder builder = new SourceMethodBuilder (file, ns_id, method); current_method_stack.Push (current_method); current_method = builder; methods.Add (current_method); return builder; }
public static SourceMethodBuilder OpenMethod (ICompileUnit file, int ns_id, IMethodDef method) { if (symwriter != null) return symwriter.OpenMethod (file, ns_id, method); else return null; }
public SourceMethodBuilder (ICompileUnit comp_unit) { this._comp_unit = comp_unit; method_lines = new List<LineNumberEntry> (); }
public SourceMethodBuilder(ICompileUnit comp_unit) { this._comp_unit = comp_unit; method_lines = new List <LineNumberEntry> (); }
protected SourceMethod (DeclSpace parent, MethodBase method, ICompileUnit file) { this.method = method; builder = SymbolWriter.OpenMethod (file, parent.NamespaceEntry.SymbolFileID, this); }
SourceMethod (MethodBase method, ICompileUnit file) { this.method = method; SymbolWriter.OpenMethod (file, this); }
public SourceMethodBuilder (ICompileUnit comp_unit, int ns_id, IMethodDef method) : this (comp_unit) { this.ns_id = ns_id; this.method = method; }
public GlobalNamespace() { var internalTypeSystemProvider = My<InternalTypeSystemProvider>.Instance; _compileUnit = internalTypeSystemProvider.EntityFor(My<CompileUnit>.Instance); _references = My<CompilerParameters>.Instance.References; }
public SourceMethodBuilder(ICompileUnit comp_unit, int ns_id, IMethodDef method) : this(comp_unit) { this.ns_id = ns_id; this.method = method; }
public static SourceMethodBuilder OpenMethod (ICompileUnit file, IMethodDef method) { if (symwriter != null) return symwriter.OpenMethod (file, -1 /* Not used */, method); else return null; }