Ejemplo n.º 1
0
 public override void CodeGen(ScriptCodeGen scg, Token errorAt, CompValuTemp result, CompValu[] args)
 {
     args[0].PushVal(scg, errorAt, new TokenTypeFloat(null));
     scg.ilGen.Emit(errorAt, OpCodes.Ldc_I4, (int)System.MidpointRounding.AwayFromZero);
     scg.ilGen.Emit(errorAt, OpCodes.Call, roundMethInfo);
     result.Pop(scg, errorAt, new TokenTypeFloat(null));
 }
Ejemplo n.º 2
0
 public override void CodeGen(ScriptCodeGen scg, Token errorAt, CompValuTemp result, CompValu[] args)
 {
     for (int i = 0; i < args.Length; i++)
     {
         args[i].PushVal(scg, errorAt, argDecl.types[i]);
     }
     scg.ilGen.Emit(errorAt, OpCodes.Call, methInfo);
     result.Pop(scg, errorAt, retType);
 }
Ejemplo n.º 3
0
        public override void CodeGen(ScriptCodeGen scg, Token errorAt, CompValuTemp result, CompValu[] args)
        {
            ScriptMyLabel itsPosLabel = scg.ilGen.DefineLabel("llAbstemp");

            args[0].PushVal(scg, errorAt);
            scg.ilGen.Emit(errorAt, OpCodes.Dup);
            scg.ilGen.Emit(errorAt, OpCodes.Ldc_I4_0);
            scg.ilGen.Emit(errorAt, OpCodes.Bge_S, itsPosLabel);
            scg.ilGen.Emit(errorAt, OpCodes.Neg);
            scg.ilGen.MarkLabel(itsPosLabel);
            result.Pop(scg, errorAt, retType);
        }
Ejemplo n.º 4
0
        /**
         * @brief Generate call to backend API function (eg llSay()) maybe followed by a call to CheckRun().
         * @param scg    = script being compiled
         * @param result = where to place result (might be void)
         * @param args   = script-visible arguments to pass to API function
         */
        public override void CodeGen(ScriptCodeGen scg, Token errorAt, CompValuTemp result, CompValu[] args)
        {
            if (isTaggedCallsCheckRun)
            {                                                  // see if 'xmr' method that calls CheckRun() internally
                new ScriptCodeGen.CallLabel(scg, errorAt);     // if so, put a call label immediately before it
                                                               // .. so restoring the frame will jump immediately to the
                                                               // .. call without re-executing any code before this
            }
            if (!methInfo.IsStatic)
            {
                scg.PushXMRInst();                          // XMRInstanceSuperType pointer
                if (apiContextField != null)                // 'this' pointer for API function
                {
                    scg.ilGen.Emit(errorAt, OpCodes.Ldfld, apiContextField);
                }
            }
            for (int i = 0; i < args.Length; i++)             // push arguments, boxing/unboxing as needed
            {
                args[i].PushVal(scg, errorAt, argDecl.types[i]);
            }

            // this should not be needed
            //            if (methInfo.Name == "llParcelMediaQuery") {
            //                scg.ilGen.Emit (errorAt, OpCodes.Call, fixLLParcelMediaQuery);
            //            }
            // this should not be needed
            //            if (methInfo.Name == "llParcelMediaCommandList") {
            //                scg.ilGen.Emit (errorAt, OpCodes.Call, fixLLParcelMediaCommandList);
            //            }
            if (methInfo.IsVirtual)                            // call API function
            {
                scg.ilGen.Emit(errorAt, OpCodes.Callvirt, methInfo);
            }
            else
            {
                scg.ilGen.Emit(errorAt, OpCodes.Call, methInfo);
            }

            result.Pop(scg, errorAt, retType);                  // pop result, boxing/unboxing as needed
            if (isTaggedCallsCheckRun)
            {
                scg.openCallLabel = null;
            }

            if (doCheckRun)
            {
                scg.EmitCallCheckRun(errorAt, false);       // maybe call CheckRun()
            }
        }
Ejemplo n.º 5
0
 // appears as llGetUsedMemory() in script source code
 // but actually calls xmrHeapUsed()
 public override void CodeGen(ScriptCodeGen scg, Token errorAt, CompValuTemp result, CompValu[] args)
 {
     scg.PushXMRInst();
     scg.ilGen.Emit(errorAt, OpCodes.Call, getUsedMemMethInfo);
     result.Pop(scg, errorAt, new TokenTypeInt(null));
 }
Ejemplo n.º 6
0
 public abstract void CodeGen(ScriptCodeGen scg, Token errorAt, CompValuTemp result, CompValu[] args);