public Merker GetProperty(string name, EP_Type type = EP_Type.NONE) { Merker m; string fName = fm.fName + "." + name; m = memory.FirstOrDefault(z => z.pName == name); if (m == null && _parent != null) { m = _parent.memory.FirstOrDefault(z => z.pName == name); } if (type != EP_Type.NONE && m == null && !string.IsNullOrEmpty(name)) { m = new Merker() { fName = fName, pName = name, type = type }; memory.Add(m); } return(m); }
internal Merker DefineMerker(VariableDescriptor v, EP_Type type = EP_Type.NONE) { Merker m = null; uint addr; m = cur.memory.FirstOrDefault(z => z.vd == v); if (m == null) { m = global.memory.FirstOrDefault(z => z.vd == v); } if (m == null) { addr = uint.MaxValue; var nt = Periphery.MsDevice.NTTable.FirstOrDefault(z => v.Name.StartsWith(z.Item1)); if (nt != null && v.Name.Length > 2 && UInt32.TryParse(v.Name.Substring(2), out addr)) { addr = (uint)((uint)(((byte)v.Name[0]) << 24) | (uint)(((byte)v.Name[1]) << 16) | addr & 0xFFFF); type = (nt.Item2 & Periphery.MsDevice.DType.Output) != 0?EP_Type.OUTPUT:EP_Type.INPUT; } else if (type == EP_Type.NONE) { if (v.Initializer != null && v.Initializer is FunctionDefinition) { type = EP_Type.FUNCTION; } else if (v.LexicalScope) { type = EP_Type.LOCAL; addr = (uint)cur.memory.Where(z => z.type == EP_Type.LOCAL).Count(); if (addr > 15) { throw new ArgumentOutOfRangeException("Too many local variables: " + v.Name + cur.fm == null ? string.Empty : ("in " + cur.fm.ToString())); } } else { type = EP_Type.SINT32; addr = uint.MaxValue; } } m = new Merker() { type = type, vd = v, pName = v.Name, Addr = addr, init = v.Initializer }; if (type == EP_Type.API || type == EP_Type.INPUT || type == EP_Type.OUTPUT) { global.memory.Add(m); m.fName = v.Name; } else { cur.memory.Add(m); m.fName = (cur == global ? v.Name : cur.fm.fName + (cur.fm.type == EP_Type.FUNCTION ? "+" : ".") + v.Name); } } else if (m.type != type && m.type == EP_Type.NONE) { m.type = type; } return(m); }
private static bool IsProperty(EP_Type type) { return(type == EP_Type.PropB1 || type == EP_Type.PropS1 || type == EP_Type.PropS2 || type == EP_Type.PropS4 || type == EP_Type.PropU1 || type == EP_Type.PropU2); }