Esempio n. 1
0
        public GamaFunctionResolver(GamaFunctionList list)
        {
            Name = list.Name;

            FixedArgs     = new Dictionary <int, GamaValueRef>();
            AmbiguousArgs = new Dictionary <int, GamaFunctionList>();

            // Create copy of original callbacks
            Remaining = new List <GamaFunctionRef>(list.Callbacks);
        }
Esempio n. 2
0
        public GamaMetaRef(GamaTypeRef parent)
        {
            Parent = parent;

            Operators         = new GamaOperatorList();
            CompiledOperators = new GamaOperatorListCompiled();

            Methods      = new List <GamaFunctionList>();
            Fields       = new List <GamaFieldRef>();
            Constructors = new GamaFunctionList(".new");
        }
Esempio n. 3
0
        /* This is the main reason why function resolver is created and used            */
        /* Resolving function that take functions as parameters create quite a ruckus   */
        /* Thats why they need special care and algorithm                               */
        public void Resolve(int index, GamaFunctionList fnlist)
        {
            if (index < 0)
            {
                return;
            }

            AmbiguousArgs[index] = fnlist;

            Remaining.RemoveAll((fnref) =>
            {
                if (fnref.IsMethod)
                {
                    index++;                 // skip first for object reference
                }
                var ty = fnref.Type as GamaFunction;
                if (fnref.Parameters.Count == 0)
                {
                    return(true);
                }
                if (index >= fnref.Parameters.Count)
                {
                    if (ty.IsVarArg)
                    {
                        return(false);
                    }
                    return(true);
                }
                // Check this later: TODO
                foreach (var cb in fnlist.Callbacks)
                {
                    var paramty = fnref.Parameters[index].Type;
                    if (paramty is GamaPointer ptr)
                    {
                        paramty = ptr.BaseType;
                    }
                    if (cb.Type.Compatible(paramty))
                    {
                        return(false);
                    }
                }
                return(true);
            });
        }
Esempio n. 4
0
        // TODO: add casting operators

        public GamaOperatorList()
        {
            Add = new GamaFunctionList("+");
            Sub = new GamaFunctionList("-");
            Mul = new GamaFunctionList("*");
            Div = new GamaFunctionList("/");
            Mod = new GamaFunctionList("%");

            And = new GamaFunctionList("&");
            Or  = new GamaFunctionList("|");
            Xor = new GamaFunctionList("^");

            Eq  = new GamaFunctionList("==");
            Neq = new GamaFunctionList("!=");

            Gt = new GamaFunctionList(">");
            Ge = new GamaFunctionList(">=");
            Lt = new GamaFunctionList("<");
            Le = new GamaFunctionList("<=");

            Index = new GamaFunctionList("[...]");
        }