Beispiel #1
0
        private AbcMethod BuildSetterImpl(IMethod method, AbcInstance instance)
        {
            if (method.IsStatic)
            {
                return(null);
            }
            var type = method.DeclaringType;

            if (!type.IsArray)
            {
                return(null);
            }
            if (method.Name != CLRNames.Array.Setter)
            {
                return(null);
            }

            var name = _generator.MethodBuilder.DefineQName(method);

            return(instance.DefineMethod(
                       Sig.@this(name, method.Type, method),
                       code =>
            {
                int n = method.Parameters.Count;
                code.LoadThis();
                ToFlatIndex(code, n, false);
                code.GetLocal(n);                                 //value
                code.SetArrayElem(false);
                code.ReturnVoid();
            }));
        }
Beispiel #2
0
        private AbcMethod CreateSystemArraySZ()
        {
            return(Instance.DefineMethod(
                       Sig.@static("__create_sz_array__", Instance.Name, AvmTypeCode.Int32, "size"),
                       code =>
            {
                const int varSize = 1;
                const int varArray = 2;

                code.CreateInstance(Instance);
                code.SetLocal(varArray);

                code.GetLocal(varArray);
                code.CreateArrayVarSize(varSize);
                code.SetProperty(Const.Array.Value);

                //NOTE: explicitly set rank because we did not call default ctor for System.Array
                code.GetLocal(varArray);
                code.PushInt(1);
                code.SetProperty(Const.Array.Rank);

                code.GetLocal(varArray);
                code.ReturnValue();
            }));
        }
Beispiel #3
0
        private AbcMethod BuildGetterImpl(IMethod method, AbcInstance instance)
        {
            if (method.IsStatic)
            {
                return(null);
            }
            var type = method.DeclaringType;

            if (!type.IsArray)
            {
                return(null);
            }
            if (method.Name != CLRNames.Array.Getter)
            {
                return(null);
            }

            //string name = "Get" + NameUtil.GetParamsString(method);
            var name = _generator.MethodBuilder.DefineQName(method);

            return(instance.DefineMethod(
                       Sig.@this(name, method.Type, method),
                       code =>
            {
                code.LoadThis();
                ToFlatIndex(code, method.Parameters.Count, true);
                code.GetArrayElem(method.Type, false);
                code.ReturnValue();
            }));
        }
Beispiel #4
0
 // note. we need this constructor to provide information
 // about method's parameters without having to decompile it
 //
 // the point is that to get sig's symbols we've got to know their ids
 // but the ids need to be synchronized with Refs in decompiled body
 // that's why a simple call to Sig::Syms need to decompile the entire body
 public ParamInfo(Sig sig, int index, String name, Type type)
 {
     Sig = sig;
     Index = index;
     Name = name.IsNullOrEmpty() ? "$p" + index : name;
     Type = type;
 }
Beispiel #5
0
        private AbcMethod BoxNullable(IType type)
        {
            if (!type.IsNullableInstance())
            {
                return(null);
            }

            var instance = _generator.TypeBuilder.BuildInstance(type);

            var arg         = type.GetTypeArgument(0);
            var argInstance = _generator.TypeBuilder.BuildInstance(arg);

            return(instance.DefineMethod(
                       Sig.@static(BoxName, argInstance.Name, type, "value"),
                       code =>
            {
                const int value = 1;
                code.If(
                    //hasValue?
                    () =>
                {
                    code.GetLocal(value);
                    code.Nullable_HasValue(true);
                    return code.IfTrue();
                },
                    () =>
                {
                    code.Box(arg, () => code.GetBoxedValue(value));
                    code.ReturnValue();
                },
                    () => code.ReturnNull()
                    );
            }));
        }
