当前位置: 首页>>代码示例>>C#>>正文


C# Scope.GetILTypeName方法代码示例

本文整理汇总了C#中Scope.GetILTypeName方法的典型用法代码示例。如果您正苦于以下问题:C# Scope.GetILTypeName方法的具体用法?C# Scope.GetILTypeName怎么用?C# Scope.GetILTypeName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Scope的用法示例。


在下文中一共展示了Scope.GetILTypeName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckSemantics

        public override void CheckSemantics(Scope scope, List<SemanticError> errors)
        {
            CheckIdentifier(scope, errors);
            if (scope.GetType(Identifier.Text).Type != TypesEnumeration.Array)
                errors.Add(SemanticError.WrongType(Identifier.Text, "Array", this));

            Identifier.ILName = string.Format("{0}Scope{1}", Identifier.Text, scope.CurrentScope);
            DefinedType.ILName = scope.GetILTypeName(DefinedType.Text);
        }
开发者ID:hansel0691,项目名称:Tiger,代码行数:9,代码来源:ArrayDeclarationNode.cs

示例2: CheckSemantics

        public override void CheckSemantics(Scope scope, List<SemanticError> errors)
        {
            //Verify if the array exist
            var varInfo = scope.GetVarInstance(this.ArrayIdentifier.Text);
            if (varInfo == null)
            {
                errors.Add(SemanticError.UndefinedVariableUsed(this.ArrayIdentifier.Text, this));
                return;
            }
            this.NextNested.CheckSemantics(varInfo.VariableType, scope, errors);
            ExpressionType = this.NextNested.ExpressionType;
            ArrayIdentifier.ILName = scope.GetILVarNames(ArrayIdentifier.Text);
            var arrayInfo = (ArrayInfo) scope.GetType(varInfo.VariableType);

            NextNested.Index.ILName = scope.GetILTypeName(arrayInfo.ItemsType);
            ILName = scope.GetILVarNames(ArrayIdentifier.Text);
            ExpressionType.ILName = scope.GetILTypeName(ExpressionType.Name);
        }
开发者ID:hansel0691,项目名称:Tiger,代码行数:18,代码来源:ArrayItemNode.cs

示例3: CheckSemantics

        public void CheckSemantics(string identifier, Scope scope, List<SemanticError> errors)
        {
            NestedNode curreNode = this;
            do
            {
                //check the field access
                var typeInfo = scope.GetType(identifier);
                if (curreNode is FieldNestedNode)
                {
                    //check if the type is record
                    if (typeInfo.Type != TypesEnumeration.Record)
                    {
                        errors.Add(SemanticError.WrongType("Record", typeInfo.Type.ToString(), this));
                        return;
                    }
                    var recordInfo = (RecordInfo)typeInfo;
                    var fieldNested  = (FieldNestedNode) curreNode;

                    var currentField = recordInfo.Parameters.FirstOrDefault(x => x.Identifier == fieldNested.FieldIdentifier.Text);
                    if (currentField == null)
                        errors.Add(SemanticError.InvalidFieldAccess(identifier,
                                                                    fieldNested.FieldIdentifier.Text, this));
                    else
                    {
                        fieldNested.FieldIdentifier.ILName = scope.GetILTypeName(identifier) + "." + fieldNested.FieldIdentifier.Text;
                        identifier = currentField.Type;
                    }
                }
                else
                {
                    //check if the type is an array
                    if (typeInfo.Type != TypesEnumeration.Array)
                    {
                        errors.Add(SemanticError.WrongType("Array", typeInfo.Type.ToString(), this));
                        return;
                    }
                    var arrayInfo = (ArrayInfo) typeInfo;
                    var arrayIndex = (IndexNestedNode) curreNode;
                    arrayIndex.CheckSemantics(scope, errors);
                    if (((IndexNestedNode)curreNode).Index.ExpressionType.Type != TypesEnumeration.Integer)
                        errors.Add(SemanticError.WrongType(((IndexNestedNode)curreNode).Index.ExpressionType.Name,"int",this));
                    else
                    {
                        identifier = arrayInfo.ItemsType;
                        //arrayIndex.Index.ILName = scope.GetILTypeName(identifier);
                    }

                    curreNode.ILName = scope.GetILTypeName(identifier);
                    //curreNode.ILName = scope.GetILTypeName(identifier) + "." + fieldNested.FieldIdentifier.Text;
                }
                curreNode = curreNode.NextNested;
            } while (curreNode != null);
            ExpressionType = scope.GetType(identifier);
        }
开发者ID:hansel0691,项目名称:Tiger,代码行数:54,代码来源:NestedNode.cs

