Esempio n. 1
0
 public ObjectInstance(Engine engine, ObjectClass objectClass, InternalTypes type = InternalTypes.Object)
     : base(type)
 {
     _engine    = engine;
     _class     = objectClass;
     Extensible = true;
 }
Esempio n. 2
0
        /// <summary>
        /// http://www.ecma-international.org/ecma-262/6.0/#sec-topropertykey
        /// </summary>

        public static JsValue ToPropertyKey(JsValue o)
        {
            const InternalTypes stringOrSymbol = InternalTypes.String | InternalTypes.Symbol;

            return((o._type & stringOrSymbol) != 0
                ? o
                : ToPropertyKeyNonString(o));
        }
Esempio n. 3
0
 internal ObjectInstance(Engine engine, ObjectClass objectClass, InternalTypes type = InternalTypes.Object)
     : base(type)
 {
     _engine = engine;
     _class  = objectClass;
     // if engine is ready, we can take default prototype for object
     _prototype = engine.Realm.Intrinsics?.Object?.PrototypeObject;
     Extensible = true;
 }
Esempio n. 4
0
        private static JsValue ToPropertyKeyNonString(JsValue o)
        {
            const InternalTypes stringOrSymbol = InternalTypes.String | InternalTypes.Symbol;
            var primitive = ToPrimitive(o, Types.String);

            return((primitive._type & stringOrSymbol) != 0
                ? primitive
                : ToStringNonString(primitive));
        }
Esempio n. 5
0
        private static bool EqualUnlikely(JsValue x, JsValue y)
        {
            if (x._type == InternalTypes.Null && y._type == InternalTypes.Undefined)
            {
                return(true);
            }

            if (x._type == InternalTypes.Undefined && y._type == InternalTypes.Null)
            {
                return(true);
            }

            if (x.IsNumber() && y.IsString())
            {
                return(Equal(x, TypeConverter.ToNumber(y)));
            }

            if (x.IsString() && y.IsNumber())
            {
                return(Equal(TypeConverter.ToNumber(x), y));
            }

            if (x.IsBoolean())
            {
                return(Equal(TypeConverter.ToNumber(x), y));
            }

            if (y.IsBoolean())
            {
                return(Equal(x, TypeConverter.ToNumber(y)));
            }

            const InternalTypes stringOrNumber = InternalTypes.String | InternalTypes.Integer | InternalTypes.Number;

            if (y.IsObject() && (x._type & stringOrNumber) != 0)
            {
                return(Equal(x, TypeConverter.ToPrimitive(y)));
            }

            if (x.IsObject() && ((y._type & stringOrNumber) != 0))
            {
                return(Equal(TypeConverter.ToPrimitive(x), y));
            }

            return(false);
        }
Esempio n. 6
0
        public virtual SyntaxNode ToSyntaxNode(SyntaxGenerator syntaxGenerator)
        {
            var methodsSyntaxNodes       = Methods.Select(method => method.ToSyntaxNode(syntaxGenerator));
            var internalTypesSyntaxNodes = InternalTypes.Select(internalType => internalType.ToSyntaxNode(syntaxGenerator));

            var declarationModifiers = DeclarationModifiers.None.WithPartial(IsPartial);

            var typeSyntaxNode = syntaxGenerator.ClassDeclaration(Name,
                                                                  accessibility: Accessibility,
                                                                  modifiers: declarationModifiers,
                                                                  members: methodsSyntaxNodes.Union(internalTypesSyntaxNodes));

            foreach (var baseType in BaseTypes)
            {
                var baseTypeSyntaxNode = baseType.ToSyntaxNode(syntaxGenerator);
                typeSyntaxNode = syntaxGenerator.AddBaseType(typeSyntaxNode, baseTypeSyntaxNode);
            }

            syntaxGenerator.AddMembers(typeSyntaxNode, Methods.Select(method => method.ToSyntaxNode(syntaxGenerator)));

            return(typeSyntaxNode);
        }
Esempio n. 7
0
 public virtual void VisitSimulation(InternalTypes.Simulation n)
 {
 }
Esempio n. 8
0
 public virtual void VisitSettings(InternalTypes.Settings n)
 {
 }
Esempio n. 9
0
 public virtual void VisitSecurities(InternalTypes.Securities n)
 {
 }
Esempio n. 10
0
 public virtual void VisitPrincipalRules(InternalTypes.PrincipalRules n)
 {
 }
Esempio n. 11
0
 public virtual void VisitDeal(InternalTypes.Deal n)
 {
 }
Esempio n. 12
0
 public virtual void VisitCollateralItem(InternalTypes.CollateralItem n)
 {
 }
Esempio n. 13
0
 internal JsValue(InternalTypes type)
 {
     _type = type;
 }
Esempio n. 14
0
 protected JsValue(Types type)
 {
     _type = (InternalTypes)type;
 }
Esempio n. 15
0
 public virtual void VisitBond(InternalTypes.Bond n)
 {
 }
Esempio n. 16
0
 public virtual void VisitCollateral(InternalTypes.Collateral n)
 {
 }
Esempio n. 17
0
 public virtual void VisitInterestRules(InternalTypes.InterestRules n)
 {
 }
Esempio n. 18
0
 public virtual void VisitCreditPaymentRules(InternalTypes.CreditPaymentRules n)
 {
 }
Esempio n. 19
0
 public virtual void VisitInternalRuleListAnd(InternalTypes.InternalRuleListAnd n)
 {
 }
Esempio n. 20
0
 private JsString(string value, InternalTypes type) : base(type)
 {
     _value = value;
 }
Esempio n. 21
0
 public virtual void VisitInternalRuleListOr(InternalTypes.InternalRuleListOr n)
 {
 }