Beispiel #6
0
        private static AbcMethod GetHashCodeDic(AbcGenerator generator)
        {
            var instance = generator.RuntimeImpl.Instance;

            var dicType = generator.Abc.DefineName(QName.Package("flash.utils", "Dictionary"));
            var dic     = instance.DefineStaticSlot("hcdic$", dicType);

            return(instance.DefineMethod(
                       Sig.@static("get_hashcode_dic", dicType),
                       code =>
            {
                code.LoadThis();
                code.GetProperty(dic);
                var br = code.IfNotNull();

                code.LoadThis();
                code.CreateInstance(dicType);
                code.SetProperty(dic);

                br.BranchTarget = code.Label();
                code.LoadThis();
                code.GetProperty(dic);
                code.ReturnValue();
            }));
        }
Beispiel #7
0
        public String SignalMesasageSearch(String InputSignalName, StreamReader reader)
        {
            //Objective: Search Related message to the input Signal
            //Input    : SignalName and OpenFile Stream
            //OutPut   : Returns Message Related to the input Signal
            string line;
            String EncodedSignal = null;

            reader.BaseStream.Seek(0, System.IO.SeekOrigin.Begin);
            while ((line = reader.ReadLine()) != null)
            {
                if (line == "Signal_representation {")
                {
                    while ((line = reader.ReadLine()) != "}")
                    {
                        string[] Signal      = line.Split(':');
                        string[] SignalSplit = Signal[1].Split(',');
                        foreach (string Sig in SignalSplit)
                        {
                            if (Sig.Trim(new Char[] { ';', ' ' }) == InputSignalName)
                            {
                                EncodedSignal = Signal[0].Trim();
                            }
                        }
                    }
                }
            }
            return(EncodedSignal + " {");// In Signal Encoding It Searches for Message and {
        }
        public override void ValidaTipo(List <ElementoTS> tablaSimbolos, Queue <string> errores)
        {
            char tipodato2, tipodato3;//si el tipo dato es '\0' entonces no hay que validar que coincida

            derecha.Ambito   = Ambito;
            derecha.TipoDato = TipoDato;
            derecha.ValidaTipo(tablaSimbolos, errores);
            tipodato3 = derecha.TipoDato;
            if (tipodato3 == 'e')
            {
                if (derecha.Token.Nombre != "Operacion" && derecha.Token.Nombre != "")
                {
                    errores.Enqueue("La variable: " + derecha.Token.Lexema + " no ha sido declarada");
                }
            }
            if (izquierda != null)//tiene izquierda
            {
                izquierda.Ambito   = Ambito;
                izquierda.TipoDato = TipoDato;
                izquierda.ValidaTipo(tablaSimbolos, errores);
                tipodato2 = izquierda.TipoDato;
                if (tipodato2 == 'e')
                {
                    if (izquierda.Token.Nombre != "Operacion" && derecha.Token.Nombre != "")
                    {
                        errores.Enqueue("La variable: " + izquierda.Token.Lexema + " no ha sido declarada");
                    }
                }
                if (tipodato2 == tipodato3 && tipodato2 != 'e')
                {
                    if (Sig != null)
                    {
                        Sig.ValidaTipo(tablaSimbolos, errores);
                    }
                }
                else
                {
                    string der, izq;
                    if (derecha.Token.Nombre != "Operacion" && derecha.Token.Nombre != "")
                    {
                        der = derecha.Token.Lexema;
                    }
                    else
                    {
                        der = "Operacion derecha";
                    }
                    if (izquierda.Token.Nombre != "Operacion" && izquierda.Token.Nombre != "")
                    {
                        izq = izquierda.Token.Lexema;
                    }
                    else
                    {
                        izq = "Operacion izquieda";
                    }
                    errores.Enqueue("Los tipos de datos entre " + izq + " y " + der + " son distintos");
                    tipodato3 = 'e';
                }
            }
            TipoDato = tipodato3;
        }
