Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

42
mcs/mcs/AssemblyInfo.cs Normal file
View File

@@ -0,0 +1,42 @@
//
// AssemblyInfo.cs
//
// Author:
// Marek Safar (marek.safar@gmail.com)
//
// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Reflection;
[assembly: AssemblyTitle ("Mono C# Compiler")]
[assembly: AssemblyProduct ("Mono C# Compiler")]
[assembly: AssemblyCopyright ("2001 - 2009 Novell, Inc.")]
[assembly: AssemblyCompany ("Novell, Inc.")]
[assembly: AssemblyCulture ("")]
[assembly: AssemblyConfiguration ("")]
[assembly: AssemblyVersion (Consts.MonoVersion)]
[assembly: AssemblyFileVersion (Consts.FxFileVersion)]
[assembly: AssemblyDescription ("Mono C# Compiler")]

View File

@@ -0,0 +1 @@
bb0089306539349ccfea3105af58ca74ffbfc0ee

107
mcs/mcs/Makefile Normal file
View File

@@ -0,0 +1,107 @@
# To produce a debugging parser, use the version that says "-cvt"
JAY_FLAGS=-c
# JAY_FLAGS=-cvt
thisdir := mcs
SUBDIRS :=
include ../build/rules.make
EXTRA_DISTFILES = \
mcs.csproj \
mcs.sln \
cs-parser.jay \
mcs.exe.sources
ifeq (basic, $(PROFILE))
PROGRAM = basic.exe
sourcefile = mcs.exe.sources
else
PROGRAM_USE_INTERMEDIATE_FILE = true
PROGRAM = mcs.exe
the_libdir = $(topdir)/class/lib/build/
LOCAL_MCS_FLAGS += -lib:$(topdir)/class/lib/build -debug
endif
LOCAL_MCS_FLAGS += -d:STATIC,NO_SYMBOL_WRITER,NO_AUTHENTICODE
PROGRAM_INSTALL_DIR = $(mono_libdir)/mono/4.5
PROGRAM_COMPILE = $(BOOT_COMPILE)
BUILT_SOURCES = cs-parser.cs
CLEAN_FILES += y.output
%-parser.cs: %-parser.jay $(topdir)/jay/skeleton.cs
$(topdir)/jay/jay $(JAY_FLAGS) < $(topdir)/jay/skeleton.cs $< > jay-tmp.out && mv jay-tmp.out $@
KEEP_OUTPUT_FILE_COPY = yes
include ../build/executable.make
#
# Below this line we have local targets used for testing and development
#
# Testing targets
TIME = time
# This used to be called test, but that conflicts with the global
# recursive target.
btest: mcs2.exe mcs3.exe
ls -l mcs2.exe mcs3.exe
mcs2.exe: $(PROGRAM)
$(TIME) $(RUNTIME) $(RUNTIME_FLAGS) $(PROGRAM) $(USE_MCS_FLAGS) -target:exe -out:$@ $(BUILT_SOURCES) @$(response)
mcs3.exe: mcs2.exe
$(TIME) $(RUNTIME) $(RUNTIME_FLAGS) ./mcs2.exe $(USE_MCS_FLAGS) -target:exe -out:$@ $(BUILT_SOURCES) @$(response)
wc:
wc -l $(BUILT_SOURCES) `cat $(sourcefile)`
# we need this because bash tries to use its own crappy timer
FRIENDLY_TIME = $(shell which time) -f'%U seconds'
do-time : $(PROGRAM)
@ echo -n "Run 1: "
@ rm -f mcs2.exe
@ $(MAKE) TIME="$(FRIENDLY_TIME)" mcs2.exe > /dev/null || (echo FAILED; exit 1)
@ echo -n "Run 2: "
@ rm -f mcs3.exe
@ $(MAKE) TIME="$(FRIENDLY_TIME)" mcs3.exe > /dev/null || (echo FAILED; exit 1)
@ $(MAKE) do-corlib
do-corlib:
@ echo -n "corlib: "
@ rm -f ../class/lib/mscorlib.dll
@ cd ../class/corlib ; $(MAKE) BOOTSTRAP_MCS='$(FRIENDLY_TIME) mono $$(topdir)/class/lib/$(PROFILE)/mcs.exe' > /dev/null || (echo FAILED; exit 1)
PROFILER=default
do-gettext:
xgettext --keyword='Report.Error:3' --keyword='Report.Error:2' --keyword='Report.Warning:3' --keyword='Report.Warning:2' -o mcs.po --language='C#' `cat gmcs.exe.sources | grep -v /`
profile : $(PROGRAM)
$(RUNTIME) $(RUNTIME_FLAGS) --profile=$(PROFILER) $(PROGRAM) $(USE_MCS_FLAGS) -target:exe -out:mcs2.exe $(BUILT_SOURCES) @$(response)
debug-parser:
rm cs-parser.cs
$(MAKE) JAY_FLAGS=-cvt
#
# quick hack target, to quickly develop the gmcs compiler
# Update manually.
q: cs-parser.cs qh
echo 'System.Console.WriteLine ("Hello");' | mono csharp.exe
echo -e 'using System;\nConsole.WriteLine ("hello");' | mono csharp.exe
echo -e '"foo" == "bar";' | mono csharp.exe
echo -e 'var a = 1;\na + 2;' | mono csharp.exe
echo -e 'int j;\nj = 1;' | mono csharp.exe
echo -e 'var a = new int[]{1,2,3};\nfrom x in a select x;' | mono csharp.exe
echo -e 'var a = from f in System.IO.Directory.GetFiles ("/tmp") where f == "passwd" select f;' | mono csharp.exe

