Example #1
0
        private void ValidateMonetaryType()
        {
            if (UnitRef == null)
            {
                return;
            }

            // According to Table 3 in section 4.8.2 of the XBRL spec, monetary item units cannot use
            // ratios; they must be single measures. This condition is checked by test 304.26 in the
            // XBRL-CONF-CR5-2012-01-24 conformance suite.

            if (UnitRef.Ratio == true)
            {
                StringBuilder MessageBuilder = new StringBuilder();
                string        StringFormat   = AssemblyResources.GetName("RatioFoundInMonetaryItemUnit");
                MessageBuilder.AppendFormat(StringFormat, Name, UnitRef.Id);
                thisParentFragment.AddValidationError(new ItemValidationError(this, MessageBuilder.ToString()));
                return;
            }

            // Validate the unit's measure, if it exists.

            if (UnitRef.MeasureQualifiedNames.Count == 0)
            {
                return;
            }
            if (UnitRef.MeasureQualifiedNames[0] == null)
            {
                return;
            }

            string Uri = UnitRef.MeasureQualifiedNames[0].NamespaceUri;

            if (Uri == null)
            {
                StringBuilder MessageBuilder = new StringBuilder();
                string        StringFormat   = AssemblyResources.GetName("WrongMeasureNamespaceForMonetaryFact");
                MessageBuilder.AppendFormat(StringFormat, Name, UnitRef.Id, "unspecified");
                thisParentFragment.AddValidationError(new ItemValidationError(this, MessageBuilder.ToString()));
                return;
            }
            if ((Uri.Length > 0) && (Uri.Equals(XbrlDocument.XbrlIso4217NamespaceUri) == false))
            {
                StringBuilder MessageBuilder = new StringBuilder();
                string        StringFormat   = AssemblyResources.GetName("WrongMeasureNamespaceForMonetaryFact");
                MessageBuilder.AppendFormat(StringFormat, Name, UnitRef.Id, UnitRef.MeasureQualifiedNames[0].NamespaceUri);
                thisParentFragment.AddValidationError(new ItemValidationError(this, MessageBuilder.ToString()));
                return;
            }
            UnitRef.SetCultureAndRegionInfoFromISO4217Code(UnitRef.MeasureQualifiedNames[0].LocalName);
            if ((UnitRef.CultureInformation == null) && (UnitRef.RegionInformation == null))
            {
                StringBuilder MessageBuilder = new StringBuilder();
                string        StringFormat   = AssemblyResources.GetName("UnsupportedISO4217CodeForUnitMeasure");
                MessageBuilder.AppendFormat(StringFormat, Name, UnitRef.Id, UnitRef.MeasureQualifiedNames[0].LocalName);
                thisParentFragment.AddValidationError(new ItemValidationError(this, MessageBuilder.ToString()));
            }
        }
Example #2
0
 public RoutineDeclaration(
     Identifier name,
     bool isForeign,
     IEnumerable <Parameter> parameters,
     UnitRef returnType,
     IEnumerable <Entity> body,
     PreCondition preCondition   = null,
     PostCondition postCondition = null
     )
     : base(name)
 {
     IsForeign = isForeign;
     Parameters.AddRange(parameters);
     ReturnType = returnType;
     Body.AddRange(body);
     PreCondition  = preCondition ?? new PreCondition();
     PostCondition = postCondition ?? new PostCondition();
 }