Beispiel #9
0
        void DefinePrototype(AvmTypeCode type, AbcMethod sig)
        {
            var srcmethod = sig.Method;

            if (srcmethod == null)
            {
                return;
            }

            string key = GetKey(type, srcmethod.Name);
            var    val = _prototypes[key] as object[];

            if (val == null)
            {
                return;
            }

            var m = val[1] as AbcMethod;

            if (m != null)
            {
                return;
            }

            var coder = val[0] as AbcCoder;

            m = Abc.DefineMethod(Sig.@from(sig), coder);

            _generator.NewApi.SetProtoFunction(type, sig.TraitName, m);

            val[0] = m;
        }
        public override void ValidaTipo(List <ElementoTS> tablaSimbolos, Queue <string> errores)
        {
            TipoDato = BuscarTablaSimbolos(tablaSimbolos, id.Token.Lexema, Ambito);
            char tipo1 = TipoDato;

            if (TipoDato == 'e')
            {
                errores.Enqueue("La variable " + id.Token.Lexema + " no ha sido declarada");
            }
            if (expresion != null)
            {
                expresion.Ambito   = Ambito;
                expresion.TipoDato = tipo1;
                expresion.ValidaTipo(tablaSimbolos, errores);
            }
            char tipo2 = expresion.TipoDato;

            if (tipo1 != tipo2)
            {
                errores.Enqueue("El tipo de dato de " + id.Token.Lexema + " en la funcion " + Ambito + " es diferente de la expresion.");
            }
            if (Sig != null)
            {
                Sig.Ambito = Ambito;
                Sig.ValidaTipo(tablaSimbolos, errores);
            }
        }
 public virtual void ValidaTipo(List <ElementoTS> tablaSimbolos, Queue <string> errores)
 {
     if (Sig != null)
     {
         Sig.ValidaTipo(tablaSimbolos, errores);
     }
     if (Token != null)
     {
         if (Token.Nombre != "null")
         {
             if (EsInt(Token.Lexema))
             {
                 TipoDato = 'i';
             }
             else if (EsFloat(Token.Lexema))
             {
                 TipoDato = 'f';
             }
             else
             {
                 TipoDato = BuscarTablaSimbolos(tablaSimbolos, Token.Lexema, Ambito);
             }
         }
     }
 }
        public override void ValidaTipo(List <ElementoTS> tablaSimbolos, Queue <string> errores)
        {
            TipoDato = GetTipoDato(tipo);
            string nombre = id.Token.Lexema;

            if (BuscarTablaSimbolos(tablaSimbolos, nombre, Ambito) != 'e')
            {
                errores.Enqueue("La variable: " + nombre + " ya fue declarada");
            }
            else
            {
                tablaSimbolos.Add(new ElementoTS(nombre, TipoDato, Ambito, ""));
            }
            CadenaParametros += tipo[0];
            if (listaParam != null)
            {
                listaParam.Ambito           = Ambito;
                listaParam.CadenaParametros = CadenaParametros;
                listaParam.ValidaTipo(tablaSimbolos, errores);
                CadenaParametros = listaParam.CadenaParametros;
            }
            if (Sig != null)
            {
                Sig.Ambito = Ambito;
                Sig.ValidaTipo(tablaSimbolos, errores);
            }
        }
Beispiel #13
0
        private AbcMethod DefineCustomAttributesInitializer(AbcInstance instance, ICustomAttributeProvider provider)
        {
            instance = FixInstance(instance);

            var provname = provider.GetQName();

            if (provname == null)
            {
                provname = NameDummyCounter.ToString();
                ++NameDummyCounter;
            }
            var name = _generator.Abc.DefineName(QName.PfxPublic("init_custom_attrs_" + provname));

            return(instance.DefineMethod(
                       Sig.@static(name, _generator.Corlib.Array.Instance),
                       code =>
            {
                const int arr = 1;
                const int varAttr = 2;

                code.NewArray(arr, SystemTypes.Object, provider.CustomAttributes,
                              attr => NewAttribute(code, attr, varAttr));

                code.ReturnValue();
            }));
        }
