示例#1
0
        public LiteValue Visit(SyntaxClassNode Node, LiteEnv Env)
        {
            ClassInfo BaseCls = null;

            if (Node.GetBaseClassIdentNode() is SyntaxIdentifierNode BaseIdent)
            {
                var Val = Env.Get(BaseIdent.GetValue());
                if (Val.Type == LiteValueType.Class)
                {
                    BaseCls = ClassTable.GetClass((int)Val.Numeric);
                }

                if (BaseCls == null)
                {
                    Logger.DError($"error base class : {BaseIdent.GetValue()}");
                    return(LiteValue.Error);
                }
            }

            var ClsValue = ClassTable.AddClassEx(new ClassInfo(Node.GetClassName(), Env,
                                                               Node.GetClassBody() as SyntaxClassBodyStatementNode,
                                                               BaseCls));

            Env.SetSelf(Node.GetClassName(), ClsValue);
            return(ClsValue);
        }