Ejemplo n.º 1
0
 public void DefineType(string name, TigerType tigerType)
 {
     if (!TypeNameAvailable(name))
     {
         throw new Exception("Type name not available");
     }
     TypeDictionary.Add(name, tigerType);
 }
Ejemplo n.º 2
0
 public void DefineIncompleteType(string name, TigerType tigerType = null)
 {
     if (!TypeNameAvailable(name))
     {
         throw new Exception("Type name not available");
     }
     TypeDictionary.Add(name, tigerType ?? TigerType.Nil);
 }
Ejemplo n.º 3
0
 public VariableInfo(string name, string staticName, TigerType tigerType, TigerScope containingScope, bool assignable)
 {
     Name            = name;
     StaticName      = staticName;
     TigerType       = tigerType;
     Assignable      = assignable;
     ContainingScope = containingScope;
 }
Ejemplo n.º 4
0
 public FunctionInfo(string name, string staticName, TigerType returnType, TigerType[] tigerTypes, TigerScope containingScope, MethodBuilder methodBuilder)
 {
     Name            = name;
     StaticName      = staticName;
     ReturnType      = returnType;
     Parameters      = tigerTypes;
     ContainingScope = containingScope;
     MethodBuilder   = methodBuilder;
 }
Ejemplo n.º 5
0
        public virtual bool Assignable(TigerType tigerType)
        {
            if (tigerType is SimpleType)
            {
                tigerType = ((SimpleType)tigerType).ActualType;
            }

            return(tigerType == this || IsNullable && tigerType is NilType);
        }
Ejemplo n.º 6
0
 public bool ValidReturnType(TigerType tigerType)
 {
     if (IsRoot)
     {
         return(false);
     }
     return(TigerType.AreOfSameType(tigerType, TigerType.Void) ||
            TigerType.AreOfSameType(tigerType, TigerType.Nil) ||
            (Parent.ExistsType(tigerType.Name) && !DefinesType(tigerType.Name)));
 }
Ejemplo n.º 7
0
        public VariableInfo DefineVariable(string name, TigerType tigerType, TigerScope containingScope, bool assignable = true)
        {
            if (FunctionVariableDictionary.ContainsKey(name))
            {
                throw new Exception("A variable or function with this name already exists");
            }
            VariableInfo variableInfo = new VariableInfo(name, Name + "_" + name, tigerType, containingScope, assignable);

            FunctionVariableDictionary.Add(name, variableInfo);
            return(variableInfo);
        }
Ejemplo n.º 8
0
        public FunctionInfo DefineFunction(string name, TigerType returnType, TigerType[] parameters, TigerScope containingScope, MethodBuilder methodBuilder = null)
        {
            if (!FunctionNameAvailable(name))
            {
                throw new Exception("A variable or function with this name already exists");
            }
            FunctionInfo functionInfo = new FunctionInfo(name, Name + "_" + name, returnType, parameters, containingScope, methodBuilder);

            FunctionVariableDictionary.Add(name, functionInfo);
            return(functionInfo);
        }
Ejemplo n.º 9
0
 public void CompleteType(string name, TigerType tigerType)
 {
     TypeDictionary[name] = tigerType;
 }
Ejemplo n.º 10
0
 public static bool AreOfSameType(TigerType t1, TigerType t2)
 {
     return(t1 != null && t2 != null && t1 == t2);
 }
Ejemplo n.º 11
0
 public static bool AreCompatible(TigerType t1, TigerType t2)
 {
     return(t1 != null && t2 != null && (t1.Assignable(t2) || t2.Assignable(t1)));
 }
Ejemplo n.º 12
0
 public RecordField(string name, TigerType tigerType)
 {
     Name      = name;
     TigerType = tigerType;
 }
Ejemplo n.º 13
0
 public override bool Assignable(TigerType tigerType)
 {
     return(ActualType.Assignable(tigerType));
 }
Ejemplo n.º 14
0
 public SimpleType(string name, TigerType actualType) : base(name)
 {
     ActualType = actualType;
 }
Ejemplo n.º 15
0
 public override bool Assignable(TigerType tigerType)
 {
     return(Name == tigerType.Name || tigerType is NilType);
 }
Ejemplo n.º 16
0
 public ArrayType(string name, TigerType contentType) : base(name)
 {
     ContentType = contentType;
 }