Beispiel #14
0
        public AbcMethod Exit()
        {
            var instance = _generator.Corlib.Environment.Instance;

            return(instance.DefineMethod(
                       Sig.@static("exit_impl", AvmTypeCode.Void, AvmTypeCode.Int32, "exitCode"),
                       code =>
            {
                var isFlash = IsFlashPlayer();
                code.Getlex(isFlash);
                code.Call(isFlash);
                var ifNotFlash = code.IfFalse();

                var ns = Abc.DefinePackage("avmplus");
                var mn = Abc.DefineQName(ns, "System");
                code.Getlex(mn);
                mn = Abc.DefineQName(ns, "exit");
                code.GetLocal(1);                                 //exitCode
                code.Call(mn, 1);
                code.ReturnVoid();

                ifNotFlash.BranchTarget = code.Label();

                ns = Abc.DefinePackage("flash.System");
                mn = Abc.DefineQName(ns, "System");
                code.Getlex(mn);
                mn = Abc.DefineQName(ns, "exit");
                code.GetLocal(1);                                 //exitCode
                code.Add(InstructionCode.Coerce_u);               //???
                code.Call(mn, 1);
                code.ReturnVoid();
            }));
        }
Beispiel #15
0
        private AbcMethod BuildAddressImpl(IMethod method, AbcInstance instance)
        {
            if (method.IsStatic)
            {
                return(null);
            }
            var type = method.DeclaringType;

            if (!type.IsArray)
            {
                return(null);
            }
            if (method.Name != CLRNames.Array.Address)
            {
                return(null);
            }

            var elemPtr = _generator.Pointers.ElemPtr.Instance;

            string name = "GetAddr_" + method.GetParametersSignature(Runtime.Avm);

            return(instance.DefineMethod(
                       Sig.@this(name, elemPtr.Name, method),
                       code =>
            {
                code.Getlex(elemPtr);
                code.LoadThis();                                 //arr
                ToFlatIndex(code, method.Parameters.Count, true);
                code.Construct(2);
                code.ReturnValue();
            }));
        }
Beispiel #16
0
        private AbcMethod CastToDefaultImpl(IType type, bool cast)
        {
            const bool me = true;

            if (cast)
            {
                var AS = CastToDefaultImpl(type, false);
                return(Impl(type, AS, GetCastMethodName(type, me)));
            }

            var instance = _generator.TypeBuilder.BuildInstance(type);
            var typeName = _generator.TypeBuilder.BuildMemberType(type);
            var name     = GetAsMethodName(type, me);

            return(instance.DefineMethod(
                       Sig.@static(name, typeName, AvmTypeCode.Object, "value"),
                       code =>
            {
                const int value = 1;
                code.BeginAsMethod();

                code.Try();
                code.GetLocal(value);
                code.Coerce(typeName);
                code.ReturnValue();

                code.CatchReturnNull();
            }));
        }
Beispiel #17
0
        public AbcMethod IsFlashPlayer()
        {
            var instance = _generator.Corlib.Environment.Instance;

            return(instance.DefineMethod(
                       Sig.get("isFlash", Abc.BuiltinTypes.RealBoolean).@static(),
                       code =>
            {
                var isFlash = instance.DefineStaticSlot("__isFlash", AvmTypeCode.Boolean);
                var isFlashInitialized =
                    instance.DefineStaticSlot("__isFlashInitialized", AvmTypeCode.Boolean);

                code.GetLocal(0);
                code.GetProperty(isFlashInitialized);

                var ifTrue = code.IfTrue();

                code.GetLocal(0);
                code.GetLocal(0);
                var m = IsFlashPlayerInternal();
                code.Call(m);
                code.SetProperty(isFlash);

                ifTrue.BranchTarget = code.Label();

                code.GetLocal(0);
                code.GetProperty(isFlash);
                code.FixBool();
                code.ReturnValue();
            }));
        }
