public void AddExt(string _name, int _line, int _col)
 {
     SuperClass.Add(new IDEHelpNode(IDEHelpNode.NodeType.TypeNode)
     {
         Value = _name, Type = IDEHelpNode.NodeType.TypeNode, Line = _line, Col = _col
     });
 }
Exemple #2
0
        internal override SObject GetMember(ScriptProcessor processor, SObject accessor, bool isIndexer)
        {
            if (isIndexer && accessor.TypeOf() == LiteralTypeNumber)
            {
                if (Prototype.GetIndexerGetFunction() != IndexerGetFunction)
                {
                    IndexerGetFunction = Prototype.GetIndexerGetFunction();
                }

                return(IndexerGetFunction != null?IndexerGetFunction.Call(processor, this, this, new[] { accessor }) : processor.Undefined);
            }

            var accessorAsString = accessor as SString;
            var memberName       = accessorAsString != null ? accessorAsString.Value : accessor.ToString(processor).Value;

            if (Members.ContainsKey(PropertyGetPrefix + memberName)) // getter property
            {
                return(((SFunction)Members[PropertyGetPrefix + memberName].Data).Call(processor, this, this, new SObject[] { }));
            }
            if (Members.ContainsKey(memberName))
            {
                return(Members[memberName]);
            }
            if (Prototype != null && Prototype.HasMember(processor, memberName))
            {
                return(Prototype.GetMember(processor, accessor, isIndexer));
            }
            if (SuperClass != null)
            {
                return(SuperClass.GetMember(processor, accessor, isIndexer));
            }

            return(processor.Undefined);
        }
Exemple #3
0
 internal override SObject ExecuteMethod(ScriptProcessor processor, string methodName, SObject caller, SObject This, SObject[] parameters)
 {
     if (Members.ContainsKey(methodName))
     {
         if (Members[methodName].Data.TypeOf() == LITERAL_TYPE_FUNCTION)
         {
             return(((SFunction)Members[methodName].Data).Call(processor, caller, this, parameters));
         }
         else
         {
             return(processor.ErrorHandler.ThrowError(ErrorType.TypeError, ErrorHandler.MESSAGE_TYPE_NOT_A_FUNCTION, methodName));
         }
     }
     else if (Prototype != null && Prototype.HasMember(processor, methodName))
     {
         return(Prototype.ExecuteMethod(processor, methodName, caller, This, parameters));
     }
     else if (SuperClass != null)
     {
         return(SuperClass.ExecuteMethod(processor, methodName, caller, This, parameters));
     }
     else
     {
         return(processor.ErrorHandler.ThrowError(ErrorType.TypeError, ErrorHandler.MESSAGE_TYPE_NOT_A_FUNCTION, methodName));
     }
 }
        public void SuperStuff_Is_Done(int i)
        {
            var sut   = new SuperClass(i);
            var super = sut.DoSuperStuff();

            Assert.Contains(i.ToString(), super);
        }
        public PropertyDescription AttributeNamed(string name)
        {
            var property = _attributes[name];

            if (property == null && SuperClass != null)
            {
                property = SuperClass.AttributeNamed(name);
            }

            return(property);
        }
 private void CollectAllAttributes(Dictionary <string, PropertyDescription> all)
 {
     // superclass first, to ensure correct shadowing
     if (SuperClass != null)
     {
         SuperClass.CollectAllAttributes(all);
     }
     foreach (var attribute in _attributes)
     {
         all[attribute.Key] = attribute.Value;
     }
 }
 public void SetupTest()
 {
     ClassDef.ClassDefs.Clear();
     SetupDataAccessor();
     DeleteAllContactPeople();
     FixtureEnvironment.ClearBusinessObjectManager();
     ContactPersonTestBO.CreateSampleData();
     ContactPersonTestBO.LoadDefaultClassDef();
     FixtureEnvironment.ClearBusinessObjectManager();
     TestUtil.WaitForGC();
     SuperClass.LoadClassDef();
     SubClass.LoadClassDef();
 }
Exemple #8
0
        public LoxFunction FindMethod(string name)
        {
            if (Methods.ContainsKey(name))
            {
                return(Methods[name]);
            }

            if (SuperClass != null)
            {
                return(SuperClass.FindMethod(name));
            }

            return(null);
        }
