Exemple #1
0
 public void AddClassInfo(Program prog, ClassDecl c)
 {
     if (!c.IsDefaultClass)
     {
         AH.PrintError(prog, "Internal error:  ArmadaGlobalVariableSymbolTable.AddClassInfo called on non-default class");
         return;
     }
     foreach (MemberDecl member in c.Members)
     {
         if (member is Field)
         {
             var f = (Field)member;
             variableNames.Add(f.Name);
             ArmadaVariable av = null;
             if (f.IsGhost)
             {
                 av = new GlobalGhostArmadaVariable(f.Name, f.Type, f.InitialValue);
             }
             else if (f.IsNoAddr)
             {
                 av = new GlobalUnaddressableArmadaVariable(f.Name, f.Type, f.InitialValue);
             }
             else
             {
                 av = new GlobalAddressableArmadaVariable(f.Name, f.Type, f.InitialValue);
             }
             table.Add(f.Name, av);
         }
     }
 }
Exemple #2
0
 public void AddClassInfo(Program prog, ClassDecl c, ArmadaStructs structs)
 {
     if (!c.IsDefaultClass)
     {
         AH.PrintError(prog, "Internal error:  ArmadaGlobalVariableSymbolTable.AddClassInfo called on non-default class");
         return;
     }
     foreach (MemberDecl member in c.Members)
     {
         if (member is Field)
         {
             var f = (Field)member;
             variableNames.Add(f.Name);
             ArmadaVariable av = null;
             if (!AH.IsValidType(f.Type, structs))
             {
                 AH.PrintError(prog, $"Global variable {f.Name} has invalid type {f.Type}");
                 av = null;
             }
             else if (f.IsGhost)
             {
                 av = new GlobalGhostArmadaVariable(f.Name, f.Type, f.InitialValue);
             }
             else if (f.IsNoAddr)
             {
                 av = new GlobalUnaddressableArmadaVariable(f.Name, f.Type, f.InitialValue);
             }
             else
             {
                 if (AH.IsValidHeapType(f.Type, structs))
                 {
                     av = new GlobalAddressableArmadaVariable(f.Name, f.Type, f.InitialValue);
                 }
                 else
                 {
                     AH.PrintError(prog, $"Global variable {f.Name} has type {f.Type} that can't be used on the heap. Consider making it noaddr or ghost.");
                     av = null;
                 }
             }
             table.Add(f.Name, av);
         }
     }
 }
Exemple #3
0
        public void AddVariable(Program prog, ArmadaVariable v)
        {
            if (variablesByName.ContainsKey(v.name))
            {
                AH.PrintError(prog, $"Variable {v.name} defined twice in method {methodName}");
                return;
            }

            variablesByName[v.name] = v;
            variableNamesInOrder.Add(v.name);

            if (v.varType == ArmadaVarType.Input)
            {
                inputVariableNames.Add(v.name);
            }
            else if (v.varType == ArmadaVarType.Output)
            {
                outputVariableNames.Add(v.name);
            }
        }