Beispiel #18
0
        /// <summary>
        /// Creates cast_to_type method via given AS method
        /// </summary>
        /// <param name="type"></param>
        /// <param name="AS"></param>
        /// <returns></returns>
        private AbcMethod Impl(IType type, AbcMethod AS, AbcMultiname name)
        {
            var instance = AS.Instance;

            var typeName = _generator.TypeBuilder.BuildMemberType(type);

            return(instance.DefineMethod(
                       Sig.@static(name, typeName, AvmTypeCode.Object, "value"),
                       code =>
            {
                const int value = 1;

                code.GetLocal(value);
                code.IfNullReturnNull(1);

                code.Getlex(instance);
                code.GetLocal(value);
                code.Call(AS);
                code.SetLocal(value);

                code.GetLocal(value);
                var notNull = code.IfNotNull(false);
                code.ThrowInvalidCastException(type);

                notNull.BranchTarget = code.Label();
                code.GetLocal(value);
                code.ReturnValue();
            }));
        }
 public async Task <Sig> SigInfo(string id)
 {
     using (Sig Signer = new Sig(id))
     {
         return(Signer);
     }
 }
Beispiel #20
0
        public AbcMethod ToStringImpl()
        {
            var instance = _generator.TypeBuilder.BuildInstance(SystemTypes.String);

            return(instance.DefineMethod(
                       Sig.@static("cast_to_me", AvmTypeCode.String, AvmTypeCode.Object, "value"),
                       code =>
            {
                const int value = 1;

                code.IfNullReturnNull(value);

                code.If(
                    () =>
                {
                    code.GetLocal(value);
                    code.Is(AvmTypeCode.String);
                    return code.IfTrue();
                },
                    () =>
                {
                    code.GetLocal(value);
                    code.CoerceString();
                    code.ReturnValue();
                },
                    () => code.ThrowInvalidCastException()
                    );
            }));
        }
Beispiel #21
0
 public ParamInfo(Sig sig, int index)
 {
     Sig = sig;
     Index = index;
     Name = Sym.Name;
     Type = Sym.Type;
 }
Beispiel #22
0
        public AbcMethod InitImpl(IType elemType)
        {
            if (!InternalTypeExtensions.IsInitArray(elemType))
            {
                return(null);
            }

            if (elemType.IsEnum)
            {
                elemType = elemType.ValueType;
            }

            string name = "init_" + elemType.GetSigName();

            return(Instance.DefineMethod(
                       Sig.@static(name, AvmTypeCode.Void,
                                   AvmTypeCode.Array, "arr",
                                   AvmTypeCode.Int32, "size"),
                       code =>
            {
                var init = InitImpl();
                var f = DefineInitObjectMethod(elemType);

                code.LoadThis();
                code.GetLocal(1);
                code.GetLocal(2);
                code.Getlex(f.Instance);
                code.GetProperty(f.TraitName);
                code.Call(init);
                code.ReturnVoid();
            }));
        }
        void ui_SigChange(BasicTriList currentDevice, SigEventArgs args)
        {
            Sig sig = args.Sig;

            OnDebug(eDebugEventType.Info, "{0} SigChange in {1} type: {2}, sig: {3}, Name: {4}", currentDevice.ToString(), currentDevice.ID.ToString(), sig.Type.ToString(), sig.Number.ToString(), sig.Name);
            switch (sig.Type)
            {
            case eSigType.Bool:
                if (sig.BoolValue)     // press
                {
                    OnDebug(eDebugEventType.Info, "Press event on sig number: {0}", sig.Number);
                    switch (sig.Number)
                    {
                    case DIG_TOGGLE_POWER:
                        UI.ToggleDigitalJoin(currentDevice, sig.Number);
                        break;

                    case DIG_MACRO:
                        UI.PulseDigitalJoin(currentDevice, DIG_TOGGLE_POWER);
                        var randomNumber = new Random().Next(ushort.MaxValue);
                        UI.SetAnalogJoin(currentDevice, ANA_RANDOM, (ushort)randomNumber);
                        UI.SetSerialJoin(currentDevice, SER_VALUE, randomNumber.ToString());
                        break;
                    }
                }
                else     // release
                {
                }
                break;

            case eSigType.UShort:
                OnDebug(eDebugEventType.Info, "UShortValue: {0}", sig.UShortValue.ToString());
                switch (sig.Number)
                {
                case ANA_BAR_GRAPH:
                    UI.SetAnalogJoin(currentDevice, sig.Number, sig.UShortValue);
                    UI.SetSerialJoin(currentDevice, SER_VALUE, sig.UShortValue.ToString());
                    break;

                case ANA_RANDOM:
                    UI.SetAnalogJoin(currentDevice, ANA_BAR_GRAPH, sig.UShortValue);
                    break;
                }
                break;

            case eSigType.String:
                OnDebug(eDebugEventType.Info, "StringValue: {0}", sig.StringValue);
                switch (sig.Number)
                {
                case SER_INPUT:
                    UI.SetSerialJoin(currentDevice, SER_VALUE, sig.StringValue.ToString());
                    break;
                }
                break;

            default:
                OnDebug(eDebugEventType.Info, "Unhandled sig type: {0}", sig.Type.ToString());
                break;
            }
        }