示例4: CheckSemantics

        public override void CheckSemantics(Scope scope, List<SemanticError> errors)
        {
            var newScope = new Scope(scope);
            DeclarationBlock.CheckSemantics(newScope, errors);
            if (InstructionsBlock != null)
                InstructionsBlock.CheckSemantics(newScope, errors);

            //check the visibility of the returned type.
            ExpressionType = InstructionsBlock == null ? TypeInfo.GenerateVoidInfo() : this.InstructionsBlock.ExpressionType;
            if (ExpressionType != null && ExpressionType.Type != TypesEnumeration.Void && !scope.ContainsType(ExpressionType.Name))
                errors.Add(SemanticError.TypeNotVisible(ExpressionType.Name, this));
            ExpressionType.ILName = scope.GetILTypeName(ExpressionType.Name);
        }
开发者ID:hansel0691,项目名称:Tiger,代码行数:13,代码来源:LetInEndNode.cs

示例5: CheckSemantics

        public override void CheckSemantics(Scope scope, List<SemanticError> errors)
        {
            var varInfo = scope.GetVarInstance(Record.Text);
            //Verify if the variable exist
            if (varInfo == null)
            {
                errors.Add(SemanticError.UndefinedVariableUsed(this.Record.Text, this));
                return;
            }

            NextNested.CheckSemantics(varInfo.VariableType, scope, errors);
            ExpressionType = NextNested.ExpressionType;
            Record.ILName = scope.GetILVarNames(Record.Text);
            ILName = scope.GetILVarNames(Record.Text);
            ExpressionType.ILName = scope.GetILTypeName(ExpressionType.Name);
        }
开发者ID:hansel0691,项目名称:Tiger,代码行数:16,代码来源:AccessFieldNode.cs

示例6: CheckSemantics

        public override void CheckSemantics(Scope scope, List<SemanticError> errors)
        {
            RecordIdentifier.ILName = scope.GetILTypeName(RecordIdentifier.Text);

            var typeInfo = scope.GetType(this.RecordIdentifier.Text);
            //check if the record type is defined
            if (typeInfo == null || typeInfo.Type != TypesEnumeration.Record || scope.GetType(typeInfo.Name).Name != scope.GetType(this.RecordIdentifier.Text).Name)
            {
                errors.Add(SemanticError.TypeNotDefined(this.RecordIdentifier.Text, this));
                return;
            }

            var recordInfo = (RecordInfo) typeInfo;
            //the count of parameters used to define and to initialice a record must match.
            if (recordInfo.FieldsCount != this.FieldInitialicer.Count)
            {
                errors.Add(SemanticError.WrongParameterNumber("Record", this.RecordIdentifier.Text, recordInfo.FieldsCount, this.FieldInitialicer.Count, this));
                return;
            }

            for (int i = 0; i < recordInfo.FieldsCount; i++)
            {
                var assignNode = this.FieldInitialicer[i];
                assignNode.CheckSemantics(scope, errors);

                //check the field name and order
                if (assignNode.Field.Text != recordInfo.Parameters[i].Identifier)
                    errors.Add(SemanticError.WrongFieldInit(this.RecordIdentifier.Text, recordInfo.Parameters[i].Identifier, this));
                //check the field type
                if (assignNode.Value.ExpressionType.Type == TypesEnumeration.Nil)
                {
                    if (!scope.GetType(recordInfo.Parameters[i].Type).Nilable)
                        errors.Add(SemanticError.InvalidNilAssignation(recordInfo.Parameters[i].Identifier, this));
                }
                else if (scope.GetType(assignNode.Value.ExpressionType.Name).Name != scope.GetType(recordInfo.Parameters[i].Type).Name)
                    errors.Add(SemanticError.WrongType(assignNode.Value.ExpressionType.Name, recordInfo.Parameters[i].Type, this));

                FieldInitialicer[i].ILName = RecordIdentifier.ILName + string.Format(".{0}", assignNode.Field.Text);
            }
            ExpressionType = recordInfo;
            ExpressionType.ILName = scope.GetILTypeName(ExpressionType.Name);
        }
开发者ID:hansel0691,项目名称:Tiger,代码行数:42,代码来源:InstanceRecordNode.cs

示例7: CheckSemantics

        public override void CheckSemantics(Scope scope, List<SemanticError> errors)
        {
            CheckFunctionId(scope,errors);

            //check the return type is defined already
            if (!scope.ContainsType(ReturnType.Text))
            {
                errors.Add(SemanticError.TypeNotDefined(ReturnType.Text, this));
                return;
            }
            var newScope = CreateFunctionScope(scope, errors);
            Body.CheckSemantics(newScope, errors);

            if (Body.ExpressionType.Type == TypesEnumeration.Nil)
            {
                if (!scope.GetType(ReturnType.Text).Nilable)
                    errors.Add(SemanticError.InvalidNilAssignation(ReturnType.Text,this));
            }
            else if (Body.ExpressionType.Name != scope.GetType(ReturnType.Text).Name)
                errors.Add(SemanticError.WrongType(ReturnType.Text, Body.ExpressionType.Name, this));

            ReturnType.ILName = ReturnType != null ? scope.GetILTypeName(ReturnType.Text) : "voidScope0";
            Identifier.ILName = string.Format("{0}Scope{1}", Identifier, scope.CurrentScope);
        }
