Ejemplo n.º 1
0
            public override Node getNode(string[] args, Node parent)
            {
                FunctionRef func = new FunctionRef();

                func.Name   = args[0];
                func.parent = parent;
                return(func);
            }
Ejemplo n.º 2
0
        public LOLMethod(FunctionRef info, LOLProgram prog)
        {
            this.info = info;
            this.args = new ArgumentRef[info.Arity + (info.IsVariadic ? 1 : 0)];
            this.program = prog;
            this.locals = new Scope(prog.globals);

            LocalRef it = new LocalRef("IT");
            locals.AddSymbol(it);
        }
Ejemplo n.º 3
0
    public static void Define( string name, string[] paramTypes, ProtocolCallback callback )
    {
        FunctionRef fr = new FunctionRef();
        fr.id = _this._id++;
        fr.name = name;
        fr.paramTypes = paramTypes;
        fr.callback = callback;

        _this.functions.Add(fr);
    }
Ejemplo n.º 4
0
        public void FunctionRef_when_not_registered_must_not_be_found()
        {
            var provider = ((ExtendedActorSystem)Sys).Provider;
            var fref     = new FunctionRef(TestActor.Path / "blabla", provider, Sys.EventStream, (x, y) => { });

            EventFilter.Exception <InvalidOperationException>().ExpectOne(() =>
            {
                // needs to be something that fails when the deserialized form is not a FunctionRef
                // this relies upon serialize-messages during tests
                TestActor.Tell(new DropForwarder(fref));
                ExpectNoMsg(TimeSpan.FromSeconds(1));
            });
        }
Ejemplo n.º 5
0
            public override Node getNode(string[] args, Node parent)
            {
                Assign assign = null;

                if (name == "funcAssignment")
                {
                    assign          = new Assign();
                    assign.Variable = args[0];
                    FunctionRef function = new FunctionRef();
                    function.Name     = args[1];
                    assign.expression = function;
                    assign.parent     = parent;
                }
                else if (name == "assignmentExp")
                {
                    assign          = new Assign();
                    assign.Variable = args[0];
                    assign.parent   = parent;
                }
                else
                {
                    if (Utils.IsDigitsOnly(args[1]))
                    {
                        assign            = new Assign();
                        assign.Variable   = args[0];
                        assign.expression = new IntConstant(int.Parse(args[1]));
                        assign.parent     = parent;
                    }
                    else
                    {
                        assign                   = new Assign();
                        assign.Variable          = args[0];
                        assign.expression        = new IntRef(args[0]);
                        assign.expression.parent = assign;
                        assign.parent            = parent;
                    }
                }

                return(assign);
            }
Ejemplo n.º 6
0
 public DropForwarder(FunctionRef @ref)
 {
     Ref = @ref;
 }
Ejemplo n.º 7
0
 public LoadFunctionOpCode(int line, int linePosition, FunctionRef parameter) : base(line, linePosition, parameter)
 {
     opCodeID = OpCodeID.O_LOADF;
 }
Ejemplo n.º 8
0
 public FunctionRefValue(FunctionRef functionRef)
 {
     valueType = ValueTypeID.TYPE_FUNCTIONREF;
     val       = functionRef;
 }
Ejemplo n.º 9
0
        public override void Eval(EvaluatorState ev)
        {
            //Console.WriteLine(this.ToString());

            // pointer to _argc
            IValue argcValue = ev.Stack.ReadTop();

            if (argcValue.TypeOf() != ValueTypeID.TYPE_NUMBER)
            {
                Console.WriteLine(">> exp. argc");
                // TODO: add more specific error code here
                throw new SharpNektonException(new SharpNektonError(SharpNektonErrorID.E_BADTYPE));
            }

            // get number of passed params
            int numberOfPassedParams = (int)argcValue.GetNumericValue();

            // functionref is stored on the stack[numparams] by pushp instuction,
            // so GetVal() is not neccessary
            IValue functionRefValue = ev.Stack.ReadN(ev.Stack.StackTop - (numberOfPassedParams + 1)); // n + 1 = count with _argc

            switch (functionRefValue.TypeOf())
            {
            case ValueTypeID.TYPE_FUNCTIONREF:
                // store the return address on the stack
                ev.Stack.Push(new RTSAValue(ev.RegPC));

                // check parameter counts
                FunctionRef functionRef = (FunctionRef)functionRefValue.GetObjectValue();
                if (CheckParams(functionRef.NumberOfDefinedParameters, numberOfPassedParams) == false)
                {
                    throw new SharpNektonException(new SharpNektonError(SharpNektonErrorID.E_BADPARAMCOUNT));
                }

                // set PC to new address and test it
                OpCodeListItem functionStartAddress = functionRef.CodePart.First();
                if (functionStartAddress != null)
                {
                    ev.RegPC = functionStartAddress;
                }
                else
                {
                    // TODO: add more specific error code here
                    throw new SharpNektonException(new SharpNektonError(SharpNektonErrorID.E_BADJMPTARGET));
                }
                break;

            case ValueTypeID.TYPE_CFUNCTIONREF:
                // check parameter counts
                ExternalFunctionRef extFunctionRef = (ExternalFunctionRef)functionRefValue.GetObjectValue();
                if (CheckParams(extFunctionRef.NumberOfDefinedParameters, numberOfPassedParams) == false)
                {
                    throw new SharpNektonException(new SharpNektonError(SharpNektonErrorID.E_BADPARAMCOUNT));
                }

                // call the function
                extFunctionRef.FunctionRef(numberOfPassedParams);
                break;

            default:
                //Console.WriteLine(">> type is {0}", functionRefValue.TypeOf().ToString());
                throw new SharpNektonException(new SharpNektonError(SharpNektonErrorID.E_EXPTYPEFUNCREF));
            }
        }
Ejemplo n.º 10
0
 public AFunctionRefOpCode(int line, int linePosition, FunctionRef parameter) : base(line, linePosition)
 {
     this.parameter = parameter;
 }