Beispiel #24
0
        //returns true if passed object is null
        public AbcMethod IsNullImpl()
        {
            var instance = _generator.Corlib.SystemType.Instance;

            return(instance.DefineMethod(
                       Sig.@static("IsNull", AvmTypeCode.Boolean, AvmTypeCode.Object, "value"),
                       code =>
            {
                const int value = 1;

                code.GetLocal(value);
                var notNull = code.IfNotNull();
                code.PushNativeBool(true);
                code.ReturnValue();

                notNull.BranchTarget = code.Label();
                code.Try();

                code.GetLocal(value);
                code.Nullable_HasValue(true);
                code.Add(InstructionCode.Not);
                code.ReturnValue();

                code.BeginCatch();
                code.Pop();
                code.PushNativeBool(false);
                code.ReturnValue();
                code.EndCatch(true);
            }));
        }
Beispiel #25
0
        private static void DefineDebugCollectionView(AbcGenerator generator, AbcInstance instance)
        {
            var name = generator.Abc.DefineName(QName.Global(DebugPropertyPrefix + "collection$view"));

            if (instance.FindSuperTrait(name, AbcTraitKind.Getter) != null)
            {
                return;
            }

            if (IsDictionary(generator, instance.Type))
            {
                instance.DefineMethod(
                    Sig.get(DebugPropertyPrefix + "dictionary$marker", AvmTypeCode.Boolean),
                    code =>
                {
                    code.PushNativeBool(true);
                    code.ReturnValue();
                });
            }

            instance.DefineMethod(
                Sig.get(name, AvmTypeCode.Array),
                code =>
            {
                var m = generator.Corlib.GetMethod(CompilerMethodId.ToArray);
                code.Getlex(m);
                code.LoadThis();
                code.Call(m);
                code.ReturnValue();
            });
        }
Beispiel #26
0
        private static bool DefineDebuggerDisplay(AbcGenerator generator, IType type, AbcInstance instance, ICustomAttribute attr)
        {
            if (attr.Arguments.Count != 1)
            {
                return(false);
            }
            var display = attr.Arguments[0].Value as string;

            if (string.IsNullOrEmpty(display))
            {
                return(false);
            }
            if (!display.CheckFormatBraceBalance())
            {
                CompilerReport.Add(Warnings.InvalidDebuggerDisplayString, display);
                return(false);
            }

            var name = generator.Abc.DefineName(QName.Global(DebugPropertyPrefix + "display$exp"));

            //TODO: Parse display string to build string
            var m = instance.DefineMethod(
                Sig.get(name, AvmTypeCode.String),
                code =>
            {
                code.PushString(display);
                code.ReturnValue();
            });

            m.Trait.IsVirtual  = !type.IsSealed;
            m.Trait.IsOverride = instance.FindSuperTrait(name, AbcTraitKind.Getter) != null;

            return(true);
        }