开发者ID:hansel0691,项目名称:Tiger,代码行数:24,代码来源:FunctionDeclarationNode.cs

示例8: CheckSemantics

 public override void CheckSemantics(Scope scope, List<SemanticError> errors)
 {
     CheckIdentifier(scope, errors);
     Identifier.ILName = string.Format("{0}Scope{1}", Identifier.Text, scope.CurrentScope);
     Alias.ILName = scope.GetILTypeName(Alias.Text);
 }
开发者ID:hansel0691,项目名称:Tiger,代码行数:6,代码来源:AliasDeclarationNode.cs

示例9: CheckSemantics

        public override void CheckSemantics(Scope scope, List<SemanticError> errors)
        {
            Value.CheckSemantics(scope, errors);

            if (scope.ContainsVarInstance(Identifier.Text, true) || scope.ContainsRoutine(Identifier.Text, true))
                errors.Add(SemanticError.DefinedVariable(Identifier.Text, this));
            if (Scope.standard_functions.Contains(Identifier.Text))
                errors.Add(SemanticError.HidingAnStandardFunc("Function", Identifier.Text, this));

            if (VariableType != null)
            {
                if (!scope.ContainsType(this.VariableType.Text))
                {
                    errors.Add(SemanticError.TypeNotDefined(this.VariableType.Text, this));
                    return;
                }
                //check if the value of the variable has the same type that the defined
                else if (Value.ExpressionType.Type == TypesEnumeration.Nil)
                {
                    if (!scope.GetType(VariableType.Text).Nilable)
                        errors.Add(SemanticError.InvalidNilAssignation(VariableType.Text, this));
                }
                else if (scope.GetType(this.Value.ExpressionType.Name).Name != scope.GetType(this.VariableType.Text).Name)
                    errors.Add(SemanticError.WrongType(this.VariableType.Text, this.Value.ExpressionType.Name, this));
            }
            else
            {
                switch (Value.ExpressionType.Type)
                {
                    case TypesEnumeration.Nil:
                        errors.Add(SemanticError.InvalidNilAssignation(Identifier.Text, this));
                        return;
                    case TypesEnumeration.Void:
                        errors.Add(SemanticError.NonValuedAssignation(this));
                        return;
                }
            }

            Identifier.ExpressionType = VariableType != null ? scope.GetType(VariableType.Text) : Value.ExpressionType;
            Identifier.ILName = string.Format("{0}Scope{1}", Identifier.Text, scope.CurrentScope);
            Value.ExpressionType.ILName = scope.GetILTypeName(Value.ExpressionType.Name);
        }
开发者ID:hansel0691,项目名称:Tiger,代码行数:42,代码来源:VariableDeclarationNode.cs

示例10: CheckSemantics

        public override void CheckSemantics(Scope scope, List<SemanticError> errors)
        {
            this.Length.CheckSemantics(scope, errors);
            this.DefaultValue.CheckSemantics(scope, errors);

            //check if the array identifier is defined
            var typeInfo = scope.GetType(this.ArrayIdentifier.Text);
            if (typeInfo == null)
            {
                errors.Add(SemanticError.TypeNotDefined(this.ArrayIdentifier.Text, this));
                return;
            }
            /*if (scope.GetType(typeInfo.Name).Name != scope.GetType(ArrayIdentifier.Text).Name)
            {
                errors.Add(SemanticError.WrongType(ExpressionType.Name, typeInfo.Name, this));
                return;
            }*/
            if (typeInfo.Type != TypesEnumeration.Array)
            {
                errors.Add(SemanticError.WrongType("Array", typeInfo.Name, this));
                return;
            }

            var arrayInfo = (ArrayInfo) typeInfo;
            //check if lenght is int
            if (this.Length.ExpressionType.Type != TypesEnumeration.Integer)
                errors.Add(SemanticError.InvalidNumber("The length", this));
            //default value must be the same type of the defined
            if (DefaultValue.ExpressionType.Type == TypesEnumeration.Nil)
            {
                if (!scope.GetType(arrayInfo.ItemsType).Nilable)
                    errors.Add(SemanticError.InvalidNilAssignation(arrayInfo.ItemsType, this));
            }
            else if (arrayInfo.ItemsType != scope.GetType(DefaultValue.ExpressionType.Name).Name)
                errors.Add(SemanticError.WrongType(arrayInfo.ItemsType, this.DefaultValue.ExpressionType.Name, this));

            this.ExpressionType = scope.GetType(ArrayIdentifier.Text);
            ArrayIdentifier.ILName = string.Format("{0}Scope{1}", ArrayIdentifier, scope.CurrentScope);
            DefaultValue.ILName = scope.GetILTypeName(arrayInfo.ItemsType);
        }
开发者ID:hansel0691,项目名称:Tiger,代码行数:40,代码来源:InstanceTypeArrayNode.cs


注:本文中的Scope.GetILTypeName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。