public GamaCompiledFunctionRef FindFunction(GamaTypeRef ret, GamaTypeRef[] paramtypes)
        {
            foreach (var cb in Callbacks)
            {
                if (cb.ParameterTypes.Length != paramtypes.Length)
                {
                    continue;
                }
                if (cb.ReturnType != ret)
                {
                    continue;
                }

                bool found = true;
                for (int i = 0; i < paramtypes.Length; i++)
                {
                    if (cb.ParameterTypes[i] != paramtypes[i])
                    {
                        found = false;
                        break;
                    }
                }

                if (found)
                {
                    return(cb);
                }
            }

            return(null);
        }
Beispiel #2
0
 public GamaTypeRef(string name, LLVMTypeRef type, GamaTypeRef parent)
 {
     ID             = id++;
     Name           = name;
     Parent         = parent;
     UnderlyingType = type;
     Meta           = new GamaMetaRef(this);
 }
Beispiel #3
0
 public GamaFunctionRef(GamaTypeRef ret, GamaParamList parms, GamaTypeRef ty, LLVMValueRef val, bool ismethod) : base(ty, val, true)
 {
     Blocks     = new List <ObjectGroup <GamaBlockRef> >();
     ReturnType = ret;
     Parameters = parms;
     Attributes = new GamaAttributeSet();
     IsMethod   = ismethod;
 }
Beispiel #4
0
 public bool Add(string name, GamaTypeRef type)
 {
     if (Parameters.Find(p => p.Name == name) != null)
     {
         return(false);
     }
     Parameters.Add(new GamaParamRef((uint)Parameters.Count, name, type));
     return(true);
 }
Beispiel #5
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");
        }
Beispiel #6
0
        public bool IsSubtypeOf(GamaTypeRef r)
        {
            var p = this;

            while (p != null)
            {
                if (p == r)
                {
                    return(true);
                }
                p = p.Parent;
            }
            return(false);
        }
Beispiel #7
0
        public GamaFunctionRef FindFunction(GamaTypeRef ret, GamaTypeRef[] parms, bool skipHidden = false)
        {
            foreach (var cb in Callbacks)
            {
                if (cb.Parameters.Count != parms.Length)
                {
                    continue;
                }
                if (cb.ReturnType != ret)
                {
                    continue;
                }

                bool found = true;
                for (int i = 0; i < parms.Length; i++)
                {
                    if (cb.Parameters[i].Type != parms[i])
                    {
                        found = false;
                        break;
                    }
                }

                if (found)
                {
                    // Skipping hidden types are useful for hiding some functions from other namespaces
                    // This won't stop this type from apparing in same namespace tho
                    if (skipHidden && cb.HasAttribute("hide"))
                    {
                        continue;
                    }
                    else
                    {
                        return(cb);
                    }
                }
            }
            return(null);
        }
Beispiel #8
0
 public GamaValueRef(GamaTypeRef type, LLVMValueRef value, bool ismodlval)
 {
     Type  = type;
     Value = value;
     IsModifiableLValue = ismodlval;
 }
Beispiel #9
0
 public GamaFieldRef(string name, int idx, GamaTypeRef type)
 {
     Name  = name;
     Index = idx;
     Type  = type;
 }
 public GamaCompiledFunctionRef(GamaTypeRef ret, GamaTypeRef[] paramtypes, GamaCompiledFunctionDelegate cb)
 {
     ReturnType     = ret;
     ParameterTypes = paramtypes;
     Callback       = cb;
 }
Beispiel #11
0
 // Overridable compatible definitions
 // Useful for libraries that don't know each other
 // And custom compatible implementations
 public virtual bool Compatible(GamaTypeRef other)
 {
     return(this == other);
 }
Beispiel #12
0
 public GamaParamRef(string name, GamaTypeRef type)
 {
     Name = name;
     Type = type;
 }
Beispiel #13
0
 public GamaParamRef(uint index, string name, GamaTypeRef type)
 {
     Index = index;
     Name  = name;
     Type  = type;
 }