Beispiel #27
0
        private void DefineFlexAppInitializer(AbcInstance instance)
        {
            Debug.Assert(instance.Initializer == null);

            instance.Initializer = Abc.DefineMethod(
                Sig.@global(null),
                code =>
            {
                code.PushThisScope();
                code.ConstructSuper();

                code.Trace("PFC: calling App.initializer");

                CtorAfterSuperCall(code);

                if (!IsFlex4)
                {
                    var ctor = instance.FindParameterlessConstructor();
                    if (ctor != null)
                    {
                        var ctorMethod = _generator.MethodBuilder.BuildAbcMethod(ctor);
                        AddEventListener(code, ctorMethod, FlexAppEvents.Initialize);
                    }
                }

                code.ReturnVoid();
            });
        }
 public override int GetHashCode()
 {
     return(PersonId.GetHashCode() ^
            ConceptId.GetHashCode() ^
            TypeConceptId.GetHashCode() ^
            (SourceValue != null ? SourceValue.GetHashCode() : 0) ^
            (StopReason != null ? StopReason.GetHashCode() : 0) ^
            Refills.GetHashCode() ^
            VisitOccurrenceId.GetHashCode() ^
            Quantity.GetHashCode() ^
            DaysSupply.GetHashCode() ^
            RouteConceptId.GetHashCode() ^
            EffectiveDrugDose.GetHashCode() ^
            DoseUnitConceptId.GetHashCode() ^
            SourceConceptId.GetHashCode() ^
            (Sig != null ? Sig.GetHashCode() : 0) ^
            (LotNumber != null ? LotNumber.GetHashCode() : 0) ^
            (RouteSourceValue != null ? RouteSourceValue.GetHashCode() : 0) ^
            (DoseUnitSourceValue != null ? DoseUnitSourceValue.GetHashCode() : 0) ^
            ProviderId.GetHashCode() ^
            (StartDate.GetHashCode()) ^
            (EndDate.GetHashCode()) ^
            (VerbatimEndDate.GetHashCode()) ^
            (StartTime != null ? StartTime.GetHashCode() : 0) ^
            (EndTime != null ? EndTime.GetHashCode() : 0));
 }
        public static void DetachSigEventHandler(this Sig cue, UnifiedSigEventHandler handler)
        {
            eSigEvent eventType;

            switch (cue.Type)
            {
            case eSigType.Bool:
                eventType = eSigEvent.BoolChange;
                break;

            case eSigType.UShort:
                eventType = cue.IsInput ? eSigEvent.UShortInputRamping : eSigEvent.UShortChange;
                break;

            case eSigType.String:
                eventType = eSigEvent.StringChange;
                break;

            default:
                eventType = eSigEvent.NA;
                break;
            }

            cue.DetachSigEventHandler(handler, eventType);
        }
Beispiel #30
0
        /// <summary>
        /// Defines static method to call this ctor.
        /// </summary>
        /// <param name="ctor">this ctor</param>
        /// <returns></returns>
        public AbcMethod DefineCtorStaticCall(IMethod ctor)
        {
            Debug.Assert(ctor.IsConstructor);
            Debug.Assert(!ctor.IsStatic);

            var thisCtor = _generator.MethodBuilder.BuildAbcMethod(ctor);

            if (thisCtor.IsInitializer)
            {
                throw new InvalidOperationException("ctor is initializer");
            }

            var declType = ctor.DeclaringType;
            var instance = BuildInstance(declType);

            return(instance.DefineMethod(
                       Sig.@static(thisCtor.TraitName.NameString + "__static", instance.Name, thisCtor),
                       code =>
            {
                code.PushThisScope();
                code.CreateInstance(instance);
                code.Dup();
                code.LoadArguments(ctor);
                code.Call(thisCtor);
                code.ReturnValue();
            }));
        }