Exemple #9
0
        internal override SObject GetMember(ScriptProcessor processor, SObject accessor, bool isIndexer)
        {
            if (isIndexer && accessor.TypeOf() == LITERAL_TYPE_NUMBER)
            {
                if (Prototype.GetIndexerGetFunction() != IndexerGetFunction)
                {
                    IndexerGetFunction = Prototype.GetIndexerGetFunction();
                }

                if (IndexerGetFunction != null)
                {
                    return(IndexerGetFunction.Call(processor, this, this, new SObject[] { accessor }));
                }
                else
                {
                    return(processor.Undefined);
                }
            }

            string memberName;

            if (accessor is SString)
            {
                memberName = ((SString)accessor).Value;
            }
            else
            {
                memberName = accessor.ToString(processor).Value;
            }

            if (Members.ContainsKey(PROPERTY_GET_PREFIX + memberName)) // getter property
            {
                return(((SFunction)Members[PROPERTY_GET_PREFIX + memberName].Data).Call(processor, this, this, new SObject[] { }));
            }
            else if (Members.ContainsKey(memberName))
            {
                return(Members[memberName]);
            }
            else if (Prototype != null && Prototype.HasMember(processor, memberName))
            {
                return(Prototype.GetMember(processor, accessor, isIndexer));
            }
            else if (SuperClass != null)
            {
                return(SuperClass.GetMember(processor, accessor, isIndexer));
            }

            return(processor.Undefined);
        }
Exemple #10
0
 internal override bool HasMember(ScriptProcessor processor, string memberName)
 {
     if (Members.ContainsKey(memberName))
     {
         return(true);
     }
     else if (Prototype != null && Prototype.HasMember(processor, memberName))
     {
         return(true);
     }
     else if (SuperClass != null)
     {
         return(SuperClass.HasMember(processor, memberName));
     }
     return(false);
 }
Exemple #11
0
        internal override void SetMember(ScriptProcessor processor, SObject accessor, bool isIndexer, SObject value)
        {
            if (isIndexer)
            {
                if (Prototype.GetIndexerSetFunction() != IndexerSetFunction)
                {
                    IndexerSetFunction = Prototype.GetIndexerSetFunction();
                }
            }

            if (isIndexer && accessor.TypeOf() == LITERAL_TYPE_NUMBER && IndexerSetFunction != null)
            {
                IndexerSetFunction.Call(processor, this, this, new SObject[] { accessor, value });
            }
            else
            {
                string memberName;
                if (accessor is SString)
                {
                    memberName = ((SString)accessor).Value;
                }
                else
                {
                    memberName = accessor.ToString(processor).Value;
                }

                if (Members.ContainsKey(PROPERTY_SET_PREFIX + memberName)) // setter property
                {
                    ((SFunction)Members[PROPERTY_SET_PREFIX + memberName].Data).Call(processor, this, this, new SObject[] { value });
                }
                if (Members.ContainsKey(memberName))
                {
                    Members[memberName].Data = value;
                }
                else if (Prototype != null && Prototype.HasMember(processor, memberName) && !Prototype.IsStaticMember(memberName))
                {
                    // This is the case when new members got added to the prototype, and we haven't copied them over to the instance yet.
                    // So we do that now, and then set the value of that member:
                    AddMember(memberName, value);
                }
                else
                {
                    SuperClass?.SetMember(processor, accessor, isIndexer, value);
                }
            }
        }
Exemple #12
0
        public IVmObject LookupInstanceMethod(string name)
        {
            (var method, var ok) = Methods.Get(name);
            if (!ok)
            {
                if (SuperClass != null)
                {
                    return(SuperClass.LookupInstanceMethod(name));
                }
                if (Class != null)
                {
                    return(Class.LookupInstanceMethod(name));
                }

                return(null);
            }

            return(method);
        }
Exemple #13
0
        public Pointer LookupConstant(string name, bool findInScope)
        {
            var ok = Constants.TryGetValue(name, out var constant);

            if (!ok)
            {
                if (findInScope && Scope != null)
                {
                    return(Scope.LookupConstant(name, true));
                }
                if (SuperClass != null)
                {
                    return(SuperClass.LookupConstant(name, false));
                }

                return(null);
            }

            return(constant);
        }
