コード例 #1
0
ファイル: ESOSimple.cs プロジェクト: rubikscraft/E-Lang
        private EVariable Calc(EVariable a, EVariable b)
        {
            EVariable convA = a;
            EVariable convB = b;

            if (input.HasValue)
            {
                EType inputType = input.Value;
                convA = a.Convert(inputType);
                convB = b.Convert(inputType);
            }

            dynamic convC = calc(convA.Get(), convB.Get());

            return(EVariable.New(output).Set(convC));
        }
コード例 #2
0
        public override EVariable Exec(EScope scope)
        {
            EVariable newVar = new EVVoid();

            foreach (EWord variable in variables)
            {
                newVar = EVariable.New(type);
                scope.Set(variable.ToString(), newVar);
            }

            if (assignOperations != null)
            {
                foreach (EAssignOperation assignOp in assignOperations)
                {
                    assignOp.Exec(scope);
                }
            }

            return(newVar);
        }
コード例 #3
0
        public override EVariable Exec(EScope scope, ESolvable[] args)
        {
            // TODO: output type casting
            if (args.Length != arguments.Length)
            {
                throw new ELangException("Wrong amount of args for function " + name);
            }

            EScope lowerScope = scope.GetChild();

            for (int i = 0; i < arguments.Length; i++)
            {
                string    argname = arguments[i].GetVariable().ToString();
                ETypeWord argtype = arguments[i].GetEType();

                EVariable solved = EVariable.New(argtype).Assign(args[i].Solve(lowerScope));
                lowerScope.Set(argname, solved);
            }

            return(Interpreter.Run(program, lowerScope));
        }
コード例 #4
0
 public override EVariable Solve(EScope scope)
 {
     return(EVariable.New(type));
 }