Esempio n. 1
0
        public static void Compile(JsCompiler compiler, JsClass klass, ObjectMethodId id)
        {
            var type = klass.Type;

            if (!type.IsEnum)
            {
                throw new InvalidOperationException("Type is not enum.");
            }

            switch (id)
            {
            case ObjectMethodId.Equals:
                //TODO: implement Equals for enums here
                JsStruct.Compile(compiler, klass, id);
                break;

            case ObjectMethodId.GetHashCode:
                CompileGetHashCode(compiler, klass);
                break;

            case ObjectMethodId.ToString:
                CompileToString(compiler, klass);
                break;

            default:
                throw new ArgumentOutOfRangeException("id");
            }
        }
Esempio n. 2
0
        private void CompileMethod(JsClass klass, ObjectMethodId id)
        {
            switch (klass.Type.TypeKind)
            {
            case TypeKind.Struct:
                JsStruct.Compile(this, klass, id);
                break;

            case TypeKind.Enum:
                JsEnum.Compile(this, klass, id);
                break;
            }
        }