Example #3
0
        public override void Stage1RoutineStubs()
        {
            var unitRef = new UnitRef(UnitName);

            var lhs   = new Identifier("lhs");
            var rhs   = new Identifier("rhs");
            var value = new Identifier("value");

            RegisterRoutine(new SLangRoutineDefinition(this,
                                                       new RoutineDeclaration(
                                                           new Identifier("operator+(Integer,Integer)"),
                                                           false,
                                                           new[]
            {
                new RoutineDeclaration.Parameter(unitRef, lhs),
                new RoutineDeclaration.Parameter(unitRef, rhs),
            },
                                                           unitRef,
                                                           new Entity[]
            {
                new Return(
                    new Call(Context.Intrinsics.GetCallee(new Identifier("add")), new[]
                {
                    new Reference(lhs),
                    new Reference(rhs),
                }))
            }
                                                           )));

            RegisterRoutine(new SLangRoutineDefinition(this,
                                                       new RoutineDeclaration(
                                                           new Identifier("operator-(Integer,Integer)"),
                                                           false,
                                                           new[]
            {
                new RoutineDeclaration.Parameter(unitRef, lhs),
                new RoutineDeclaration.Parameter(unitRef, rhs),
            },
                                                           unitRef,
                                                           new Entity[]
            {
                new Return(
                    new Call(new Callee(Intrinsics.UnitName, new Identifier("sub")), new[]
                {
                    new Reference(lhs),
                    new Reference(rhs),
                }))
            }
                                                           )));

            RegisterRoutine(new SLangRoutineDefinition(this,
                                                       new RoutineDeclaration(
                                                           new Identifier("operator-(Integer)"),
                                                           false,
                                                           new[]
            {
                new RoutineDeclaration.Parameter(unitRef, value),
            },
                                                           unitRef,
                                                           new Entity[]
            {
                new Return(
                    new Call(new Callee(Intrinsics.UnitName, new Identifier("neg")), new[]
                {
                    new Reference(value),
                }))
            }
                                                           )));

            RegisterRoutine(new SLangRoutineDefinition(this,
                                                       new RoutineDeclaration(
                                                           new Identifier("operator!(Integer)"),
                                                           false,
                                                           new[]
            {
                new RoutineDeclaration.Parameter(unitRef, value),
            },
                                                           unitRef,
                                                           new Entity[]
            {
                new Return(
                    new Call(new Callee(Intrinsics.UnitName, new Identifier("not")), new[]
                {
                    new Reference(value),
                }))
            }
                                                           )));

            RegisterRoutine(new SLangRoutineDefinition(this,
                                                       new RoutineDeclaration(
                                                           new Identifier("operator<(Integer,Integer)"),
                                                           false,
                                                           new[]
            {
                new RoutineDeclaration.Parameter(unitRef, lhs),
                new RoutineDeclaration.Parameter(unitRef, rhs),
            },
                                                           unitRef,
                                                           new Entity[]
            {
                new Return(
                    new Call(new Callee(Intrinsics.UnitName, new Identifier("clt")), new[]
                {
                    new Reference(lhs),
                    new Reference(rhs),
                }))
            }
                                                           )));

            RegisterRoutine(new SLangRoutineDefinition(this,
                                                       new RoutineDeclaration(
                                                           new Identifier("operator>(Integer,Integer)"),
                                                           false,
                                                           new[]
            {
                new RoutineDeclaration.Parameter(unitRef, lhs),
                new RoutineDeclaration.Parameter(unitRef, rhs),
            },
                                                           unitRef,
                                                           new Entity[]
            {
                new Return(
                    new Call(new Callee(Intrinsics.UnitName, new Identifier("cgt")), new[]
                {
                    new Reference(lhs),
                    new Reference(rhs),
                }))
            }
                                                           )));

            RegisterRoutine(new SLangRoutineDefinition(this,
                                                       new RoutineDeclaration(
                                                           new Identifier("operator==(Integer,Integer)"),
                                                           false,
                                                           new[]
            {
                new RoutineDeclaration.Parameter(unitRef, lhs),
                new RoutineDeclaration.Parameter(unitRef, rhs),
            },
                                                           unitRef,
                                                           new Entity[]
            {
                new Return(
                    new Call(new Callee(Intrinsics.UnitName, new Identifier("ceq")), new[]
                {
                    new Reference(lhs),
                    new Reference(rhs),
                }))
            }
                                                           )));

            base.Stage1RoutineStubs();
        }
Example #4
0
 public UnitReference(Context ctx, UnitRef unitRef) : this(ctx, unitRef.Name)
 {
 }
Example #5
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        UnitRef unitPreset = (UnitRef)target;

        EditorGUILayout.Space();
        GUILayout.Label("Size", EditorStyles.boldLabel);
        GUILayout.BeginHorizontal();

        if (unitPreset.agentType == 0)
        {
            GUILayout.Label("Tiny", EditorStyles.boldLabel);
        }
        else
        {
            if (GUILayout.Button("Tiny"))
            {
                unitPreset.agentType      = 0;
                unitPreset.colliderRadius = 0.1f;
            }
        }
        if (unitPreset.agentType == -334000983)
        {
            GUILayout.Label("Small", EditorStyles.boldLabel);
        }
        else
        {
            if (GUILayout.Button("Small"))
            {
                unitPreset.agentType      = -334000983;
                unitPreset.colliderRadius = 0.35f;
            }
        }
        if (unitPreset.agentType == 1479372276)
        {
            GUILayout.Label("Medium", EditorStyles.boldLabel);
        }
        else
        {
            if (GUILayout.Button("Medium"))
            {
                unitPreset.agentType      = 1479372276;
                unitPreset.colliderRadius = 0.6f;
            }
        }
        if (unitPreset.agentType == -1923039037)
        {
            GUILayout.Label("Large", EditorStyles.boldLabel);
        }
        else
        {
            if (GUILayout.Button("Large"))
            {
                unitPreset.agentType      = -1923039037;
                unitPreset.colliderRadius = 0.8f;
            }
        }
        if (unitPreset.agentType == -902729914)
        {
            GUILayout.Label("Huge", EditorStyles.boldLabel);
        }
        else
        {
            if (GUILayout.Button("Huge"))
            {
                unitPreset.agentType      = -902729914;
                unitPreset.colliderRadius = 1.2f;
            }
        }

        GUILayout.EndHorizontal();
    }
Example #6
0
 public VariableDeclaration(Identifier name, UnitRef type, Expression initializer)
     : base(name)
 {
     Type        = type;
     Initializer = initializer;
 }
Example #7
0
 public Parameter(UnitRef type, Identifier name)
 {
     Type = type;
     Name = name;
 }