public IScopeable AddInstance(IScopeAppender scopeHandler, InstanceAnonymousTypeLinker genericsLinker) { var instance = new VariableInstance(this, genericsLinker, scopeHandler.DefinedIn()); scopeHandler.Add(instance, Static); return(instance); }
public ParameterInstance GetInstance(InstanceAnonymousTypeLinker instanceInfo) => new ParameterInstance(new CodeParameter(Name, Type.GetRealType(instanceInfo), DefaultValue) { Attributes = Attributes, Invoked = _invoked, RestrictedCalls = _restrictedCalls, DefaultValue = DefaultValue }, Var.GetInstance(null, instanceInfo));
public IScopeable AddInstance(IScopeAppender scopeHandler, InstanceAnonymousTypeLinker genericsLinker) { // Get the instance. IMethod instance = new DefinedMethodInstance(this, genericsLinker, scopeHandler.DefinedIn()); scopeHandler.Add(instance, Static); return(instance); }
public DefinedStructInstance(DefinedStructInitializer provider, InstanceAnonymousTypeLinker genericsLinker) : base(provider, genericsLinker) { Provider = provider; Constructors = new Constructor[] { new Constructor(this, Provider.DefinedAt, AccessLevel.Public) }; }
public DefinedClass(ParseInfo parseInfo, DefinedClassInitializer initializer, CodeType[] generics) : base(initializer.Name, initializer) { CanBeDeleted = true; Generics = generics; _parseInfo = parseInfo; _definedInitializer = initializer; _typeLinker = new InstanceAnonymousTypeLinker(initializer.GenericTypes, generics); }
public override CodeType GetRealType(InstanceAnonymousTypeLinker instanceInfo) { var newGenerics = new CodeType[Generics.Length]; for (int i = 0; i < newGenerics.Length; i++) { if (Generics[i] is AnonymousType at && instanceInfo.Links.ContainsKey(at)) { newGenerics[i] = instanceInfo.Links[at]; }
public override CodeType GetRealType(InstanceAnonymousTypeLinker instanceInfo) { // Similiar to DefinedClass.GetRealType var newLinker = InstanceAnonymousTypeLinker.Empty; for (int i = 0; i < Generics.Length; i++) { if (Generics[i] is AnonymousType at && instanceInfo.Links.ContainsKey(at)) { newLinker.Add(_provider.GenericTypes[i], instanceInfo.Links[at]); }
// Private constructor for CloneMerge. private InstanceAnonymousTypeLinker(InstanceAnonymousTypeLinker a, InstanceAnonymousTypeLinker b) { Links = new Dictionary <AnonymousType, CodeType>(a.Links); foreach (var pair in b.Links) { if (!Links.ContainsKey(pair.Key)) { Links.Add(pair.Key, pair.Value); } } }
// Determines if the type linker is compatible with another. public bool Compatible(InstanceAnonymousTypeLinker other) { foreach (var link in Links) { if (!(other.Links.TryGetValue(link.Key, out var otherPairedWith) && link.Value.CompatibleWith(otherPairedWith))) { return(false); } } return(true); }
public VariableInstance(Var var, InstanceAnonymousTypeLinker instanceInfo, CodeType definedIn) { Var = var; CodeType = var.CodeType.GetRealType(instanceInfo); _definedIn = definedIn; Attributes = new VariableInstanceAttributes() { CanBeSet = var.StoreType != StoreType.None, StoreType = var.StoreType, UseDefaultVariableAssigner = !var.IsMacro, ContainingType = definedIn }; }
public StructInstance(IStructProvider provider, InstanceAnonymousTypeLinker typeLinker) : base(provider.Name) { ObjectScope = new Scope("struct " + Name); StaticScope = new Scope("struct " + Name); Generics = typeLinker.SafeTypeArgsFromAnonymousTypes(provider.GenericTypes); Attributes = new StructAttributes(this); TypeSemantics = new StructSemantics(this); _provider = provider; _typeLinker = typeLinker; ArrayHandler = this; Operations.AddAssignmentOperator(); }
public DefinedMethodInstance(DefinedMethodProvider provider, InstanceAnonymousTypeLinker instanceInfo, CodeType definedIn) { Provider = provider; CodeType = provider.ReturnType?.GetRealType(instanceInfo); InstanceInfo = instanceInfo; DefinedInType = Attributes.ContainingType = definedIn; Attributes.Parallelable = provider.IsSubroutine; Attributes.Recursive = provider.Recursive; Parameters = new CodeParameter[provider.ParameterProviders.Length]; ParameterVars = new IVariableInstance[Parameters.Length]; for (int i = 0; i < Parameters.Length; i++) { var parameterInstance = provider.ParameterProviders[i].GetInstance(instanceInfo); ParameterVars[i] = parameterInstance.Variable; Parameters[i] = parameterInstance.Parameter; } Attributes.CallInfo = Provider.CallInfo; Attributes.GetRestrictedCallTypes = Provider.CallInfo; }
public AnonymousLabelInfo(InstanceAnonymousTypeLinker typeLinker) { TypeLinker = typeLinker; MakeAnonymousTypesUnkown = true; }
// Creates a new linker with the current linker merged with the provided linker. // If a duplicate key is found in the provided linker, this is prioritized. public InstanceAnonymousTypeLinker CloneMerge(InstanceAnonymousTypeLinker other) => new InstanceAnonymousTypeLinker(this, other);
public override StructInstance GetInstance(InstanceAnonymousTypeLinker typeLinker) => new DefinedStructInstance(this, typeLinker);
public StructInstance GetInstance(InstanceAnonymousTypeLinker typeLinker) => new StructInstance(this, typeLinker);
public IScopeable AddInstance(IScopeAppender scopeHandler, InstanceAnonymousTypeLinker genericsLinker) { scopeHandler.Add(this, Static); return(this); }
public IScopeable AddInstance(IScopeAppender scopeHandler, InstanceAnonymousTypeLinker genericsLinker) => throw new NotImplementedException();
public IVariableInstance GetInstance(CodeType definedIn, InstanceAnonymousTypeLinker genericsLinker) => this;
public abstract StructInstance GetInstance(InstanceAnonymousTypeLinker typeLinker);
public virtual CodeType GetRealType(InstanceAnonymousTypeLinker instanceInfo) => this;