protected CompilerGeneratedContainer (TypeContainer parent, MemberName name, Modifiers mod, MemberKind kind) : base (parent, name, null, kind) { Debug.Assert ((mod & Modifiers.AccessibilityMask) != 0); ModFlags = mod | Modifiers.COMPILER_GENERATED | Modifiers.SEALED; spec = new TypeSpec (Kind, null, this, null, ModFlags); }
public TypeContainer (TypeContainer parent, MemberName name, Attributes attrs, MemberKind kind) : base (parent, name, attrs) { this.Kind = kind; if (name != null) this.Basename = name.Basename; defined_names = new Dictionary<string, MemberCore> (); }
public Delegate (TypeContainer parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, ParametersCompiled param_list, Attributes attrs) : base (parent, name, attrs, MemberKind.Delegate) { this.ReturnType = type; ModFlags = ModifiersExtensions.Check (AllowedModifiers, mod_flags, IsTopLevel ? Modifiers.INTERNAL : Modifiers.PRIVATE, name.Location, Report); parameters = param_list; spec = new TypeSpec (Kind, null, this, null, ModFlags | Modifiers.SEALED); }
public CSharpParser (SeekableStreamReader reader, CompilationSourceFile file, Report report, ParserSession session) { this.file = file; current_container = current_namespace = file; this.module = file.Module; this.compiler = file.Compiler; this.settings = compiler.Settings; this.report = report; lang_version = settings.Version; yacc_verbose_flag = settings.VerboseParserFlag; doc_support = settings.DocumentationFile != null; lexer = new Tokenizer (reader, file, session); oob_stack = new Stack<object> (); lbag = session.LocationsBag; use_global_stacks = session.UseJayGlobalArrays; parameters_bucket = session.ParametersStack; }
public override void AddTypeContainer (TypeContainer tc) { AddNameToContainer (tc, tc.Basename); if (containers == null) containers = new List<TypeContainer> (); members.Add (tc); base.AddTypeContainer (tc); }
public override MethodBuilder Define (TypeContainer ds) { CheckAbstractAndExtern (block != null); return base.Define (ds); }
public override void RemoveContainer (TypeContainer cont) { base.RemoveContainer (cont); NS.RemoveContainer (cont); }
public virtual MethodBuilder Define (TypeContainer parent) { // Fill in already resolved event type to speed things up and // avoid confusing duplicate errors ((Parameter) parameters.FixedParameters[0]).Type = method.member_type; parameters.Types = new TypeSpec[] { method.member_type }; method_data = new MethodData (method, method.ModFlags, method.flags | MethodAttributes.HideBySig | MethodAttributes.SpecialName, this); if (!method_data.Define (parent.PartialContainer, method.GetFullName (MemberName))) return null; if (Compiler.Settings.WriteMetadataOnly) block = null; MethodBuilder mb = method_data.MethodBuilder; Spec = new MethodSpec (MemberKind.Method, parent.PartialContainer.Definition, this, ReturnType, mb, ParameterInfo, method.ModFlags); Spec.IsAccessor = true; return mb; }
public override MethodBuilder Define (TypeContainer parent) { parameters.Resolve (this); base.Define (parent); Spec = new MethodSpec (MemberKind.Method, parent.PartialContainer.Definition, this, ReturnType, null, ParameterInfo, ModFlags); method_data = new MethodData (method, ModFlags, flags, this); if (!method_data.Define (parent.PartialContainer, method.GetFullName (MemberName))) return null; Spec.SetMetaInfo (method_data.MethodBuilder); return method_data.MethodBuilder; }
public ClassOrStruct (TypeContainer parent, MemberName name, Attributes attrs, MemberKind kind) : base (parent, name, attrs, kind) { }
public Class (TypeContainer parent, MemberName name, Modifiers mod, Attributes attrs) : base (parent, name, attrs, MemberKind.Class) { var accmods = IsTopLevel ? Modifiers.INTERNAL : Modifiers.PRIVATE; var allowedMods = AllowedModifiers; // Modify allowed modifiers for classes in PlayScript if (this.Location.SourceFile != null && this.Location.SourceFile.FileType == SourceFileType.PlayScript) { allowedMods = allowedMods | Modifiers.AS_DYNAMIC & ~Modifiers.UNSAFE; // Dynamic classes yes, but no unsafe code in AS if (!this.Location.SourceFile.PsExtended) { // Normal AS does not support STATIC or ABSTRACT classes either allowedMods &= ~(Modifiers.ABSTRACT | Modifiers.NEW); if (!name.Basename.EndsWith("_fn")) allowedMods &= ~Modifiers.STATIC; // Only function classes can be static in standard AS } } this.ModFlags = ModifiersExtensions.Check (allowedMods, mod, accmods, Location, Report); spec = new TypeSpec (Kind, null, this, null, ModFlags); }
public override void RemoveContainer (TypeContainer cont) { base.RemoveContainer (cont); Members.Remove (cont); Cache.Remove (cont.Basename); }
public virtual void AddTypeContainer (TypeContainer tc) { containers.Add (tc); var tparams = tc.MemberName.TypeParameters; if (tparams != null && tc.PartialContainer != null) { var td = (TypeDefinition) tc; for (int i = 0; i < tparams.Count; ++i) { var tp = tparams[i]; if (tp.MemberName == null) continue; td.AddNameToContainer (tp, tp.Name); } } }
void case_1002() #line 6844 "cs-parser.jay" { current_container = current_type = new Class (current_container, new MemberName ("<InteractiveExpressionClass>"), Modifiers.PUBLIC, null); /* (ref object retval)*/ Parameter [] mpar = new Parameter [1]; mpar [0] = new Parameter (new TypeExpression (compiler.BuiltinTypes.Object, Location.Null), "$retval", Parameter.Modifier.REF, null, Location.Null); ParametersCompiled pars = new ParametersCompiled (mpar); var mods = Modifiers.PUBLIC | Modifiers.STATIC; if (settings.Unsafe) mods |= Modifiers.UNSAFE; current_local_parameters = pars; Method method = new Method ( current_type, new TypeExpression (compiler.BuiltinTypes.Void, Location.Null), mods, new MemberName ("Host"), pars, null /* attributes */); current_type.AddMember (method); oob_stack.Push (method); ++lexer.parsing_block; start_block (lexer.Location); }
void case_23() #line 533 "cs-parser.jay" { if (yyVals[0+yyTop] != null) lbag.AddLocation (current_container, GetLocation (yyVals[-9+yyTop]), GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop])); else lbag.AddLocation (current_container, GetLocation (yyVals[-9+yyTop]), GetLocation (yyVals[-6+yyTop]), GetLocation (yyVals[-1+yyTop])); current_container = current_namespace = current_namespace.Parent; }
void case_21() #line 500 "cs-parser.jay" { Attributes attrs = (Attributes) yyVals[-2+yyTop]; var name = (MemberName) yyVals[0+yyTop]; if (attrs != null) { bool valid_global_attrs = true; if ((current_namespace.DeclarationFound || current_namespace != file)) { valid_global_attrs = false; } else { foreach (var a in attrs.Attrs) { if (a.ExplicitTarget == "assembly" || a.ExplicitTarget == "module") continue; valid_global_attrs = false; break; } } if (!valid_global_attrs) report.Error (1671, name.Location, "A namespace declaration cannot have modifiers or attributes"); } module.AddAttributes (attrs, current_namespace); var ns = new NamespaceContainer (name, current_namespace); current_namespace.AddTypeContainer (ns); current_container = current_namespace = ns; }
public static bool CheckImplementingMethodConstraints (TypeContainer container, MethodSpec method, MethodSpec baseMethod) { var tparams = method.Constraints; var base_tparams = baseMethod.Constraints; for (int i = 0; i < tparams.Length; ++i) { if (!tparams[i].HasSameConstraintsImplementation (base_tparams[i])) { container.Compiler.Report.SymbolRelatedToPreviousError (method); container.Compiler.Report.SymbolRelatedToPreviousError (baseMethod); // Using container location because the interface can be implemented // by base class container.Compiler.Report.Error (425, container.Location, "The constraints for type parameter `{0}' of method `{1}' must match the constraints for type parameter `{2}' of interface method `{3}'. Consider using an explicit interface implementation instead", tparams[i].GetSignatureForError (), method.GetSignatureForError (), base_tparams[i].GetSignatureForError (), baseMethod.GetSignatureForError ()); return false; } } return true; }
public Interface (TypeContainer parent, MemberName name, Modifiers mod, Attributes attrs) : base (parent, name, attrs, MemberKind.Interface) { var accmods = IsTopLevel ? Modifiers.INTERNAL : Modifiers.PRIVATE; this.ModFlags = ModifiersExtensions.Check (AllowedModifiers, mod, accmods, name.Location, Report); spec = new TypeSpec (Kind, null, this, null, ModFlags); }
public MemberCore (TypeContainer parent, MemberName name, Attributes attrs) { this.Parent = parent; member_name = name; caching_flags = Flags.Obsolete_Undetected | Flags.ClsCompliance_Undetected | Flags.HasCompliantAttribute_Undetected | Flags.Excluded_Undetected; AddAttributes (attrs, this); }
public virtual void RemoveContainer (TypeContainer cont) { if (containers != null) containers.Remove (cont); var tc = Parent == Module ? Module : this; tc.defined_names.Remove (cont.Basename); }
public override MethodBuilder Define (TypeContainer parent) { // Disable reporting, parameters are resolved twice Report.DisableReporting (); try { parameters.Resolve (this); } finally { Report.EnableReporting (); } return base.Define (parent); }
public BaseContext (TypeContainer tc) { this.tc = tc; }
public virtual MethodBuilder Define (TypeContainer parent) { var container = parent.PartialContainer; // // Check for custom access modifier // if ((ModFlags & Modifiers.AccessibilityMask) == 0) { ModFlags |= method.ModFlags; flags = method.flags; } else { if (container.Kind == MemberKind.Interface) Report.Error (275, Location, "`{0}': accessibility modifiers may not be used on accessors in an interface", GetSignatureForError ()); else if ((method.ModFlags & Modifiers.ABSTRACT) != 0 && (ModFlags & Modifiers.PRIVATE) != 0) { Report.Error (442, Location, "`{0}': abstract properties cannot have private accessors", GetSignatureForError ()); } CheckModifiers (ModFlags); ModFlags |= (method.ModFlags & (~Modifiers.AccessibilityMask)); ModFlags |= Modifiers.PROPERTY_CUSTOM; flags = ModifiersExtensions.MethodAttr (ModFlags); flags |= (method.flags & (~MethodAttributes.MemberAccessMask)); } CheckAbstractAndExtern (block != null); CheckProtectedModifier (); if (block != null) { if (block.IsIterator) Iterator.CreateIterator (this, Parent.PartialContainer, ModFlags); if (Compiler.Settings.WriteMetadataOnly) block = null; } return null; }
public override void AddTypeContainer (TypeContainer tc) { string name = tc.Basename; var mn = tc.MemberName; while (mn.Left != null) { mn = mn.Left; name = mn.Name; } var names_container = Parent == null ? Module : (TypeContainer) this; MemberCore mc; if (names_container.DefinedNames.TryGetValue (name, out mc)) { if (tc is NamespaceContainer && mc is NamespaceContainer) { containers.Add (tc); return; } Report.SymbolRelatedToPreviousError (mc); if ((mc.ModFlags & Modifiers.PARTIAL) != 0 && (tc is ClassOrStruct || tc is Interface)) { Error_MissingPartialModifier (tc); } else { Report.Error (101, tc.Location, "The namespace `{0}' already contains a definition for `{1}'", GetSignatureForError (), mn.GetSignatureForError ()); } } else { names_container.DefinedNames.Add (name, tc); var tdef = tc.PartialContainer; if (tdef != null) { // // Same name conflict in different namespace containers // var conflict = ns.GetAllTypes (name); if (conflict != null) { foreach (var e in conflict) { if (e.Arity == mn.Arity) { mc = (MemberCore) e.MemberDefinition; break; } } } if (mc != null) { Report.SymbolRelatedToPreviousError (mc); Report.Error (101, tc.Location, "The namespace `{0}' already contains a definition for `{1}'", GetSignatureForError (), mn.GetSignatureForError ()); } else { ns.AddType (Module, tdef.Definition); } } } base.AddTypeContainer (tc); }
public void AddTypeContainer (TypeContainer current_container, TypeDefinition tc) { if (current_container == tc){ Console.Error.WriteLine ("Internal error: inserting container into itself"); return; } if (undo_actions == null) undo_actions = new List<Action> (); var existing = current_container.Containers.FirstOrDefault (l => l.Basename == tc.Basename); if (existing != null) { current_container.RemoveContainer (existing); undo_actions.Add (() => current_container.AddTypeContainer (existing)); } undo_actions.Add (() => current_container.RemoveContainer (tc)); }
void push_current_container (TypeDefinition tc, object partial_token) { if (module.Evaluator != null){ tc.Definition.Modifiers = tc.ModFlags = (tc.ModFlags & ~Modifiers.AccessibilityMask) | Modifiers.PUBLIC; if (undo == null) undo = new Undo (); undo.AddTypeContainer (current_container, tc); } if (partial_token != null) current_container.AddPartial (tc); else current_container.AddTypeContainer (tc); ++lexer.parsing_declaration; current_container = tc; current_type = tc; }
public void RemoveContainer (TypeContainer tc) { types.Remove (tc.Basename); cached_types.Remove (tc.Basename); }
TypeContainer pop_current_class () { var retval = current_container; current_container = current_container.Parent; current_type = current_type.Parent as TypeDefinition; return retval; }
public ProxyMethodContext (TypeContainer container) { this.container = container; }
public TypeDefinition (TypeContainer parent, MemberName name, Attributes attrs, MemberKind kind) : base (parent, name, attrs, kind) { PartialContainer = this; members = new List<MemberCore> (); }