Exemplo n.º 1
0
    public ScopeFrame CreateFunctionScope(FunctionFrame ftype, string FunctionName, List <IDPacket> Bindings)
    {
        ScopeFrame fscope = CreateParseFunctionScope(ftype, FunctionName);

        //delete function frame inside scope
        fscope.Functions.Remove(FunctionName);

        PushScope(fscope);
        int BINDCNT = 0;

        foreach (FunctionParameter fp in ftype.Parameters)
        {
            IDPacket Binding = Bindings [BINDCNT];
            IDPacket Address = IDPacket.CreateIDPacket(this, fp.Name, Binding.Type);
            if (Binding.Type != fp.Type)
            {
                Error("Binding Error: Parameter type mismatch, expected: " + fp.Type + " got " + Binding.Type);
            }
            if (Binding.ArrayType != IdentityType.Unknown)
            {
                if (fp.TypeDimensions != null)
                {
                    if (Binding.ArrayType != fp.Type)
                    {
                        Error("Binding Error: Parameter type mismatch, expected: Array of " + fp.Type + " got Array of " + Binding.ArrayType);
                    }
                    int dcnt = 0;
                    foreach (int dim in fp.TypeDimensions)
                    {
                        if (dim == -1)
                        {
                            continue;
                        }
                        if (dim != Binding.TypeDimensions [dcnt++])
                        {
                            Error(String.Format("Binding Error: Dimension Mismatch, expecting {0} got {1}", fp.TypeDimensions,
                                                Binding.TypeDimensions));
                        }
                    }
                }
                else
                {
                    Error(String.Format("Binding Error: Expecting a Primitive {0} got Array of {1}", fp.Type, Binding.ArrayType));
                }
            }
            else if (fp.TypeDimensions != null)
            {
                Error(String.Format("Binding Error: Expecting an Array of {0} got Primitive {1}", fp.Type, Binding.ArrayType));
            }

            COPY(Address, Binding);
            Debug("After copy");
        }
        return(PopScopeNoSave());
    }
Exemplo n.º 2
0
 public IDPacket GET(string name)
 {
     if (current_scope.Primitives.Numbers.ContainsKey(name))
     {
         return(IDPacket.CreateIDPacket(this, name, IdentityType.Number));
     }
     else if (current_scope.Primitives.Booleans.ContainsKey(name))
     {
         return(IDPacket.CreateIDPacket(this, name, IdentityType.Boolean));
     }
     else if (current_scope.Primitives.Text.ContainsKey(name))
     {
         return(IDPacket.CreateIDPacket(this, name, IdentityType.Text));
     }
     else if (current_scope.Generics.ContainsKey(name))
     {
         IDPacket     StructPacket = IDPacket.CreateIDPacket(this, name, IdentityType.Structure);
         GenericFrame GF;
         ArrayFrame   AF = new ArrayFrame();
         TryGetGeneric(StructPacket, out GF);
         if (GF.GetType() == AF.GetType())
         {
             AF = (ArrayFrame)GF;
             StructPacket.ArrayType = AF.ResolvedType;
         }
         return(StructPacket);
     }
     else if (current_scope.Functions.ContainsKey(name))
     {
         return(IDPacket.CreateIDPacket(this, name, IdentityType.Function));
     }
     else
     {
         return(null);
     }
 }