public FieldInfo SetVariable(DataPortor scop, Tree tree, bool asParameter = false) { if (tree.Membre != null && scop.GetField(tree.Membre.Name, SearcheMode.Flaten) == tree.Membre) { return(tree.Membre); } string type = tree.Children[0].Content; string varName = tree.Children[1].Content; Class @class = GetClass(scop, type); var fieldInfo = new FieldInfo(varName, @class, scop is MethodInfo); if (scop is MethodInfo && asParameter) { fieldInfo = ((MethodInfo)scop).AddParam(fieldInfo); } else if (scop is MethodInfo || scop is Class) { fieldInfo = scop.Add(fieldInfo); } else { throw new BadImageFormatException(); } return(fieldInfo); }
private Class GetClass(DataPortor scop, string type) { Class @class = _byteCodeMapper.Finder.GetClass(_byteCodeMapper.CurrentScop.Root, type); if (@class == null) { LogIn(scop, null, this, "Class Name :" + type + " doesn't declared"); return(null); } if ([email protected] && [email protected] && @class.IsFromAssembly(_byteCodeMapper.CurrentScop)) { if (Prevent.Contains(@class)) { throw new StrongTypingException(); } Prevent.Add((Class)scop); DownloadClass(@class, _summary[@class]); Prevent.RemoveAt(Prevent.Count - 1); } return(@class); }
/* * public FieldInfo Get(Tree t) { * switch (t.Kind) { * case Kind.Unair: * break; * case Kind.Numbre: * //typeCalc.CalcTypes() * //return ConstInfo.Immediate(t.) * break; * case Kind.Variable: * break; * case Kind.String: * break; * case Kind.Expression: * break; * case Kind.Return: * break; * case Kind.Caller: * break; * case Kind.Assigne: * break; * case Kind.Hyratachy: * break; * case Kind.For: * break; * case Kind.If: * break; * case Kind.ElseIf: * break; * case Kind.While: * break; * case Kind.Do: * break; * case Kind.Bloc: * break; * case Kind.Instruction: * break; * case Kind.Parent: * break; * case Kind.Ifs: * break; * case Kind.Param: * break; * case Kind.TypeAssigne: * break; * case Kind.EqAssign: * break; * case Kind.Space: * break; * case Kind.Class: * break; * case Kind.Const: * break; * case Kind.DeclareParams: * break; * case Kind.Function: * break; * case Kind.DeclareParam: * break; * case Kind.KeyWord: * break; * case Kind.Operator: * break; * case Kind.Program: * break; * case Kind.Term: * break; * case Kind.Facteur: * break; * case Kind.Power: * break; * case Kind.Logic: * break; * case Kind.Word: * break; * case Kind.Array: * break; * case Kind.Goto: * break; * case Kind.Label: * break; * case Kind.Register: * break; * case Kind.Constructor: * break; * case Kind.New: * break; * case Kind.Struct: * break; * case Kind.When: * break; * default: * throw new ArgumentOutOfRangeException (); * } * return null; * } */ public FieldInfo IsVar(Scop scop, string name) { DataPortor first = (DataPortor)Finder.GetBackFirst <MethodInfo>(scop) ?? Finder.GetBackFirst <Class>(scop); return(first != null?first.GetField(name, SearcheMode.Deep) : null); }