public XClass(ClassDefinition definition, XSystemDictionary smalltalk) { if ((definition == null) || (smalltalk == null)) throw new ArgumentNullException(); this.Name = definition.Name.Value; if (!String.IsNullOrWhiteSpace(definition.SuperclassName.Value) && (definition.SuperclassName.Value != "nil")) this._superclass = smalltalk.GetOrCreateBinding(definition.SuperclassName.Value); this.InstanceState = definition.InstanceState.Value; this.ClassVariables = new ClassVariablesPool(definition.ClassVariableNames); this.ClassInstanceVariables = new ClassInstanceVariablesPool(this, definition.ClassInstanceVariableNames); this.ImportedPools = new ImportedPoolsPool(smalltalk, definition.ImportedPoolNames); this.InstanceVariableNames = definition.InstanceVariableNames.Select(sr => sr.Value).ToArray(); }
/// <summary> /// Add a class definition to the installation context. /// </summary> /// <param name="definition">Definition of the class to be added.</param> public void AddClass(ClassDefinition definition) { this._globals.Add(definition); }
/// <summary> /// File-in and process the actions contained in the node. /// </summary> /// <param name="processor">Interchange format processor responsible for the processing context.</param> /// <param name="parseErrorSink">Error sink for reporting parse errors.</param> /// <param name="sourceCodeService">Source code service that can convert tokens to source code span and reports issues.</param> /// <returns>Return an interchange unit node for annotation, usually just self.</returns> public override InterchangeUnitNode FileIn(InterchangeFormatProcessor processor, IParseErrorSink parseErrorSink, ISourceCodeReferenceService sourceCodeService) { if (processor == null) throw new ArgumentNullException("processor"); if (parseErrorSink == null) throw new ArgumentNullException("parseErrorSink"); if (sourceCodeService == null) throw new ArgumentNullException("sourceCodeService"); // ALL instance vars must be set. If one is missing, then source code bug, and // InterchangeFormatParser.ParseClassDefinition() should have reported the error. if ((this.ClassName == null) || (this.SuperclassName == null) || (this.IndexedInstanceVariables == null) || (this.InstanceVariableNames == null) || (this.ClassVariableNames == null) || (this.SharedPools == null) || (this.ClassInstanceVariableNames == null)) return this; SmalltalkClass.InstanceStateEnum? instanceState = this.GetInstanceState(processor, parseErrorSink, sourceCodeService); if (instanceState == null) return this; IEnumerable<SourceReference<string>> civn = this.GetClassInstanceVariableNames(processor, parseErrorSink, sourceCodeService); if (civn == null) return this; // ParseIdentifierList() reported the error IEnumerable<SourceReference<string>> ivn = this.GetInstanceVariableNames(processor, parseErrorSink, sourceCodeService); if (ivn == null) return this; // ParseIdentifierList() reported the error IEnumerable<SourceReference<string>> cvn = this.GetClassVariableNames(processor, parseErrorSink, sourceCodeService); if (cvn == null) return this; // ParseIdentifierList() reported the error IEnumerable<SourceReference<string>> spn = this.GetSharedPoolNames(processor, parseErrorSink, sourceCodeService); if (spn == null) return this; // ParseIdentifierList() reported the error ClassDefinition definition = new ClassDefinition( processor.CreateSourceReference(this.ClassName.Value, this.ClassName, sourceCodeService), processor.CreateSourceReference(this.SuperclassName.Value, this.SuperclassName, sourceCodeService), processor.CreateSourceReference(instanceState.Value, this.IndexedInstanceVariables, sourceCodeService), civn, cvn, ivn, spn); this.Definfition = definition; // This may fail, but we don't care. If failed, it reported the error through its error sink. processor.FileInProcessor.FileInClass(definition); return this; }