Beispiel #31
0
        private AbcMethod BuildUnary(IMethod op)
        {
            if (op == null)
            {
                throw new ArgumentNullException("op");
            }

            var abcOp = _generator.MethodBuilder.BuildAbcMethod(op);

            var instance = _generator.TypeBuilder.BuildInstance(op.DeclaringType);

            string name     = "this_" + abcOp.TraitName.NameString;
            var    thisName = Abc.DefineName(QName.Global(name));
            var    retType  = _generator.TypeBuilder.BuildReturnType(op.Type);

            return(instance.DefineMethod(
                       Sig.@this(thisName, retType),
                       code =>
            {
                code.Getlex(instance);
                code.GetLocal(0);
                code.Call(abcOp);
                code.Coerce(op.Type, true);
                code.ReturnValue();
            }));
        }
Beispiel #32
0
        public AbcMethod Build(BinaryOperator op, IType left, IType right)
        {
            var method = Find(op, left, right);

            if (method == null)
            {
                throw new InvalidOperationException();
            }

            var abcOp = _generator.MethodBuilder.BuildAbcMethod(method);

            var instance = _generator.TypeBuilder.BuildInstance(method.DeclaringType);

            Debug.Assert(instance.Abc == Abc);

            string name     = "this_" + abcOp.TraitName.NameString;
            var    thisName = Abc.DefineName(QName.Global(name));
            var    retType  = _generator.TypeBuilder.BuildReturnType(method.Type);

            return(instance.DefineMethod(
                       Sig.@this(thisName, retType, right, "right"),
                       code =>
            {
                code.Getlex(instance);
                code.GetLocal(0);                         //left
                code.GetLocal(1);                         //right
                code.Call(abcOp);
                code.Coerce(retType);
                code.ReturnValue();
            }));
        }
Beispiel #33
0
        void parseForSignatures()
        {
            // Split the input into lines, and weed out only the ones with sig values.
            IEnumerable<string> verbLines = _code
            .Split('\n')
            .Where(l => isVerbLine( l ) )
            .Select( l => l.Substring( l.IndexOf( "verb" ) + 4 ).Trim() );

            // Process each one into a sig...
            List<Sig> newSigs = new List<Sig>();
            foreach (string verbLine in verbLines) {
            string[] p = verbLine.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
            Sig sig = new Sig();
            if (p.Length > 0) {
                if( p[0].EqualsI( "*" ) )
                    sig.wildcard = true;
                else
                {
                    // Direct object.
                    sig.dobj = ParseSpecifier(p[0]);
                }
            }
            if (p.Length > 1) {
                // Preposition.
                sig.prep = ParsePrep(p[1]);
            }
            if (p.Length > 2) {
                // Indirect object.
                sig.iobj = ParseSpecifier(p[2]);
            }
            if (p.Length > 3) {
                // Second preposition.
                sig.prep2 = ParsePrep(p[3]);
            }
            if (p.Length > 4) {
                // Second indirect object.
                sig.iobj2 = ParseSpecifier(p[4]);
            }
            newSigs.Add(sig);
            }
            this.signatures = newSigs;
        }
Beispiel #34
0
        static bool MatchSig(VerbParameters param, Sig s)
        {
            if (s.wildcard)
            return true;

            return MatchObj(param, param.dobj, s.dobj)
            && MatchPrep(param.prep, s.prep)
            && MatchObj(param, param.iobj, s.iobj)
            && MatchPrep(param.prep2, s.prep2)
            && MatchObj(param, param.iobj2, s.iobj2);
        }
Beispiel #35
0
 // note. this one is necessary to preserve all metadata that we might need later on
 // e.g. for the purpose of determining whether this particular argument is an "out" one
 public ParamInfo(Sig sig, int index, ParameterInfo metadata)
     : this(sig, index, metadata.AssertNotNull().Name, metadata.AssertNotNull().ParameterType)
 {
     Metadata = metadata;
 }