Exemple #14
0
        public static void TestGetTypeInSuperClass()
        {
            ConcreteClass test = new ConcreteClass();

            Assert.AreEqual(
                "Bridge.ClientTest.Batch3.BridgeIssues.Bridge3426+ConcreteClass",
                test.TypeProp,
                "Property query for instance:abstract class returns the expected class name.");
            Assert.AreEqual(
                "Bridge.ClientTest.Batch3.BridgeIssues.Bridge3426+ConcreteClass",
                test.TypeMethod(),
                "Method query returns the expected class name.");

            SuperClass sup = new SuperClass();

            Assert.AreEqual("Bridge.ClientTest.Batch3.BridgeIssues.Bridge3426+SuperClass",
                            sup.TypeProp,
                            "Property query for direct instance of super class returns the expected name.");
            Assert.AreEqual("Bridge.ClientTest.Batch3.BridgeIssues.Bridge3426+SuperClass",
                            sup.TypeMethod(),
                            "Method query for direct instance of super class returns the expected name.");

            SubClass sub = new SubClass();

            Assert.AreEqual("Bridge.ClientTest.Batch3.BridgeIssues.Bridge3426+SubClass",
                            sub.TypeProp,
                            "Property query for instance of sub class returns the expected name.");
            Assert.AreEqual("Bridge.ClientTest.Batch3.BridgeIssues.Bridge3426+SubClass",
                            sub.TypeMethod(),
                            "Method query for instance of sub class returns the expected name.");

            SuperClass subCast = (SuperClass)sub;

            Assert.AreEqual("Bridge.ClientTest.Batch3.BridgeIssues.Bridge3426+SubClass",
                            subCast.TypeProp,
                            "Property query for cast instance of super class returns the expected name.");
            Assert.AreEqual("Bridge.ClientTest.Batch3.BridgeIssues.Bridge3426+SubClass",
                            subCast.TypeMethod(),
                            "Method query for cast instance of super class returns the expected name.");
        }
Exemple #15
0
        internal override void SetMember(ScriptProcessor processor, SObject accessor, bool isIndexer, SObject value)
        {
            if (isIndexer)
            {
                if (Prototype.GetIndexerSetFunction() != IndexerSetFunction)
                {
                    IndexerSetFunction = Prototype.GetIndexerSetFunction();
                }
            }

            if (isIndexer && accessor.TypeOf() == LiteralTypeNumber && IndexerSetFunction != null)
            {
                IndexerSetFunction.Call(processor, this, this, new[] { accessor, value });
            }
            else
            {
                var accessorAsString = accessor as SString;
                var memberName       = accessorAsString != null ? accessorAsString.Value : accessor.ToString(processor).Value;

                if (Members.ContainsKey(PropertySetPrefix + memberName)) // setter property
                {
                    ((SFunction)Members[PropertySetPrefix + memberName].Data).Call(processor, this, this, new[] { value });
                }
                if (Members.ContainsKey(memberName))
                {
                    Members[memberName].Data = value;
                }
                else if (Prototype != null && Prototype.HasMember(processor, memberName) && !Prototype.IsStaticMember(memberName))
                {
                    // This is the case when new members got added to the prototype, and we haven't copied them over to the instance yet.
                    // So we do that now, and then set the value of that member:
                    AddMember(memberName, value);
                }
                else
                {
                    SuperClass?.SetMember(processor, accessor, isIndexer, value);
                }
            }
        }
 public virtual T caseSuperClass(SuperClass theEObject)
 {
     return(default(T));
 }
Exemple #17
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="node">対象Node</param>
        /// <param name="semanticModel">対象ソースのsemanticModel</param>
        /// <param name="parent">親IAnalyzeItem</param>
        /// <param name="container">イベントコンテナ</param>
        public ItemClass(ClassDeclarationSyntax node, SemanticModel semanticModel, IAnalyzeItem parent, EventContainer container) : base(parent, node, semanticModel, container)
        {
            ItemType = ItemTypes.Class;

            var declaredClass = semanticModel.GetDeclaredSymbol(node);

            // スーパークラス/インターフェース設定
            if (node.BaseList != null)
            {
                // スーパークラス
                SuperClass.AddRange(getExpressionList(declaredClass.BaseType));

                // スーパークラスのメンバーを追加する
                SetBaseMembers(declaredClass.BaseType);

                // インターフェース
                foreach (var interfaceInfo in declaredClass.AllInterfaces)
                {
                    Interfaces.Add(getExpressionList(interfaceInfo));
                }

                // 対象をList<IExpression>に格納する
                List <IExpression> getExpressionList(INamedTypeSymbol target)
                {
                    var result = new List <IExpression>();

                    var displayParts = target.ToDisplayParts(SymbolDisplayFormat.MinimallyQualifiedFormat);

                    foreach (var part in displayParts)
                    {
                        // スペースの場合は型設定に含めない
                        if (part.Kind == SymbolDisplayPartKind.Space)
                        {
                            continue;
                        }

                        var name = Expression.GetSymbolName(part);
                        var type = Expression.GetSymbolTypeName(part.Symbol);
                        if (part.Symbol != null)
                        {
                            type = part.Symbol.GetType().Name;

                            if (part.Kind == SymbolDisplayPartKind.ClassName || part.Kind == SymbolDisplayPartKind.InterfaceName)
                            {
                                // 外部ファイル参照イベント発行
                                RaiseOtherFileReferenced(node, part.Symbol);
                            }

                            // ジェネリックスの場合はパラメータ除去
                            if (part.Symbol is INamedTypeSymbol symbol && symbol.IsGenericType)
                            {
                                name = name.Substring(0, name.LastIndexOf("<", StringComparison.CurrentCulture));
                            }
                        }
                        result.Add(new Expression(name, type));
                    }

                    return(result);
                }
            }

            // ジェネリックタイプ
            if (declaredClass.TypeParameters.Any())
            {
                var types = declaredClass.TypeParameters.Select(item => item.Name);
                GenericTypes.AddRange(types);
            }

            // メンバ
            foreach (var childSyntax in node.ChildNodes())
            {
                var memberResult = ItemFactory.Create(childSyntax, semanticModel, container, this);
                if (memberResult != null)
                {
                    Members.Add(memberResult);
                }
            }
        }