2262
mcs/mcs/anonymous.cs Normal file

File diff suppressed because it is too large Load Diff

640
mcs/mcs/argument.cs Normal file

File diff suppressed because it is too large Load Diff

1251
mcs/mcs/assembly.cs Normal file

File diff suppressed because it is too large Load Diff

944
mcs/mcs/assign.cs Normal file

File diff suppressed because it is too large Load Diff

990
mcs/mcs/async.cs Normal file

File diff suppressed because it is too large Load Diff

2108
mcs/mcs/attribute.cs Normal file

File diff suppressed because it is too large Load Diff

1179
mcs/mcs/cfold.cs Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
36761432a51625ec32235fbaa18324d0989c536d

1151
mcs/mcs/codegen.cs Normal file

File diff suppressed because it is too large Load Diff

226
mcs/mcs/complete.cs Normal file
View File

@@ -0,0 +1,226 @@
//
// complete.cs: Expression that are used for completion suggestions.
//
// Author:
// Miguel de Icaza (miguel@ximian.com)
// Marek Safar (marek.safar@gmail.com)
//
// Copyright 2001, 2002, 2003 Ximian, Inc.
// Copyright 2003-2009 Novell, Inc.
// Copyright 2011 Xamarin Inc
//
// Completion* classes derive from ExpressionStatement as this allows
// them to pass through the parser in many conditions that require
// statements even when the expression is incomplete (for example
// completing inside a lambda
//
using System.Collections.Generic;
using System.Linq;
namespace Mono.CSharp {
//
// A common base class for Completing expressions, it
// is just a very simple ExpressionStatement
//
public abstract class CompletingExpression : ExpressionStatement
{
public static void AppendResults (List<string> results, string prefix, IEnumerable<string> names)
{
foreach (string name in names) {
if (name == null)
continue;
if (prefix != null && !name.StartsWith (prefix))
continue;
if (results.Contains (name))
continue;
if (prefix != null)
results.Add (name.Substring (prefix.Length));
else
results.Add (name);
}
}
public override bool ContainsEmitWithAwait ()
{
return false;
}
public override Expression CreateExpressionTree (ResolveContext ec)
{
return null;
}
public override void EmitStatement (EmitContext ec)
{
// Do nothing
}
public override void Emit (EmitContext ec)
{
// Do nothing
}
}
public class CompletionSimpleName : CompletingExpression {
public string Prefix;
public CompletionSimpleName (string prefix, Location l)
{
this.loc = l;
this.Prefix = prefix;
}
protected override Expression DoResolve (ResolveContext ec)
{
var results = new List<string> ();
ec.CurrentMemberDefinition.GetCompletionStartingWith (Prefix, results);
throw new CompletionResult (Prefix, results.Distinct ().Select (l => l.Substring (Prefix.Length)).ToArray ());
}
protected override void CloneTo (CloneContext clonectx, Expression t)
{
// Nothing
}
}
public class CompletionMemberAccess : CompletingExpression {
Expression expr;
string partial_name;
TypeArguments targs;
public CompletionMemberAccess (Expression e, string partial_name, Location l)
{
this.expr = e;
this.loc = l;
this.partial_name = partial_name;
}
public CompletionMemberAccess (Expression e, string partial_name, TypeArguments targs, Location l)
{
this.expr = e;
this.loc = l;
this.partial_name = partial_name;
this.targs = targs;
}
protected override Expression DoResolve (ResolveContext rc)
{
var sn = expr as SimpleName;
const ResolveFlags flags = ResolveFlags.VariableOrValue | ResolveFlags.Type;
if (sn != null) {
expr = sn.LookupNameExpression (rc, MemberLookupRestrictions.ReadAccess | MemberLookupRestrictions.ExactArity);
//
// Resolve expression which does have type set as we need expression type
// with disable flow analysis as we don't know whether left side expression
// is used as variable or type
//
if (expr is VariableReference || expr is ConstantExpr || expr is Linq.TransparentMemberAccess) {
expr = expr.Resolve (rc);
} else if (expr is TypeParameterExpr) {
expr.Error_UnexpectedKind (rc, flags, sn.Location);
expr = null;
}
} else {
expr = expr.Resolve (rc, flags);
}
if (expr == null)
return null;
TypeSpec expr_type = expr.Type;
if (expr_type.IsPointer || expr_type.Kind == MemberKind.Void || expr_type == InternalType.NullLiteral || expr_type == InternalType.AnonymousMethod) {
expr.Error_OperatorCannotBeApplied (rc, loc, ".", expr_type);
return null;
}
if (targs != null) {
if (!targs.Resolve (rc))
return null;
}
var results = new List<string> ();
var nexpr = expr as NamespaceExpression;
if (nexpr != null) {
string namespaced_partial;
if (partial_name == null)
namespaced_partial = nexpr.Namespace.Name;
else
namespaced_partial = nexpr.Namespace.Name + "." + partial_name;
rc.CurrentMemberDefinition.GetCompletionStartingWith (namespaced_partial, results);
if (partial_name != null)
results = results.Select (l => l.Substring (partial_name.Length)).ToList ();
} else {
var r = MemberCache.GetCompletitionMembers (rc, expr_type, partial_name).Select (l => l.Name);
AppendResults (results, partial_name, r);
}
throw new CompletionResult (partial_name == null ? "" : partial_name, results.Distinct ().ToArray ());
}
protected override void CloneTo (CloneContext clonectx, Expression t)
{
CompletionMemberAccess target = (CompletionMemberAccess) t;
if (targs != null)
target.targs = targs.Clone ();
target.expr = expr.Clone (clonectx);
}
}
public class CompletionElementInitializer : CompletingExpression {
string partial_name;
public CompletionElementInitializer (string partial_name, Location l)
{
this.partial_name = partial_name;
this.loc = l;
}
protected override Expression DoResolve (ResolveContext ec)
{
var members = MemberCache.GetCompletitionMembers (ec, ec.CurrentInitializerVariable.Type, partial_name);
// TODO: Does this mean exact match only ?
// if (partial_name != null && results.Count > 0 && result [0] == "")
// throw new CompletionResult ("", new string [] { "=" });
var results = members.Where (l => (l.Kind & (MemberKind.Field | MemberKind.Property)) != 0).Select (l => l.Name).ToList ();
if (partial_name != null) {
var temp = new List<string> ();
AppendResults (temp, partial_name, results);
results = temp;
}
throw new CompletionResult (partial_name == null ? "" : partial_name, results.Distinct ().ToArray ());
}
protected override void CloneTo (CloneContext clonectx, Expression t)
{
// Nothing
}
}
public class EmptyCompletion : CompletingExpression
{
protected override void CloneTo (CloneContext clonectx, Expression target)
{
}
protected override Expression DoResolve (ResolveContext rc)
{
throw new CompletionResult ("", new string [0]);
}
}
}

