コード例 #1
0
        public Function(BaseStructure Base, bool asConstructor) : base(Base.Name, Base.Modifiers, Base.AccessModifier, Base.Childs)
        {
            Directive = Base.Directive;

            CompileCache.UnknownLabelNameErrorList = new List <ConstantErrorMark>();
            CompileCache.Variables   = new List <VariableMark>();
            CompileCache.NamedConsts = new List <ConstantMark>();
            Parameters = new List <FunctionParameter>();

            if (asConstructor)
            {
                Target       = RuleTarget.Constructor;
                IsConstuctor = true;
            }
            else
            {
                Target = RuleTarget.Method;

                Modifier retModifier = GetModifier(ReturnKeyword);
                if (retModifier.Value == NoReturnableValueKeyword)
                {
                    RetType       = TypeReference.Void;
                    HasNoRetValue = true;
                }
                else
                {
                    RetType = new TypeReference(retModifier.Value, null);
                }

                if (GetModifier(OverrideKeyword) != null)
                {
                    IsStatic = true;
                }
                if (GetModifier(VirtualKeyword) != null)
                {
                    IsStatic = true;
                }
                if (GetModifier(StaticKeyword) != null)
                {
                    IsStatic = true;
                }
                if (GetModifier(EntryPointKeyword) != null)
                {
                    IsEntryPoint = true;
                }
            }

            foreach (var parameter in Modifiers.FindAll(p => p.Name == ParameterKeyword))
            {
                var parts = parameter.Value.Split(':');

                var type = parts[0];
                var name = parts[1];

                Parameters.Add(new FunctionParameter(
                                   new TypeReference(type, null), name));
            }
        }
コード例 #2
0
ファイル: Field.cs プロジェクト: Coestaris/hasm
        public Field(BaseStructure Base) : base(Base.Name, Base.Modifiers, Base.AccessModifier, Base.Childs)
        {
            Target    = RuleTarget.Field;
            Directive = Base.Directive;

            Modifier type = GetModifier(TypeKeyword);

            Type = new TypeReference(type.Value, null);

            IsStatic = GetModifier(StaticKeyword) != null;
        }
コード例 #3
0
ファイル: Assembly.cs プロジェクト: Coestaris/hasm
        public Assembly(BaseStructure Base) : base(Base.Name, Base.Modifiers, Base.AccessModifier, Base.Childs)
        {
            UsedTypes      = new List <TypeReference>();
            Classes        = new List <Class>();
            ParentAssembly = null;
            Target         = RuleTarget.Assembly;
            Directive      = Base.Directive;

            SetParentAssembly(Base.Childs);

            foreach (var item in Base.Childs)
            {
                Classes.Add(item as Class);
            }
        }
コード例 #4
0
        public Class(BaseStructure Base) : base(Base.Name, Base.Modifiers, Base.AccessModifier, Base.Childs)
        {
            Extends      = new List <Class>();
            StaticFields = new Dictionary <int, Object>();
            Target       = RuleTarget.Class;
            Directive    = Base.Directive;

            Constructors = new List <Function>();
            InnerClasses = new List <Class>();
            Functions    = new List <Function>();
            Fields       = new List <Field>();

            foreach (var child in Base.Childs)
            {
                switch (child.Target)
                {
                case RuleTarget.Class:
                    (child as Class).IsInner     = true;
                    (child as Class).InnerParent = this;
                    InnerClasses.Add(child as Class);
                    break;

                case RuleTarget.Method:
                    (child as Function).BaseClass = this;
                    Functions.Add(child as Function);
                    break;

                case RuleTarget.Field:
                {
                    Field field = child as Field;
                    field.BaseClass = this;
                    Fields.Add(child as Field);
                }
                break;

                case RuleTarget.Constructor:
                    (child as Function).BaseClass = this;
                    (child as Function).RetType   = new TypeReference(this, null);
                    Constructors.Add(child as Function);
                    break;

                default:
                    break;
                }
            }
        }
コード例 #5
0
 public Function(BaseStructure Base) : this(Base, false)
 {
 }