Exemple #18
0
 public HomeController()
 {
     this.super = new SuperClass(1);
 }
Exemple #19
0
 // and this
 public InheritedClass(SuperClass super) : base(super)
 {
     // bacause you can't call base() and this()
     Init();
 }
Exemple #20
0
 // you need to have this
 public SuperClass(SuperClass copy)
 {
     a = copy.a;
 }
Exemple #21
0
 public SubClass(SuperClass x)
 {
 }
Exemple #22
0
        /// <summary>
        /// 文字列取得
        /// </summary>
        /// <param name="index">前スペース数</param>
        /// <returns>文字列</returns>
        public override string ToString(int index = 0)
        {
            var result     = new StringBuilder();
            var indexSpace = string.Concat(Enumerable.Repeat("  ", index));

            foreach (var comment in Comments)
            {
                result.Append(indexSpace);
                result.AppendLine($"{comment}");
            }

            foreach (var modifier in Modifiers)
            {
                result.Append(indexSpace);
                result.Append($"{modifier} ");
            }
            result.Append($"class {Name}");

            // ジェネリックタイプ
            if (GenericTypes.Any())
            {
                result.Append("<");

                GenericTypes.ForEach(item => {
                    result.Append(item);
                    if (GenericTypes.IndexOf(item) > 0)
                    {
                        result.Append(", ");
                    }
                });

                result.Append(">");
            }

            // スーパークラス/インターフェイス
            if (SuperClass.Any())
            {
                result.Append(" : ");
                SuperClass.ForEach(item => {
                    result.Append(item.Name);
                });
            }
            if (Interfaces.Any())
            {
                if (SuperClass.Any())
                {
                    result.Append(", ");
                }
                Interfaces.ForEach(item => {
                    if (Interfaces.IndexOf(item) > 0)
                    {
                        result.Append(", ");
                    }
                    item.ForEach(expression =>
                    {
                        result.Append(expression.Name);
                    });
                });
            }

            result.AppendLine();
            result.Append(indexSpace);
            result.AppendLine("{");

            Members.ForEach(member => result.AppendLine(member.ToString(index + 1)));

            result.Append(indexSpace);
            result.AppendLine("}");

            return(result.ToString());
        }
        public void GatherXObjects(List <XObject> xobjects)
        {
            xobjects.Add(new XAttribute("name", Name));
            if (SuperClass != null)
            {
                xobjects.Add(new XElement("superclass", new XElement("superclass", new XAttribute("name", SuperClass.ToString()))));
            }
            if (DefaultType != null)
            {
                xobjects.Add(new XAttribute("defaulttype", DefaultType.ToString()));
            }
            var conforming = new List <XObject> ();

            foreach (var spec in ConformingProtocols)
            {
                conforming.Add(new XElement("conformingprotocol", new XAttribute("name", spec.ToString())));
            }
            xobjects.Add(new XElement("conformingprotocols", conforming.ToArray()));
        }
Exemple #24
0
        public static void Main(string[] args)
        {
            var super = new SuperClass(42);

            System.Console.WriteLine(super.DoSuperStuff());
        }