public void PutParseStructure(string name, StructureFrame value) { if (!current_scope.Generics.ContainsKey(name)) { current_scope.Generics.Add(name, value); } }
public static GenericFrame CopyAndPreserveHeirarchy(GenericFrame oval) { ScopeFrame SCF = new ScopeFrame(); StructureFrame SF = new StructureFrame(); ArrayFrame AF = new ArrayFrame(); GenericFrame GF = new GenericFrame(); if (GF.GetType() == oval.GetType()) { return(oval); } else if (AF.GetType() == oval.GetType()) { AF = (ArrayFrame)oval; return(AF); } else if (SF.GetType() == oval.GetType()) { SF = (StructureFrame)oval; return(SF); } else { SCF = (ScopeFrame)oval; return(SCF); } }
/*public bool TryGetStructure(string name, out StructureType structure) * { * return current_scope.Structures.TryGetValue (name, out structure); * }*/ public bool TryGetStructureChildIdentityType(StructureFrame scope, string name, ref IdentityType itype) { if (scope.Primitives.Numbers.ContainsKey(name)) { itype = IdentityType.Number; return(true); } else if (scope.Primitives.Text.ContainsKey(name)) { itype = IdentityType.Text; return(true); } else if (scope.Primitives.Booleans.ContainsKey(name)) { itype = IdentityType.Boolean; return(true); } else if (scope.Functions.ContainsKey(name)) { itype = IdentityType.Function; return(true); } else if (scope.Generics.ContainsKey(name)) { itype = IdentityType.Structure; return(true); } else { return(false); } }
public ScopeFrame CreateParseFunctionScope(FunctionFrame ftype, string FunctionName) { ScopeFrame fscope = new ScopeFrame(current_scope, FunctionName, ScopeFrame.FrameTypes.Function); fscope.Name = FunctionName; fscope.Type = ScopeFrame.FrameTypes.Function; PushScope(fscope); foreach (FunctionParameter fp in ftype.Parameters) { if (IsPrimitive(fp.Type)) { CreateParsePrimitive(fp.Name, fp.Type); } else if (fp.Type == IdentityType.Structure) { StructureFrame trash = new StructureFrame(); PutParseStructure(fp.Name, trash); } else if (fp.Type == IdentityType.Function) { FunctionFrame trash = new FunctionFrame(); PutParseFunction(fp.Name, trash); } else { Error("Unknown parameter type, cannot create function scope"); } } return(PopScopeNoSave()); }
protected StructureFrame UpdateOriginal(StructureFrame original) { List <string> keys; keys = new List <string>(original.Primitives.Numbers.Keys); foreach (string key in keys) { if (Primitives.Numbers.ContainsKey(key)) { original.Primitives.Numbers [key] = Primitives.Numbers [key]; } } keys = new List <string>(original.Primitives.Booleans.Keys); foreach (string key in keys) { /*bool val; * this.Primitives.Booleans.TryGetValue (key, out val); * original.Primitives.Booleans[key] = val;*/ if (Primitives.Booleans.ContainsKey(key)) { original.Primitives.Booleans [key] = Primitives.Booleans [key]; } } keys = new List <string>(original.Primitives.Text.Keys); foreach (string key in keys) { /*string val; * this.Primitives.Text.TryGetValue (key, out val); * original.Primitives.Text[key] = val;*/ if (Primitives.Text.ContainsKey(key)) { original.Primitives.Text [key] = Primitives.Text [key]; } } keys = new List <string>(original.Generics.Keys); foreach (string key in keys) { if (Generics.ContainsKey(key)) { original.Generics [key] = Generics [key]; } } keys = new List <string>(original.Functions.Keys); foreach (string key in keys) { if (Functions.ContainsKey(key)) { original.Functions [key] = Functions [key]; } } return(original); }
void RegisterStructure(string name, StructureFrame stype) { if (!IdentityExists(name)) { current_scope.Generics.Add(name, stype); } else { Error("Structure with name " + name + " already exists."); } }
public ScopeFrame(StructureFrame original, string Name, FrameTypes Type) : base(original) { this.Name = Name; this.Type = Type; }
void RegisterStructure(string name, StructureFrame stype) { if (!IdentityExists (name)) current_scope.Generics.Add (name, stype); else Error ("Structure with name " + name + " already exists."); }
public void MergeForScope(string StructureName, StructureFrame original) { Generics.Remove(StructureName); Merge(original); }
public StructureFrame(StructureFrame original) : base(new IdentityType[] { IdentityType.Number, IdentityType.Boolean, IdentityType.Text, IdentityType.Structure, IdentityType.Function }) { Merge(original); }
public void MergeForScope(string StructureName, StructureFrame original) { Generics.Remove (StructureName); Merge (original); }
protected StructureFrame UpdateOriginal(StructureFrame original) { List<string> keys; keys = new List<string>(original.Primitives.Numbers.Keys); foreach (string key in keys) { if(Primitives.Numbers.ContainsKey(key)) original.Primitives.Numbers [key] = Primitives.Numbers [key]; } keys = new List<string>(original.Primitives.Booleans.Keys); foreach (string key in keys) { /*bool val; this.Primitives.Booleans.TryGetValue (key, out val); original.Primitives.Booleans[key] = val;*/ if(Primitives.Booleans.ContainsKey(key)) original.Primitives.Booleans [key] = Primitives.Booleans [key]; } keys = new List<string>(original.Primitives.Text.Keys); foreach (string key in keys) { /*string val; this.Primitives.Text.TryGetValue (key, out val); original.Primitives.Text[key] = val;*/ if(Primitives.Text.ContainsKey(key)) original.Primitives.Text [key] = Primitives.Text [key]; } keys = new List<string>(original.Generics.Keys); foreach (string key in keys) { if(Generics.ContainsKey(key)) original.Generics [key] = Generics [key]; } keys = new List<string>(original.Functions.Keys); foreach (string key in keys) { if(Functions.ContainsKey(key)) original.Functions [key] = Functions [key]; } return original; }
public ScopeFrame CreateParseFunctionScope(FunctionFrame ftype, string FunctionName) { ScopeFrame fscope = new ScopeFrame (current_scope, FunctionName, ScopeFrame.FrameTypes.Function); fscope.Name = FunctionName; fscope.Type = ScopeFrame.FrameTypes.Function; PushScope (fscope); foreach (FunctionParameter fp in ftype.Parameters) { if (IsPrimitive (fp.Type)) { CreateParsePrimitive (fp.Name, fp.Type); } else if (fp.Type == IdentityType.Structure) { StructureFrame trash = new StructureFrame(); PutParseStructure (fp.Name, trash); } else if (fp.Type == IdentityType.Function) { FunctionFrame trash = new FunctionFrame(); PutParseFunction (fp.Name, trash); } else { Error ("Unknown parameter type, cannot create function scope"); } } return PopScopeNoSave (); }
/*public bool TryGetStructure(string name, out StructureType structure) { return current_scope.Structures.TryGetValue (name, out structure); }*/ public bool TryGetStructureChildIdentityType(StructureFrame scope, string name, ref IdentityType itype) { if (scope.Primitives.Numbers.ContainsKey (name)) { itype = IdentityType.Number; return true; } else if (scope.Primitives.Text.ContainsKey (name)) { itype = IdentityType.Text; return true; } else if (scope.Primitives.Booleans.ContainsKey (name)) { itype = IdentityType.Boolean; return true; } else if (scope.Functions.ContainsKey (name)) { itype = IdentityType.Function; return true; } else if (scope.Generics.ContainsKey (name)) { itype = IdentityType.Structure; return true; } else { return false; } }
public void PutParseStructure(string name, StructureFrame value) { if(!current_scope.Generics.ContainsKey(name)) current_scope.Generics.Add (name, value); }
/* Address format: * <type>:<name> * s:<name> - structure * f:<name> - function * l:<name> - loop * u - unknown * * [feature redacted] .. go back into parent scope * / global scope */ void FindNameScope(IDPacket packet, out ScopeFrame scope) { Debug("Attempting to find scope of " + packet.Address + ", name: " + packet.Name); if (packet.Address.Length == 0) { scope = TemporaryStorage; return; } string[] _path = packet.Address.Split('/'); List <string> pathList = new List <string>(); foreach (string tok in _path) { if (tok.Length > 0) { pathList.Add(tok); } } string[] path = pathList.ToArray(); scope = Global_Scope; int PARENT_COUNTER = 0; ScopeFrame[] _SS = Scope_Stack.ToArray(); for (int i = 0; i < path.Length; i++) { string str = path [i]; /* -- parent keyword feature has been removed * * if (str.Equals (IDPacket.PARENT_TYPE)) { * scope = _SS [_SS.Length - 1 - ++PARENT_COUNTER]; * continue; * } */ string[] addr_parts = str.Split(':'); string addr_type = addr_parts [0], addr_name = addr_parts [1]; if (!addr_type.Equals("s")) { Debug("Searching scope stack..."); if (_SS [i].Name.Equals(addr_name)) { Debug(String.Format("Found {0} on top of {1}", addr_name, scope.Name)); scope = _SS [i]; } else { Debug(String.Format("Didn't find {0} on top of {1}", addr_name, scope.Name)); } } else { Debug("Searching Generics..."); GenericFrame schild; if (scope.Generics.TryGetValue(addr_name, out schild)) { Debug("[Generic] Child " + addr_name + " found"); scope = StructureFrame.Appropriate(addr_name, schild); } else { Error(String.Format("There is no structure named {0} in the scope", addr_name)); } } } Debug("Exiting Finder"); }
public static GenericFrame CopyAndPreserveHeirarchy(GenericFrame oval) { ScopeFrame SCF = new ScopeFrame (); StructureFrame SF = new StructureFrame (); ArrayFrame AF = new ArrayFrame (); GenericFrame GF = new GenericFrame (); if (GF.GetType () == oval.GetType ()) { return oval; } else if (AF.GetType () == oval.GetType ()) { AF = (ArrayFrame)oval; return AF; } else if (SF.GetType () == oval.GetType ()) { SF = (StructureFrame)oval; return SF; } else { SCF = (ScopeFrame)oval; return SCF; } }