237
mcs/mcs/const.cs Normal file
View File

@@ -0,0 +1,237 @@
//
// const.cs: Constant declarations.
//
// Author:
// Miguel de Icaza (miguel@ximian.com)
// Marek Safar (marek.safar@seznam.cz)
//
// Copyright 2001-2003 Ximian, Inc.
// Copyright 2003-2008 Novell, Inc.
//
#if STATIC
using IKVM.Reflection;
#else
using System.Reflection;
#endif
namespace Mono.CSharp {
public class Const : FieldBase
{
const Modifiers AllowedModifiers =
Modifiers.NEW |
Modifiers.PUBLIC |
Modifiers.PROTECTED |
Modifiers.INTERNAL |
Modifiers.PRIVATE;
public Const (TypeDefinition parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs)
: base (parent, type, mod_flags, AllowedModifiers, name, attrs)
{
ModFlags |= Modifiers.STATIC;
}
/// <summary>
/// Defines the constant in the @parent
/// </summary>
public override bool Define ()
{
if (!base.Define ())
return false;
if (!member_type.IsConstantCompatible) {
Error_InvalidConstantType (member_type, Location, Report);
}
FieldAttributes field_attr = FieldAttributes.Static | ModifiersExtensions.FieldAttr (ModFlags);
// Decimals cannot be emitted into the constant blob. So, convert to 'readonly'.
if (member_type.BuiltinType == BuiltinTypeSpec.Type.Decimal) {
field_attr |= FieldAttributes.InitOnly;
} else {
field_attr |= FieldAttributes.Literal;
}
FieldBuilder = Parent.TypeBuilder.DefineField (Name, MemberType.GetMetaInfo (), field_attr);
spec = new ConstSpec (Parent.Definition, this, MemberType, FieldBuilder, ModFlags, initializer);
Parent.MemberCache.AddMember (spec);
if ((field_attr & FieldAttributes.InitOnly) != 0)
Parent.PartialContainer.RegisterFieldForInitialization (this,
new FieldInitializer (this, initializer, Location));
if (declarators != null) {
var t = new TypeExpression (MemberType, TypeExpression.Location);
foreach (var d in declarators) {
var c = new Const (Parent, t, ModFlags & ~Modifiers.STATIC, new MemberName (d.Name.Value, d.Name.Location), OptAttributes);
c.initializer = d.Initializer;
((ConstInitializer) c.initializer).Name = d.Name.Value;
c.Define ();
Parent.PartialContainer.Members.Add (c);
}
}
return true;
}
public void DefineValue ()
{
var rc = new ResolveContext (this);
((ConstSpec) spec).GetConstant (rc);
}
/// <summary>
/// Emits the field value by evaluating the expression
/// </summary>
public override void Emit ()
{
var c = ((ConstSpec) spec).Value as Constant;
if (c.Type.BuiltinType == BuiltinTypeSpec.Type.Decimal) {
Module.PredefinedAttributes.DecimalConstant.EmitAttribute (FieldBuilder, (decimal) c.GetValue (), c.Location);
} else {
FieldBuilder.SetConstant (c.GetValue ());
}
base.Emit ();
}
public static void Error_InvalidConstantType (TypeSpec t, Location loc, Report Report)
{
if (t.IsGenericParameter) {
Report.Error (1959, loc,
"Type parameter `{0}' cannot be declared const", t.GetSignatureForError ());
} else {
Report.Error (283, loc,
"The type `{0}' cannot be declared const", t.GetSignatureForError ());
}
}
public override void Accept (StructuralVisitor visitor)
{
visitor.Visit (this);
}
}
public class ConstSpec : FieldSpec
{
Expression value;
public ConstSpec (TypeSpec declaringType, IMemberDefinition definition, TypeSpec memberType, FieldInfo fi, Modifiers mod, Expression value)
: base (declaringType, definition, memberType, fi, mod)
{
this.value = value;
}
//
// This expresion is guarantee to be a constant at emit phase only
//
public Expression Value {
get {
return value;
}
}
//
// For compiled constants we have to resolve the value as there could be constant dependecies. This
// is needed for imported constants too to get the right context type
//
public Constant GetConstant (ResolveContext rc)
{
if (value.eclass != ExprClass.Value)
value = value.Resolve (rc);
return (Constant) value;
}
}
public class ConstInitializer : ShimExpression
{
bool in_transit;
readonly FieldBase field;
public ConstInitializer (FieldBase field, Expression value, Location loc)
: base (value)
{
this.loc = loc;
this.field = field;
}
public string Name { get; set; }
protected override Expression DoResolve (ResolveContext unused)
{
if (type != null)
return expr;
var opt = ResolveContext.Options.ConstantScope;
if (field is EnumMember)
opt |= ResolveContext.Options.EnumScope;
//
// Use a context in which the constant was declared and
// not the one in which is referenced
//
var rc = new ResolveContext (field, opt);
expr = DoResolveInitializer (rc);
type = expr.Type;
return expr;
}
protected virtual Expression DoResolveInitializer (ResolveContext rc)
{
if (in_transit) {
field.Compiler.Report.Error (110, expr.Location,
"The evaluation of the constant value for `{0}' involves a circular definition",
GetSignatureForError ());
expr = null;
} else {
in_transit = true;
expr = expr.Resolve (rc);
}
in_transit = false;
if (expr != null) {
Constant c = expr as Constant;
if (c != null)
c = field.ConvertInitializer (rc, c);
if (c == null) {
if (TypeSpec.IsReferenceType (field.MemberType))
Error_ConstantCanBeInitializedWithNullOnly (rc, field.MemberType, expr.Location, GetSignatureForError ());
else if (!(expr is Constant))
Error_ExpressionMustBeConstant (rc, expr.Location, GetSignatureForError ());
else
expr.Error_ValueCannotBeConverted (rc, field.MemberType, false);
}
expr = c;
}
if (expr == null) {
expr = New.Constantify (field.MemberType, Location);
if (expr == null)
expr = Constant.CreateConstantFromValue (field.MemberType, null, Location);
expr = expr.Resolve (rc);
}
return expr;
}
public override string GetSignatureForError ()
{
if (Name == null)
return field.GetSignatureForError ();
return field.Parent.GetSignatureForError () + "." + Name;
}
public override object Accept (StructuralVisitor visitor)
{
return visitor.Visit (this);
}
}
}

2368
mcs/mcs/constant.cs Normal file

File diff suppressed because it is too large Load Diff

733
mcs/mcs/context.cs Normal file

File diff suppressed because it is too large Load Diff

2240
mcs/mcs/convert.cs Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
f93324f30602ca2f956eff102b7674a76df37471

3799
mcs/mcs/cs-tokenizer.cs Normal file

File diff suppressed because it is too large Load Diff

1297
mcs/mcs/decl.cs Normal file

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More