mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-15 17:10:51 -10:00
Compare commits
44
Commits
20190
...
playscript-mono
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6bf50d107b | ||
|
|
98aef175b2 | ||
|
|
cfbb707d77 | ||
|
|
26b44adfee | ||
|
|
7cc63291b9 | ||
|
|
242738b9b4 | ||
|
|
23daaa8f3d | ||
|
|
d26916f86c | ||
|
|
96debf77d1 | ||
|
|
26831a86d2 | ||
|
|
281208244f | ||
|
|
88eb6b008e | ||
|
|
87048f03df | ||
|
|
91e22b4d37 | ||
|
|
9c1b3cba34 | ||
|
|
8ab849eb82 | ||
|
|
6a4dcd4f6c | ||
|
|
f117b64a5d | ||
|
|
e789b6abbb | ||
|
|
7bd34e5715 | ||
|
|
d41a06ca08 | ||
|
|
8b3b6a5208 | ||
|
|
f4c24efe89 | ||
|
|
0b016adf56 | ||
|
|
5ad97cca6c | ||
|
|
057fc20fa4 | ||
|
|
9cb7a839eb | ||
|
|
2a62fb90b5 | ||
|
|
6608f5db66 | ||
|
|
a707a3dadb | ||
|
|
487b05c2b6 | ||
|
|
ad0c77db0f | ||
|
|
951f9a7912 | ||
|
|
9b63f759fb | ||
|
|
2e255604b2 | ||
|
|
2226f02696 | ||
|
|
0ea5ed961e | ||
|
|
abbf953e28 | ||
|
|
4d4e3c3d5b | ||
|
|
26a0904c82 | ||
|
|
3dfaaa542d | ||
|
|
005dbf7840 | ||
|
|
80d3d461c3 | ||
|
|
7554e7cd95 |
No files matched your search
@@ -59,3 +59,4 @@ using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: ComVisible (false)]
|
||||
|
||||
[assembly: InternalsVisibleTo ("PlayScript.Core, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
|
||||
+19
-2
@@ -41,9 +41,10 @@ namespace Microsoft.CSharp.RuntimeBinder
|
||||
IList<CSharpArgumentInfo> argumentInfo;
|
||||
readonly CSharpBinderFlags flags;
|
||||
readonly Type context;
|
||||
readonly ExpressionType operation;
|
||||
|
||||
public CSharpBinaryOperationBinder (ExpressionType operation, CSharpBinderFlags flags, Type context, IEnumerable<CSharpArgumentInfo> argumentInfo)
|
||||
: base (operation)
|
||||
: base (GetOperation (operation))
|
||||
{
|
||||
this.argumentInfo = new ReadOnlyCollectionBuilder<CSharpArgumentInfo> (argumentInfo);
|
||||
if (this.argumentInfo.Count != 2)
|
||||
@@ -51,12 +52,24 @@ namespace Microsoft.CSharp.RuntimeBinder
|
||||
|
||||
this.flags = flags;
|
||||
this.context = context;
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
static ExpressionType GetOperation (ExpressionType exprType)
|
||||
{
|
||||
switch (exprType) {
|
||||
case (ExpressionType) 0x80000:
|
||||
case (ExpressionType) 0x80001:
|
||||
return ExpressionType.Extension;
|
||||
default:
|
||||
return exprType;
|
||||
}
|
||||
}
|
||||
|
||||
Compiler.Binary.Operator GetOperator (out bool isCompound)
|
||||
{
|
||||
isCompound = false;
|
||||
switch (Operation) {
|
||||
switch (operation) {
|
||||
case ExpressionType.Add:
|
||||
return Compiler.Binary.Operator.Addition;
|
||||
case ExpressionType.AddAssign:
|
||||
@@ -123,6 +136,10 @@ namespace Microsoft.CSharp.RuntimeBinder
|
||||
case ExpressionType.SubtractAssign:
|
||||
isCompound = true;
|
||||
return Compiler.Binary.Operator.Subtraction;
|
||||
case (ExpressionType) 0x80000:
|
||||
return Compiler.Binary.Operator.StrictEquality;
|
||||
case (ExpressionType) 0x80001:
|
||||
return Compiler.Binary.Operator.StrictInequality;
|
||||
default:
|
||||
throw new NotImplementedException (Operation.ToString ());
|
||||
}
|
||||
|
||||
@@ -66,11 +66,14 @@ namespace Microsoft.CSharp.RuntimeBinder
|
||||
}
|
||||
|
||||
public DynamicMetaObject Bind (DynamicContext ctx, Type callingType)
|
||||
{
|
||||
return Bind (new Compiler.ResolveContext (new RuntimeBinderContext (ctx, callingType), ResolveOptions));
|
||||
}
|
||||
|
||||
public DynamicMetaObject Bind (Compiler.ResolveContext rc)
|
||||
{
|
||||
Expression res;
|
||||
try {
|
||||
var rc = new Compiler.ResolveContext (new RuntimeBinderContext (ctx, callingType), ResolveOptions);
|
||||
|
||||
// Static typemanager and internal caches are not thread-safe
|
||||
lock (resolver) {
|
||||
expr = expr.Resolve (rc, Compiler.ResolveFlags.VariableOrValue);
|
||||
|
||||
@@ -55,4 +55,7 @@
|
||||
../../build/common/Consts.cs
|
||||
../../tools/monop/outline.cs
|
||||
../../mcs/cs-parser.cs
|
||||
../../mcs/ps-parser.cs
|
||||
../../mcs/ps-tokenizer.cs
|
||||
../../mcs/playscript.cs
|
||||
Assembly/AssemblyInfo.cs
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package {
|
||||
|
||||
public class ArgumentError extends Error {
|
||||
|
||||
public function ArgumentError(message:String = "") {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
//
|
||||
// Array.play
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.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.
|
||||
//
|
||||
|
||||
package {
|
||||
public dynamic class Array
|
||||
{
|
||||
public static const CASEINSENSITIVE:uint = 1;
|
||||
public static const DESCENDING:uint = 2;
|
||||
public static const UNIQUESORT:uint = 4;
|
||||
public static const RETURNINDEXEDARRAY:uint = 8;
|
||||
public static const NUMERIC:uint = 16;
|
||||
|
||||
private static const DELETED:Object = new Object ();
|
||||
|
||||
var vector:Vector.<Object>;
|
||||
|
||||
public function Array (numElements:int = 0)
|
||||
{
|
||||
vector = new Vector.<Object> (numElements);
|
||||
}
|
||||
|
||||
public function Array (...rest)
|
||||
{
|
||||
vector = new Vector.<Object> (rest);
|
||||
}
|
||||
|
||||
public function get length ():uint
|
||||
{
|
||||
return vector.length;
|
||||
}
|
||||
|
||||
public function set length (value:uint):void
|
||||
{
|
||||
vector.length = value;
|
||||
}
|
||||
|
||||
// TODO:
|
||||
//public function push (...rest):uint
|
||||
//{
|
||||
// throw new System.NotImplementedException ();
|
||||
// // TODO: return vector.push (rest);
|
||||
//}
|
||||
|
||||
|
||||
public function splice (startIndex:int = 0, deleteCount:uint = 4294967295 /*uint.MAX_VALUE*/, ...values):Array
|
||||
{
|
||||
throw new System.NotImplementedException ();
|
||||
}
|
||||
|
||||
//
|
||||
// Extensions to AS3
|
||||
//
|
||||
public function push (value:Object):uint
|
||||
{
|
||||
return vector.push (value);
|
||||
}
|
||||
|
||||
internal function setValue (index:uint, value:Object):void
|
||||
{
|
||||
if (index < 0)
|
||||
throw new System.NotImplementedException (); // TODO: Allowed but how to handle
|
||||
|
||||
//
|
||||
// Assigning out of array range
|
||||
//
|
||||
if (index >= vector.length) {
|
||||
// while (length < index - 1)
|
||||
// list.Add (default (T)); // TODO: Need better "invisible" value, perhaps DELETED would work ?
|
||||
|
||||
vector.push (value);
|
||||
return;
|
||||
}
|
||||
|
||||
vector.setValue (index, value);
|
||||
}
|
||||
|
||||
internal function getValue (index:uint):*
|
||||
{
|
||||
if (index < 0 || index > vector.length)
|
||||
return undefined;
|
||||
|
||||
return vector.getValue (index);
|
||||
}
|
||||
|
||||
internal function deleteValue (index:uint):void
|
||||
{
|
||||
setValue (index, DELETED);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// AssemblyInfo.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar ([email protected])
|
||||
//
|
||||
// Copyright 2013 Xamarin Inc (http://www.xamarin.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;
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Security;
|
||||
using System.Security.Permissions;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about the assembly
|
||||
|
||||
[assembly: AssemblyTitle ("PlayScript.Core.dll")]
|
||||
[assembly: AssemblyDescription ("PlayScript.Core.dll")]
|
||||
[assembly: AssemblyDefaultAlias ("PlayScript.Core.dll")]
|
||||
|
||||
[assembly: AssemblyCompany (Consts.MonoCompany)]
|
||||
[assembly: AssemblyProduct (Consts.MonoProduct)]
|
||||
[assembly: AssemblyCopyright (Consts.MonoCopyright)]
|
||||
[assembly: AssemblyVersion (Consts.FxVersion)]
|
||||
[assembly: SatelliteContractVersion (Consts.FxVersion)]
|
||||
[assembly: AssemblyInformationalVersion (Consts.FxFileVersion)]
|
||||
[assembly: AssemblyFileVersion (Consts.FxFileVersion)]
|
||||
|
||||
[assembly: NeutralResourcesLanguage ("en-US")]
|
||||
[assembly: CLSCompliant (false)]
|
||||
|
||||
[assembly: ComVisible (false)]
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using System;
|
||||
|
||||
namespace _root
|
||||
{
|
||||
public static class Boolean
|
||||
{
|
||||
public static string toString(this bool b) {
|
||||
return b ? "true" : "false";
|
||||
}
|
||||
|
||||
public static bool valueOf(this bool b) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// Date.play
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.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.
|
||||
//
|
||||
|
||||
package {
|
||||
public final dynamic class Date
|
||||
{
|
||||
public function Date (yearOrTimevalue:Object = null, month:Number = 1, date:Number = 1, hour:Number = 0, minute:Number = 0, second:Number = 0, millisecond:Number = 0)
|
||||
{
|
||||
}
|
||||
|
||||
public static function UTC (year:Number, month:Number, date:Number = 1, hour:Number = 0, minute:Number = 0, second:Number = 0, millisecond:Number = 0):Number
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package {
|
||||
|
||||
public class DefinitionError extends Error {
|
||||
|
||||
public function DefinitionError(message:String = "") {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using System;
|
||||
|
||||
namespace _root
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
|
||||
public class DeprecatedAttribute : Attribute
|
||||
{
|
||||
public DeprecatedAttribute()
|
||||
{
|
||||
}
|
||||
|
||||
public string message {get;set;}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using System;
|
||||
|
||||
namespace _root
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
|
||||
public class EmbedAttribute : Attribute
|
||||
{
|
||||
public string source { get; set; }
|
||||
|
||||
public string mimeType { get; set; }
|
||||
|
||||
public string embedAsCFF { get; set; }
|
||||
|
||||
public string fontFamily { get; set; }
|
||||
|
||||
public string symbol { get; set; }
|
||||
|
||||
public EmbedAttribute (string _source = null)
|
||||
{
|
||||
source = _source;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
//
|
||||
// Error.play
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright 2013 Zynga Inc.
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.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.
|
||||
//
|
||||
|
||||
package {
|
||||
|
||||
public dynamic class Error extends System.Exception
|
||||
{
|
||||
private var error_id : int;
|
||||
|
||||
public function Error (message:String = "", id:int = 0)
|
||||
{
|
||||
super (message);
|
||||
error_id = id;
|
||||
}
|
||||
|
||||
public function get errorID () : int
|
||||
{
|
||||
return error_id;
|
||||
}
|
||||
|
||||
public function get message () : String
|
||||
{
|
||||
return Message;
|
||||
}
|
||||
|
||||
public function set message (value:String): void
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function get name () : String
|
||||
{
|
||||
return GetType().Name;
|
||||
}
|
||||
|
||||
public function set name (value:String): void
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function getStackTrace () : String
|
||||
{
|
||||
return StackTrace;
|
||||
}
|
||||
|
||||
public static function getErrorMessage (index:int) : String
|
||||
{
|
||||
// TODO: Finish all error messages
|
||||
var msg:String;
|
||||
switch (index) {
|
||||
case 1000:
|
||||
msg = "The system is out of memory.";
|
||||
break;
|
||||
case 1001:
|
||||
msg = "The method {0} is not implemented.";
|
||||
break;
|
||||
case 1002:
|
||||
msg = "Number.toPrecision has a range of 1 to 21. Number.toFixed and Number.toExponential have a range of 0 to 20. Specified value is not within expected range.";
|
||||
break;
|
||||
case 1007:
|
||||
msg = "Instantiation attempted on a non-constructor.";
|
||||
break;
|
||||
case 1009:
|
||||
msg = "Cannot access a property or method of a null object reference.";
|
||||
break;
|
||||
}
|
||||
|
||||
if (msg == null)
|
||||
return System.String.Format ("#{0}", index);
|
||||
|
||||
return System.String.Format ("#{0}: {1}", index, msg);
|
||||
}
|
||||
|
||||
public static function throwError (type:Class, index:uint, ...rest) : *
|
||||
{
|
||||
throw new System.NotImplementedException ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using System;
|
||||
|
||||
namespace _root
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
|
||||
public class EventAttribute : Attribute
|
||||
{
|
||||
public string name { get; set; }
|
||||
|
||||
public string type { get; set; }
|
||||
|
||||
public EventAttribute ()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace _root
|
||||
{
|
||||
public static class Extensions
|
||||
{
|
||||
// public static string toString(this object o)
|
||||
// {
|
||||
// return o.ToString ();
|
||||
// }
|
||||
|
||||
public static string toLocaleString(this object o)
|
||||
{
|
||||
return o.ToString ();
|
||||
}
|
||||
|
||||
public static bool hasOwnProperty(this object o, string name)
|
||||
{
|
||||
var t = o.GetType ();
|
||||
return t.GetProperty(name) != null || t.GetField(name) != null;
|
||||
}
|
||||
|
||||
public static string toString(this uint o, int radix = 10)
|
||||
{
|
||||
return Convert.ToString (o, radix);
|
||||
}
|
||||
|
||||
//
|
||||
// IList extensions (for arrays, etc).
|
||||
//
|
||||
|
||||
// public static int get_length(this IList list)
|
||||
// {
|
||||
// return list.Count;
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// FunctionExtensions.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright 2013 Zynga Inc.
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.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;
|
||||
|
||||
namespace _root {
|
||||
|
||||
public static class FunctionExtensions {
|
||||
|
||||
public static dynamic apply (this Delegate d, object thisArg = null, Array argArray = null)
|
||||
{
|
||||
return d.DynamicInvoke (argArray != null ? argArray.ToArray() : null);
|
||||
}
|
||||
|
||||
public static dynamic call (this Delegate d, object thisArg = null, params object[] rest)
|
||||
{
|
||||
return d.DynamicInvoke (rest);
|
||||
}
|
||||
|
||||
// this returns the number of arguments to the delegate method
|
||||
//public static int get_length(this Delegate d) {
|
||||
// return d.Method.GetParameters().Length;
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package {
|
||||
|
||||
public class JSON {
|
||||
|
||||
public static function parse(text:String, reviver:Function = null):Object {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public static function stringify(value:Object, replacer:* = null, space:* = null):String {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
thisdir = class/PlayScript.Core
|
||||
include ../../build/rules.make
|
||||
|
||||
LIBRARY = PlayScript.Core.dll
|
||||
LIBRARY_SNK = ../mono.snk
|
||||
LIBRARY_PACKAGE = none
|
||||
|
||||
LIB_MCS_FLAGS = -d:DYNAMIC_SUPPORT -keyfile:$(LIBRARY_SNK) -delaysign -r:System.dll -r:System.Core.dll -r:System.Xml.dll -r:Microsoft.CSharp.dll -r:Mono.CSharp.dll
|
||||
|
||||
NO_TEST = yes
|
||||
|
||||
include ../../build/library.make
|
||||
@@ -0,0 +1,127 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package {
|
||||
|
||||
public class Math {
|
||||
|
||||
//
|
||||
// Constants
|
||||
//
|
||||
|
||||
public static const E : Number = 2.71828182845905;
|
||||
|
||||
public static const LN10 : Number = 2.302585092994046;
|
||||
|
||||
public static const LN2 : Number = 0.6931471805599453;
|
||||
|
||||
public static const LOG10E : Number = 0.4342944819032518;
|
||||
|
||||
public static const LOG2E : Number = 1.442695040888963387;
|
||||
|
||||
public static const PI : Number = 3.141592653589793;
|
||||
|
||||
public static const SQRT1_2 : Number = 0.7071067811865476;
|
||||
|
||||
public static const SQRT2 : Number = 1.4142135623730951;
|
||||
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
|
||||
public static function abs(val:Number):Number {
|
||||
return System.Math.Abs(val);
|
||||
}
|
||||
|
||||
public static function acos(val:Number):Number {
|
||||
return System.Math.Acos(val);
|
||||
}
|
||||
|
||||
public static function asin(val:Number):Number {
|
||||
return System.Math.Asin(val);
|
||||
}
|
||||
|
||||
public static function atan(val:Number):Number {
|
||||
return System.Math.Atan(val);
|
||||
}
|
||||
|
||||
public static function atan2(y:Number, x:Number):Number {
|
||||
return System.Math.Atan2(y, x);
|
||||
}
|
||||
|
||||
public static function ceil(val:Number):Number {
|
||||
return System.Math.Ceiling(val);
|
||||
}
|
||||
|
||||
public static function cos(angleRadians:Number):Number {
|
||||
return System.Math.Cos(angleRadians);
|
||||
}
|
||||
|
||||
public static function exp(val:Number):Number {
|
||||
return System.Math.Exp(val);
|
||||
}
|
||||
|
||||
public static function floor(val:Number):Number {
|
||||
return System.Math.Floor(val);
|
||||
}
|
||||
|
||||
public static function log(val:Number):Number {
|
||||
return System.Math.Log(val);
|
||||
}
|
||||
|
||||
public static function max(val1:Number, val2:Number):Number {
|
||||
return System.Math.Max(val1, val2);
|
||||
}
|
||||
|
||||
public static function max(val1:Number, val2:Number, ... rest):Number {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public static function min(val1:Number, val2:Number):Number {
|
||||
return System.Math.Min(val1, val2);
|
||||
}
|
||||
|
||||
public static function min(val1:Number, val2:Number, ... rest):Number {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public static function pow(base:Number, pow:Number):Number {
|
||||
return System.Math.Pow(base, pow);
|
||||
}
|
||||
|
||||
private static var sRandom:System.Random = new System.Random();
|
||||
|
||||
public static function random():Number {
|
||||
return sRandom.NextDouble();
|
||||
}
|
||||
|
||||
public static function round(val:Number):Number {
|
||||
return System.Math.Round(val);
|
||||
}
|
||||
|
||||
public static function sin(angleRadians:Number):Number {
|
||||
return System.Math.Sin(angleRadians);
|
||||
}
|
||||
|
||||
public static function sqrt(val:Number):Number {
|
||||
return System.Math.Sqrt(val);
|
||||
}
|
||||
|
||||
public static function tan(angleRadians:Number):Number {
|
||||
return System.Math.Tan(angleRadians);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// Namespace.play
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright 2013 Zynga Inc.
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package {
|
||||
|
||||
public final class Namespace
|
||||
{
|
||||
private var prefix_value:String;
|
||||
private var uri_value:String;
|
||||
|
||||
public function Namespace (prefix:*=null, uri:*=null)
|
||||
{
|
||||
prefix_value = prefix;
|
||||
uri_value = uri;
|
||||
}
|
||||
|
||||
//
|
||||
// Properties
|
||||
//
|
||||
public function get prefix () : String
|
||||
{
|
||||
return prefix_value;
|
||||
}
|
||||
|
||||
public function get uri () : String
|
||||
{
|
||||
return uri_value;
|
||||
}
|
||||
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
public function toString ():String
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function valueOf ():Object
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
namespace _root {
|
||||
|
||||
public static class Number {
|
||||
|
||||
//
|
||||
// Extension Methods
|
||||
//
|
||||
|
||||
public static string toExponential(this double d, uint fractionDigits) {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public static string toFixed(this double d, uint fractionDigits) {
|
||||
return d.ToString ( "F" + fractionDigits.ToString() );
|
||||
}
|
||||
|
||||
public static string toPrecision(this double d, uint precision) {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public static string toString(this double d) {
|
||||
return d.ToString();
|
||||
}
|
||||
|
||||
public static string toString(this double d, double radix) {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public static double valueOf(this double d) {
|
||||
return d;
|
||||
}
|
||||
|
||||
//
|
||||
// Constants
|
||||
//
|
||||
|
||||
public const double MAX_VALUE = System.Double.MaxValue;
|
||||
|
||||
public const double MIN_VALUE = System.Double.MinValue;
|
||||
|
||||
public const double @NaN = System.Double.NaN;
|
||||
|
||||
public const double NEGATIVE_INFINITY = System.Double.NegativeInfinity;
|
||||
|
||||
public const double POSITIVE_INFINITY = System.Double.PositiveInfinity;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
../../build/common/Consts.cs
|
||||
./Assembly/AssemblyInfo.cs
|
||||
./Array.play
|
||||
./Boolean.cs
|
||||
./Date.play
|
||||
./DeprecatedAttribute.cs
|
||||
./EmbedAttribute.cs
|
||||
./EventAttribute.cs
|
||||
./Extensions.cs
|
||||
./FunctionExtensions.cs
|
||||
./functions.cs
|
||||
./int.cs
|
||||
./Number.cs
|
||||
./StringExtensions.cs
|
||||
./ArgumentError.play
|
||||
./DefinitionError.play
|
||||
./Error.play
|
||||
./JSON.play
|
||||
./Math.play
|
||||
./Namespace.play
|
||||
./QName.play
|
||||
./RangeError.play
|
||||
./ReferenceError.play
|
||||
./RegExp.play
|
||||
./SecurityError.play
|
||||
./SyntaxError.play
|
||||
./SWFAttribute.cs
|
||||
./toplevel.play
|
||||
./TypeError.play
|
||||
./URIError.play
|
||||
./Vector.cs
|
||||
./VerifyError.play
|
||||
./XML.play
|
||||
./XMLList.play
|
||||
|
||||
./PlayScript.Runtime/BinaryOperator.cs
|
||||
./PlayScript.Runtime/Binder.cs
|
||||
./PlayScript.Runtime/DefaultObjectContext.cs
|
||||
./PlayScript.Runtime/IsPropertyBinder.cs
|
||||
./PlayScript.Runtime/PlayScriptGetMemberBinder.cs
|
||||
./PlayScript.Runtime/Operations.cs
|
||||
./PlayScript.Runtime/Undefined.cs
|
||||
./PlayScript.Runtime.CompilerServices/ConstantFieldAttribute.cs
|
||||
./PlayScript.Runtime.CompilerServices/DynamicClassAttribute.cs
|
||||
./PlayScript.Runtime.CompilerServices/NamespaceFieldAttribute.cs
|
||||
./PlayScript.Runtime.CompilerServices/PlayScriptAttribute.cs
|
||||
./PlayScript.Runtime.CompilerServices/RestArrayParameterAttribute.cs
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
//
|
||||
// ConstantFieldAttribute.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.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;
|
||||
|
||||
namespace PlayScript.Runtime.CompilerServices
|
||||
{
|
||||
[AttributeUsage (AttributeTargets.Field)]
|
||||
public sealed class ConstantFieldAttribute : Attribute
|
||||
{
|
||||
public ConstantFieldAttribute ()
|
||||
{
|
||||
}
|
||||
|
||||
public ConstantFieldAttribute (object value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public object Value { get; private set; }
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// DynamicClassAttribute.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.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;
|
||||
|
||||
namespace PlayScript.Runtime.CompilerServices
|
||||
{
|
||||
[AttributeUsage (AttributeTargets.Class)]
|
||||
public sealed class DynamicClassAttribute : Attribute
|
||||
{
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// NamespaceFieldAttribute.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.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;
|
||||
|
||||
namespace PlayScript.Runtime.CompilerServices
|
||||
{
|
||||
[AttributeUsage (AttributeTargets.Field)]
|
||||
public sealed class NamespaceFieldAttribute : Attribute
|
||||
{
|
||||
public NamespaceFieldAttribute (string uri)
|
||||
{
|
||||
Uri = uri;
|
||||
}
|
||||
|
||||
public string Uri { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// PlayScriptAttribute.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.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;
|
||||
|
||||
namespace PlayScript.Runtime.CompilerServices
|
||||
{
|
||||
[AttributeUsage (AttributeTargets.Class)]
|
||||
public sealed class PlayScriptAttribute : Attribute
|
||||
{
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// RestArrayAttribute.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.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;
|
||||
|
||||
namespace PlayScript.Runtime.CompilerServices
|
||||
{
|
||||
[AttributeUsage (AttributeTargets.Parameter)]
|
||||
public sealed class RestArrayParameterAttribute : Attribute
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
//
|
||||
// BinaryOperator.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.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.
|
||||
//
|
||||
|
||||
namespace PlayScript.Runtime
|
||||
{
|
||||
public enum BinaryOperator
|
||||
{
|
||||
Multiply = 1,
|
||||
Division = 2,
|
||||
Modulus = 3,
|
||||
Addition = 4,
|
||||
Subtraction = 5,
|
||||
|
||||
LeftShift = 10,
|
||||
RightShift = 11,
|
||||
UnsignedRightShift = 12,
|
||||
|
||||
LessThan = 20,
|
||||
GreaterThan = 21,
|
||||
LessThanOrEqual = 22,
|
||||
GreaterThanOrEqual = 23,
|
||||
Equality = 24,
|
||||
Inequality = 25,
|
||||
|
||||
BitwiseAnd = 30,
|
||||
ExclusiveOr = 31,
|
||||
BitwiseOr = 32,
|
||||
|
||||
LogicalAnd = 40,
|
||||
LogicalOr = 41,
|
||||
|
||||
StrictEquality = 50 | StrictMask,
|
||||
StrictInequality = 51 | StrictMask,
|
||||
|
||||
StrictMask = 1 >> 16
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
//
|
||||
// Binder.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.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;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using Microsoft.CSharp.RuntimeBinder;
|
||||
using System.Globalization;
|
||||
|
||||
namespace PlayScript.Runtime
|
||||
{
|
||||
public static class Binder
|
||||
{
|
||||
static readonly ConditionalWeakTable<object, ConcurrentDictionary<string, object>> dynamic_classes = new ConditionalWeakTable<object, ConcurrentDictionary<string, object>> ();
|
||||
|
||||
public static dynamic GetMember (object instance, Type context, object name)
|
||||
{
|
||||
if (instance == null)
|
||||
throw GetNullObjectReferenceException ();
|
||||
|
||||
//
|
||||
// Use index getter when name can be converted to number on array instances
|
||||
//
|
||||
var array = instance as _root.Array;
|
||||
if (array != null) {
|
||||
var index = GetArrayIndex (name);
|
||||
if (index != null) {
|
||||
return array.getValue (index.Value);
|
||||
}
|
||||
}
|
||||
|
||||
var sname = GetName (name);
|
||||
|
||||
ConcurrentDictionary<string, object> members;
|
||||
if (dynamic_classes.TryGetValue (instance, out members)) {
|
||||
object value;
|
||||
if (members.TryGetValue (sname, out value))
|
||||
return value;
|
||||
}
|
||||
|
||||
var binder = Microsoft.CSharp.RuntimeBinder.Binder.GetMember (CSharpBinderFlags.None, sname, context, new[] { CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null) });
|
||||
var callsite = CallSite<Func<CallSite, object, object>>.Create (binder);
|
||||
|
||||
// TODO: Add caching to avoid expensive Resolve
|
||||
return callsite.Target (callsite, instance);
|
||||
}
|
||||
|
||||
public static CallSiteBinder GetMember (string name, Type context, DefaultObjectContext objectContext)
|
||||
{
|
||||
return new PlayScriptGetMemberBinder (name, context, objectContext);
|
||||
}
|
||||
|
||||
public static void SetMember (object instance, Type context, object name, object value)
|
||||
{
|
||||
if (instance == null)
|
||||
throw GetNullObjectReferenceException ();
|
||||
|
||||
//
|
||||
// Use index setter when name can be converted to number on array instances
|
||||
//
|
||||
var array = instance as _root.Array;
|
||||
if (array != null) {
|
||||
var index = GetArrayIndex (name);
|
||||
if (index != null) {
|
||||
array.setValue (index.Value, value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var sname = GetName (name);
|
||||
|
||||
var binder = Microsoft.CSharp.RuntimeBinder.Binder.SetMember (CSharpBinderFlags.None, sname, context,
|
||||
new[] { CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null) });
|
||||
var callsite = CallSite<Func<CallSite, object, object, object>>.Create (binder);
|
||||
|
||||
// TODO: Better handling
|
||||
try {
|
||||
// TODO: Add caching to avoid expensive Resolve
|
||||
callsite.Target (callsite, instance, value);
|
||||
} catch (RuntimeBinderException) {
|
||||
var members = dynamic_classes.GetOrCreateValue (instance);
|
||||
|
||||
// TODO: Not thread safe
|
||||
members[sname] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<string> GetKeys (object instance)
|
||||
{
|
||||
if (instance == null)
|
||||
return new string [0];
|
||||
|
||||
//
|
||||
// Array's are different
|
||||
//
|
||||
var array = instance as _root.Array;
|
||||
if (array != null) {
|
||||
return CreateArrayKeysIterator (array.length);
|
||||
}
|
||||
|
||||
ConcurrentDictionary<string, object> members;
|
||||
if (dynamic_classes.TryGetValue (instance, out members)) {
|
||||
return CreateMemberKeysIterator (members.Keys);
|
||||
}
|
||||
|
||||
return new string [0];
|
||||
}
|
||||
|
||||
static IEnumerable<string> CreateArrayKeysIterator (uint length)
|
||||
{
|
||||
for (uint i = 0; i < length; ++i)
|
||||
yield return i.ToString (CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
static IEnumerable<string> CreateMemberKeysIterator (ICollection<string> keys)
|
||||
{
|
||||
foreach (var key in keys)
|
||||
yield return key;
|
||||
}
|
||||
|
||||
public static IEnumerable<dynamic> GetValues (object instance)
|
||||
{
|
||||
if (instance == null)
|
||||
return new dynamic [0];
|
||||
|
||||
//
|
||||
// Array's are different
|
||||
//
|
||||
var array = instance as _root.Array;
|
||||
if (array != null) {
|
||||
return CreateArrayValuesIterator (array);
|
||||
}
|
||||
|
||||
ConcurrentDictionary<string, object> members;
|
||||
if (dynamic_classes.TryGetValue (instance, out members)) {
|
||||
return CreateMemberValuesIterator (members.Values);
|
||||
}
|
||||
|
||||
return new dynamic [0];
|
||||
}
|
||||
|
||||
static IEnumerable<object> CreateArrayValuesIterator (_root.Array array)
|
||||
{
|
||||
for (uint i = 0; i < array.length; ++i)
|
||||
yield return array [i];
|
||||
}
|
||||
|
||||
static IEnumerable<object> CreateMemberValuesIterator (ICollection<object> values)
|
||||
{
|
||||
foreach (var value in values)
|
||||
yield return value;
|
||||
}
|
||||
|
||||
public static bool HasProperty (object instance, Type context, object property)
|
||||
{
|
||||
if (instance == null)
|
||||
throw GetNullObjectReferenceException ();
|
||||
|
||||
//
|
||||
// Calling in operator on Array instance means something different
|
||||
//
|
||||
var array = instance as _root.Array;
|
||||
if (array != null) {
|
||||
var index = GetArrayIndex (property);
|
||||
if (index == null)
|
||||
return false;
|
||||
|
||||
return array.length > index;
|
||||
}
|
||||
|
||||
var type = instance as Type;
|
||||
var sname = GetName (property);
|
||||
bool static_only;
|
||||
|
||||
//
|
||||
// It's null when it's not static
|
||||
//
|
||||
if (type == null) {
|
||||
ConcurrentDictionary<string, object> members;
|
||||
if (dynamic_classes.TryGetValue (instance, out members) && members.ContainsKey (sname)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
type = instance.GetType ();
|
||||
static_only = false;
|
||||
} else {
|
||||
static_only = true;
|
||||
}
|
||||
|
||||
var binder = new IsPropertyBinder (sname, context, static_only);
|
||||
|
||||
var callsite = CallSite<Func<CallSite, Type, bool>>.Create (binder);
|
||||
|
||||
// TODO: Better handling
|
||||
try {
|
||||
// TODO: Add caching to avoid expensive Resolve
|
||||
return callsite.Target (callsite, type);
|
||||
} catch (RuntimeBinderException) {
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool DeleteProperty (object instance, object property)
|
||||
{
|
||||
//
|
||||
// delete operator on Array instances
|
||||
//
|
||||
var array = instance as _root.Array;
|
||||
if (array != null) {
|
||||
var index = GetArrayIndex (property);
|
||||
if (index != null) {
|
||||
array.deleteValue (index.Value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ConcurrentDictionary<string, object> members;
|
||||
if (dynamic_classes.TryGetValue (instance, out members)) {
|
||||
var sname = GetName (property);
|
||||
|
||||
object value;
|
||||
members.TryRemove (sname, out value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static dynamic DelegateInvoke (Delegate instance, params object[] args)
|
||||
{
|
||||
if (instance == null)
|
||||
throw new NotImplementedException ();
|
||||
|
||||
return instance.DynamicInvoke (args);
|
||||
}
|
||||
|
||||
static uint? GetArrayIndex (object value)
|
||||
{
|
||||
try {
|
||||
return Convert.ToUInt32 (value);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static string GetName (object name)
|
||||
{
|
||||
// TODO: Will be special token for null key enough?
|
||||
if (name == null)
|
||||
throw new NotImplementedException ("null name");
|
||||
|
||||
return name.ToString ();
|
||||
}
|
||||
|
||||
static Exception GetNullObjectReferenceException ()
|
||||
{
|
||||
return new _root.Error ("Cannot access a property or method of a null object reference.", 1009);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
//
|
||||
// DefaultObjectContext.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.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.Collections.Generic;
|
||||
using Microsoft.CSharp.RuntimeBinder;
|
||||
using Compiler = Mono.CSharp;
|
||||
using PSCompiler = Mono.PlayScript;
|
||||
|
||||
namespace PlayScript.Runtime
|
||||
{
|
||||
public class DefaultObjectContext
|
||||
{
|
||||
readonly Stack<Compiler.Expression> stack;
|
||||
|
||||
private DefaultObjectContext ()
|
||||
{
|
||||
stack = new Stack<Compiler.Expression> ();
|
||||
}
|
||||
|
||||
internal Stack<Compiler.Expression> Context {
|
||||
get {
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
||||
public static DefaultObjectContext Create ()
|
||||
{
|
||||
return new DefaultObjectContext ();
|
||||
}
|
||||
|
||||
// TODO: Will likely need extra argument for something similar to CSharpArgumentInfoFlags to correctly
|
||||
// recreate source expression
|
||||
public void Register (object instance)
|
||||
{
|
||||
if (instance == null)
|
||||
throw new _root.TypeError (_root.Error.getErrorMessage (1009), 1009);
|
||||
|
||||
var ctx = DynamicContext.Create ();
|
||||
var expr = new PSCompiler.ObjectContextRuntimeExpression (ctx.ImportType (instance.GetType ()));
|
||||
|
||||
stack.Push (expr);
|
||||
}
|
||||
|
||||
public void Unregister ()
|
||||
{
|
||||
stack.Pop ();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
//
|
||||
// IsPropertyBinder.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2009 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;
|
||||
using System.Dynamic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.CSharp.RuntimeBinder;
|
||||
using Compiler = Mono.CSharp;
|
||||
|
||||
namespace PlayScript.Runtime
|
||||
{
|
||||
class IsPropertyBinder : DynamicMetaObjectBinder
|
||||
{
|
||||
Type callingContext;
|
||||
string name;
|
||||
bool static_only;
|
||||
|
||||
public IsPropertyBinder (string name, Type callingContext, bool staticOnly)
|
||||
{
|
||||
this.name = name;
|
||||
this.callingContext = callingContext;
|
||||
this.static_only = staticOnly;
|
||||
}
|
||||
|
||||
public override DynamicMetaObject Bind (DynamicMetaObject target, DynamicMetaObject[] args)
|
||||
{
|
||||
var ctx = DynamicContext.Create ();
|
||||
var context_type = ctx.ImportType (callingContext);
|
||||
var queried_type = ctx.ImportType ((Type) target.Value);
|
||||
var rc = new Compiler.ResolveContext (new RuntimeBinderContext (ctx, context_type), 0);
|
||||
|
||||
var expr = Compiler.Expression.MemberLookup (rc, false, queried_type,
|
||||
name, 0, Compiler.Expression.MemberLookupRestrictions.ExactArity, Compiler.Location.Null);
|
||||
|
||||
var pe = expr as Compiler.PropertyExpr;
|
||||
var result = pe != null && pe.IsStatic == static_only;
|
||||
|
||||
var binder = new CSharpBinder (
|
||||
this, new Compiler.BoolConstant (ctx.CompilerContext.BuiltinTypes, result, Compiler.Location.Null), null);
|
||||
|
||||
binder.AddRestrictions (target);
|
||||
return binder.Bind (ctx, callingContext);
|
||||
}
|
||||
|
||||
public override Type ReturnType {
|
||||
get {
|
||||
return typeof (bool);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
//
|
||||
// Operations.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.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;
|
||||
|
||||
namespace PlayScript.Runtime
|
||||
{
|
||||
public static class Operations
|
||||
{
|
||||
public static bool Comparison (BinaryOperator binaryOperator, object left, object right)
|
||||
{
|
||||
if (right is int)
|
||||
return Comparison (binaryOperator, left, (int) right);
|
||||
|
||||
if (right is string)
|
||||
return Comparison (binaryOperator, left, (string) right);
|
||||
|
||||
// TODO: uint, string, double, etc
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool Comparison (BinaryOperator binaryOperator, object left, int right)
|
||||
{
|
||||
if (left is int) {
|
||||
var l = (int) left;
|
||||
switch (binaryOperator) {
|
||||
case BinaryOperator.Equality:
|
||||
case BinaryOperator.StrictEquality:
|
||||
return l == right;
|
||||
case BinaryOperator.Inequality:
|
||||
return l != right;
|
||||
case BinaryOperator.GreaterThan:
|
||||
return l > right;
|
||||
case BinaryOperator.GreaterThanOrEqual:
|
||||
return l >= right;
|
||||
case BinaryOperator.LessThan:
|
||||
return l < right;
|
||||
case BinaryOperator.LessThanOrEqual:
|
||||
return l <= right;
|
||||
default:
|
||||
throw new NotImplementedException (binaryOperator.ToString ());
|
||||
}
|
||||
}
|
||||
|
||||
if ((binaryOperator & BinaryOperator.StrictMask) != 0)
|
||||
return binaryOperator == BinaryOperator.StrictInequality;
|
||||
|
||||
// TODO: uint, string, double, etc
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool Comparison (BinaryOperator binaryOperator, int left, object right)
|
||||
{
|
||||
if (right is int) {
|
||||
var r = (int) right;
|
||||
switch (binaryOperator) {
|
||||
case BinaryOperator.Equality:
|
||||
case BinaryOperator.StrictEquality:
|
||||
return left == r;
|
||||
case BinaryOperator.Inequality:
|
||||
case BinaryOperator.StrictInequality:
|
||||
return left != r;
|
||||
case BinaryOperator.GreaterThan:
|
||||
return left > r;
|
||||
case BinaryOperator.GreaterThanOrEqual:
|
||||
return left >= r;
|
||||
case BinaryOperator.LessThan:
|
||||
return left < r;
|
||||
case BinaryOperator.LessThanOrEqual:
|
||||
return left <= r;
|
||||
default:
|
||||
throw new NotImplementedException (binaryOperator.ToString ());
|
||||
}
|
||||
}
|
||||
|
||||
if ((binaryOperator & BinaryOperator.StrictMask) != 0)
|
||||
return binaryOperator == BinaryOperator.StrictInequality;
|
||||
|
||||
// TODO: uint, string, double, etc
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool Comparison (BinaryOperator binaryOperator, object left, string right)
|
||||
{
|
||||
if (right is string) {
|
||||
var l = (string) left;
|
||||
switch (binaryOperator) {
|
||||
case BinaryOperator.Equality:
|
||||
case BinaryOperator.StrictEquality:
|
||||
return l == right;
|
||||
case BinaryOperator.Inequality:
|
||||
case BinaryOperator.StrictInequality:
|
||||
return l != right;
|
||||
/* TODO: rules base on char comparison but how does it work with unicode
|
||||
case BinaryOperator.GreaterThan:
|
||||
return l > right;
|
||||
case BinaryOperator.GreaterThanOrEqual:
|
||||
return l >= right;
|
||||
case BinaryOperator.LessThan:
|
||||
return l < right;
|
||||
case BinaryOperator.LessThanOrEqual:
|
||||
return l <= right;
|
||||
default:
|
||||
throw new NotImplementedException (binaryOperator.ToString ());
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
if ((binaryOperator & BinaryOperator.StrictMask) != 0)
|
||||
return binaryOperator == BinaryOperator.StrictInequality;
|
||||
|
||||
// TODO: uint, string, double, etc
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Type ClassOf (object instance)
|
||||
{
|
||||
var type = instance as Type;
|
||||
if (type == null)
|
||||
throw new _root.TypeError (_root.Error.getErrorMessage (1007), 1007);
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
public static bool IsOfType<T> (ref T instance, Type expectedType)
|
||||
{
|
||||
if (expectedType == null)
|
||||
throw new _root.TypeError (_root.Error.getErrorMessage (1009), 1009);
|
||||
|
||||
if (instance == null)
|
||||
return false;
|
||||
|
||||
return expectedType.IsAssignableFrom (instance.GetType ());
|
||||
}
|
||||
|
||||
public static string TypeOf (object instance)
|
||||
{
|
||||
if (instance == null)
|
||||
return "object";
|
||||
|
||||
if (instance is string)
|
||||
return "string";
|
||||
|
||||
if (instance is int || instance is uint || instance is double)
|
||||
return "number";
|
||||
|
||||
if (instance is bool)
|
||||
return "boolean";
|
||||
|
||||
// TODO: Wrong, it has to be of a special type
|
||||
if (instance == Undefined.Value)
|
||||
return "undefined";
|
||||
|
||||
// TODO: Wrong, it has to be of a special type
|
||||
if (instance is _root.XML || instance is _root.XMLList)
|
||||
return "xml";
|
||||
|
||||
if (instance is Delegate)
|
||||
return "function";
|
||||
|
||||
return "object";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
//
|
||||
// PlayScriptGetMemberBinder.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.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;
|
||||
using System.Dynamic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.CSharp.RuntimeBinder;
|
||||
using Compiler = Mono.CSharp;
|
||||
using PSCompiler = Mono.PlayScript;
|
||||
|
||||
namespace PlayScript.Runtime
|
||||
{
|
||||
class PlayScriptGetMemberBinder : GetMemberBinder
|
||||
{
|
||||
Type callingContext;
|
||||
DefaultObjectContext objectContext;
|
||||
|
||||
public PlayScriptGetMemberBinder (string name, Type callingContext, DefaultObjectContext objectContext)
|
||||
: base (name, false)
|
||||
{
|
||||
this.callingContext = callingContext;
|
||||
this.objectContext = objectContext;
|
||||
}
|
||||
|
||||
public override DynamicMetaObject FallbackGetMember (DynamicMetaObject target, DynamicMetaObject errorSuggestion)
|
||||
{
|
||||
var ctx = DynamicContext.Create ();
|
||||
|
||||
Compiler.Expression expr = new PSCompiler.SimpleName (Name, Compiler.Location.Null);
|
||||
expr = new Compiler.Cast (new Compiler.TypeExpression (ctx.ImportType (ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);
|
||||
|
||||
var binder = new CSharpBinder (this, expr, errorSuggestion);
|
||||
binder.AddRestrictions (target);
|
||||
|
||||
// TODO: RuntimeBinderContext is not enough, it won't search global extension methods for builtin types
|
||||
var rc = new Compiler.ResolveContext (new RuntimeBinderContext (ctx, callingContext), binder.ResolveOptions);
|
||||
rc.DefaultObjectContext = new PSCompiler.WithContext (objectContext.Context);
|
||||
|
||||
return binder.Bind (rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// Undefined.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.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.
|
||||
//
|
||||
|
||||
namespace PlayScript.Runtime
|
||||
{
|
||||
public static class Undefined
|
||||
{
|
||||
public static readonly object Value = new object ();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// QName.play
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright 2013 Zynga Inc.
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.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.
|
||||
//
|
||||
|
||||
package {
|
||||
|
||||
public final class QName
|
||||
{
|
||||
private var mUri:String;
|
||||
private var mLocalName:String;
|
||||
|
||||
public function QName(@namespace:String=null, name:String=null)
|
||||
{
|
||||
mUri = uri;
|
||||
mLocalName = localName;
|
||||
}
|
||||
|
||||
public function get localName () : String
|
||||
{
|
||||
return mLocalName;
|
||||
}
|
||||
|
||||
public function get uri () : String
|
||||
{
|
||||
return mUri;
|
||||
}
|
||||
|
||||
public function toString():String {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function valueOf():Object {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// RangeError.play
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright 2013 Zynga Inc.
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.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.
|
||||
//
|
||||
|
||||
package {
|
||||
|
||||
public dynamic class RangeError extends Error {
|
||||
|
||||
public function RangeError (message:String = "", id:int = 0)
|
||||
{
|
||||
super (message, id);
|
||||
}
|
||||
|
||||
internal static function CreateIndexError (index:uint, range:uint):RangeError
|
||||
{
|
||||
return new RangeError (System.String.Format ("The index {0} is out of range {1}.", index, range), 1125);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package {
|
||||
|
||||
public class ReferenceError extends Error {
|
||||
|
||||
public function ReferenceError(message:String = "") {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package {
|
||||
import System.*;
|
||||
import System.Text.RegularExpressions.*;
|
||||
|
||||
public class RegExp {
|
||||
|
||||
//
|
||||
// Properties
|
||||
//
|
||||
/*
|
||||
public property dotall : Boolean {
|
||||
get { return mDoTail;}
|
||||
}
|
||||
public property extended : Boolean {
|
||||
get { return mExtended;}
|
||||
}
|
||||
public property global : Boolean {
|
||||
get { return mGlobal;}
|
||||
}
|
||||
public property ignoreCase : Boolean {
|
||||
get { return (mRegex.Options & RegexOptions.IgnoreCase) != 0;}
|
||||
}
|
||||
public property lastIndex : Number {
|
||||
get { throw new NotImplementedException();}
|
||||
}
|
||||
public property multiline : Boolean {
|
||||
get { return (mRegex.Options & RegexOptions.Multiline) != 0;}
|
||||
}
|
||||
|
||||
public property source : String {
|
||||
get { return mSource;}
|
||||
}
|
||||
*/
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
|
||||
public function RegExp(re:String, flags:String) {
|
||||
var options:RegexOptions = RegexOptions.None;
|
||||
for (var i:int=0; i < flags.Length; i++) {
|
||||
switch (flags.charAt(i)) {
|
||||
case "m":
|
||||
options |= RegexOptions.Multiline;
|
||||
break;
|
||||
case "i":
|
||||
options |= RegexOptions.IgnoreCase;
|
||||
break;
|
||||
case "g":
|
||||
mGlobal = true;
|
||||
break;
|
||||
case "x":
|
||||
mExtended = true;
|
||||
break;
|
||||
case "s":
|
||||
mDoTail = true;
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
mSource = re;
|
||||
mRegex = new Regex(re, options);
|
||||
}
|
||||
|
||||
public function exec(str:String):Object {
|
||||
var m = mRegex.Match(str);
|
||||
if (m.Success) {
|
||||
var a:Array = [];
|
||||
// a.push(m.Value);
|
||||
for each (var g:Group in m.Groups) {
|
||||
a.push(g.Value);
|
||||
}
|
||||
return a;
|
||||
} else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function test(str:String):Boolean {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public function replace(str:String, replaceWith:String):String {
|
||||
return mRegex.Replace(str, replaceWith);
|
||||
}
|
||||
|
||||
public function search(str:String):int {
|
||||
var m = mRegex.Match(str);
|
||||
if (!m.Success) {
|
||||
return -1;
|
||||
}
|
||||
return m.Index;
|
||||
}
|
||||
|
||||
public function match(str:String):Array {
|
||||
var a:Array = null;
|
||||
var m = mRegex.Match(str);
|
||||
while (m.Success) {
|
||||
if (a == null) a = new Array();
|
||||
a.push( m.Value );
|
||||
m = m.NextMatch();
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
public function split(str:String):Array
|
||||
{
|
||||
var a:Array = new Array();
|
||||
|
||||
var lastIndex:int = 0;
|
||||
|
||||
var m = mRegex.Match(str);
|
||||
while (m.Success) {
|
||||
|
||||
// get everything before the match
|
||||
var before:String = str.Substring(lastIndex, m.Index - lastIndex);
|
||||
|
||||
a.push(before);
|
||||
|
||||
// push all matching groups
|
||||
for (var i:int = 1; i < m.Groups.Count; i++)
|
||||
{
|
||||
a.push(m.Groups[i].Value);
|
||||
}
|
||||
|
||||
// set last index
|
||||
lastIndex = m.Index + m.Length;
|
||||
|
||||
// next match
|
||||
m = m.NextMatch();
|
||||
}
|
||||
|
||||
// push everything after last match
|
||||
var end:String = str.Substring(lastIndex, str.Length - lastIndex);
|
||||
a.push(end);
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
var mRegex:Regex;
|
||||
var mSource:String;
|
||||
var mGlobal:Boolean;
|
||||
var mExtended:Boolean;
|
||||
var mDoTail:Boolean;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using System;
|
||||
|
||||
namespace _root
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = false)]
|
||||
public class SWFAttribute : Attribute
|
||||
{
|
||||
public object width { get; set; }
|
||||
public object height { get; set; }
|
||||
public object frameRate { get; set; }
|
||||
public object backgroundColor { get; set; }
|
||||
public object quality {get;set;}
|
||||
|
||||
public SWFAttribute ()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package {
|
||||
|
||||
public class SecurityError extends Error {
|
||||
|
||||
public function SecurityError(message:String = "") {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace _root
|
||||
{
|
||||
public static class StringExtensions
|
||||
{
|
||||
public static int get_length(this String s) {
|
||||
return s.Length;
|
||||
}
|
||||
|
||||
public static String charAt (this String s, double index = 0) {
|
||||
return s[ (int)index ].ToString();
|
||||
}
|
||||
|
||||
public static int charCodeAt(this String s, double index) {
|
||||
return s[(int)index];
|
||||
}
|
||||
|
||||
public static String concat(this String s, params object[] args) {
|
||||
foreach (object arg in args)
|
||||
{
|
||||
s += arg.ToString();
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
private static char objectToChar(object o)
|
||||
{
|
||||
if (o is int) {
|
||||
return (char)(int)o;
|
||||
} else if (o is uint) {
|
||||
return (char)(uint)o;
|
||||
} else if (o is char) {
|
||||
return (char)o;
|
||||
} else {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public static String fromCharCode (params object[] charCodes)
|
||||
{
|
||||
if (charCodes.Length == 1)
|
||||
{
|
||||
return new String(objectToChar(charCodes[0]), 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
var chars = new char[charCodes.Length];
|
||||
for (int i=0; i < charCodes.Length; i++) {
|
||||
chars[i] = objectToChar(charCodes[i]);
|
||||
}
|
||||
return new String(chars);
|
||||
}
|
||||
}
|
||||
|
||||
public static int indexOf(this String s, String val, double startIndex = 0) {
|
||||
if (s == null) return -1;
|
||||
return s.IndexOf(val, (int)startIndex);
|
||||
}
|
||||
|
||||
public static int lastIndexOf(this String s, String val, double startIndex = 0x7FFFFFFF) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static int localeCompare(this String s, String other, params object[] values) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static Array match(this String s, object pattern) {
|
||||
if (pattern is RegExp) {
|
||||
// pattern is a regexp
|
||||
var re = pattern as RegExp;
|
||||
return re.match(s);
|
||||
} else {
|
||||
// pattern is a String or other object
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public static String replace (this String s, object pattern, object repl)
|
||||
{
|
||||
if (pattern is RegExp) {
|
||||
// pattern is a regexp
|
||||
var re = pattern as RegExp;
|
||||
return re.replace(s, repl.ToString());
|
||||
} else {
|
||||
// pattern is a String or other object
|
||||
return s.Replace(pattern.ToString (), repl.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public static int search(this String s, object pattern) {
|
||||
if (pattern is RegExp) {
|
||||
// pattern is a regexp
|
||||
var re = pattern as RegExp;
|
||||
return re.search(s);
|
||||
} else {
|
||||
// pattern is a String or other object
|
||||
return s.IndexOf(pattern.ToString ());
|
||||
}
|
||||
}
|
||||
|
||||
public static String slice(this String s) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static String slice(this String s, int startIndex) {
|
||||
return s.Substring(startIndex);
|
||||
}
|
||||
|
||||
public static String slice(this String s, int startIndex, int endIndex) {
|
||||
return s.Substring(startIndex, endIndex - startIndex);
|
||||
}
|
||||
|
||||
public static Array split (this String s, object delimiter, int limit = 0x7fffffff)
|
||||
{
|
||||
if (limit != 0x7fffffff) {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
if (delimiter is RegExp) {
|
||||
var re = delimiter as RegExp;
|
||||
return re.split(s);
|
||||
} else if (delimiter is String) {
|
||||
return new Array( s.Split(new String[] {(String)delimiter}, StringSplitOptions.None ));
|
||||
} else {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public static String substr (this String s, double startIndex = 0, double len = 0x7fffffff) {
|
||||
if (len == 0x7fffffff) {
|
||||
return s.Substring((int)startIndex);
|
||||
} else {
|
||||
// TODO: should this throw or be silent if length exceeded?
|
||||
return s.Substring((int)startIndex, (int)len);
|
||||
}
|
||||
}
|
||||
|
||||
public static String substring (this String s, double startIndex = 0, double endIndex = 0x7fffffff) {
|
||||
if (endIndex == 0x7fffffff) {
|
||||
return s.Substring((int)startIndex);
|
||||
} else {
|
||||
// TODO: should this throw or be silent if length exceeded?
|
||||
return s.Substring((int)startIndex, (int)endIndex - (int)startIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public static String toLocaleLowerCase(this String s) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static String toLocaleUpperCase(this String s) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static String toLowerCase(this String s) {
|
||||
return s.ToLowerInvariant();
|
||||
}
|
||||
|
||||
public static String toUpperCase(this String s) {
|
||||
return s.ToUpperInvariant();
|
||||
}
|
||||
|
||||
public static String valueOf(this String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package {
|
||||
|
||||
public class SyntaxError extends Error {
|
||||
|
||||
public function SyntaxError(message:String = "") {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// TypeError.play
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright 2013 Zynga Inc.
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.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.
|
||||
//
|
||||
|
||||
package {
|
||||
|
||||
public dynamic class TypeError extends Error {
|
||||
|
||||
public function TypeError (message:String = "", id:int = 0)
|
||||
{
|
||||
super (message, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package {
|
||||
|
||||
public class URIError extends Error {
|
||||
|
||||
public function URIError(message:String = "") {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
//
|
||||
// Vector.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.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;
|
||||
using System.Collections.Generic;
|
||||
using PlayScript.Runtime.CompilerServices;
|
||||
|
||||
namespace _root
|
||||
{
|
||||
[DynamicClass]
|
||||
public class Vector<T>
|
||||
{
|
||||
readonly List<T> list;
|
||||
|
||||
public Vector (int length = 0, bool @fixed = false)
|
||||
{
|
||||
list = new List<T> (length);
|
||||
this.@fixed = @fixed;
|
||||
}
|
||||
|
||||
public Vector (params T[] values)
|
||||
{
|
||||
list = new List<T> (values);
|
||||
}
|
||||
|
||||
private Vector (List<T> list)
|
||||
{
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
public bool @fixed { get; set; }
|
||||
|
||||
public uint length {
|
||||
get {
|
||||
return (uint) list.Count;
|
||||
}
|
||||
set {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public Vector<T> concat ([RestArrayParameter] Array args)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public Vector<T> concat (params T[] args)
|
||||
{
|
||||
var res = new List<T> (list);
|
||||
res.AddRange (args);
|
||||
return new Vector<T> (res);
|
||||
}
|
||||
|
||||
public int indexOf (T searchElement, int fromIndex)
|
||||
{
|
||||
return list.IndexOf (searchElement, fromIndex);
|
||||
}
|
||||
|
||||
public int lastIndexOf (T searchElement, int fromIndex = 0x7fffffff)
|
||||
{
|
||||
return list.LastIndexOf (searchElement, fromIndex);
|
||||
}
|
||||
|
||||
public uint push (T value)
|
||||
{
|
||||
list.Add (value);
|
||||
return length;
|
||||
}
|
||||
|
||||
public uint unshift ([RestArrayParameter] Array args)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public uint unshift (params T[] args)
|
||||
{
|
||||
list.InsertRange (0, args);
|
||||
return length;
|
||||
}
|
||||
|
||||
internal void setValue (uint index, T value)
|
||||
{
|
||||
if (index < 0 || index >= length)
|
||||
throw RangeError.CreateIndexError (index, length);
|
||||
|
||||
list [(int) index] = value;
|
||||
}
|
||||
|
||||
internal T getValue (uint index)
|
||||
{
|
||||
if (index < 0 || index >= length)
|
||||
throw RangeError.CreateIndexError (index, length);
|
||||
|
||||
return list [(int) index];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package {
|
||||
|
||||
public class VerifyError extends Error {
|
||||
|
||||
public function VerifyError(message:String = "") {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,283 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package {
|
||||
import System.*;
|
||||
import System.Xml.*;
|
||||
|
||||
public class XML {
|
||||
|
||||
var mElement:XmlElement;
|
||||
|
||||
//
|
||||
// Properties
|
||||
//
|
||||
/*
|
||||
public static property ignoreComments : Boolean {
|
||||
get { throw new System.NotImplementedException(); }
|
||||
set { throw new System.NotImplementedException(); }
|
||||
}
|
||||
|
||||
public static property ignoreProcessingInstructions : Boolean {
|
||||
get { throw new System.NotImplementedException(); }
|
||||
set { throw new System.NotImplementedException(); }
|
||||
}
|
||||
|
||||
public static property ignoreWhitespace : Boolean {
|
||||
get { throw new System.NotImplementedException(); }
|
||||
set { throw new System.NotImplementedException(); }
|
||||
}
|
||||
|
||||
public static property prettyIndent : int {
|
||||
get { throw new System.NotImplementedException(); }
|
||||
set { throw new System.NotImplementedException(); }
|
||||
}
|
||||
|
||||
public static property prettyPrinting : Boolean {
|
||||
get { throw new System.NotImplementedException(); }
|
||||
set { throw new System.NotImplementedException(); }
|
||||
}
|
||||
*/
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
|
||||
public function XML(value:Object) {
|
||||
/*
|
||||
if (value is XmlElement)
|
||||
{
|
||||
mElement = value as XmlElement;
|
||||
} else if (value is flash.utils.ByteArray)
|
||||
{
|
||||
var ba:flash.utils.ByteArray = value as flash.utils.ByteArray;
|
||||
|
||||
// read string from byte array
|
||||
ba.position = 0;
|
||||
var xmlString:String = ba.readAllUTF();
|
||||
|
||||
// parse xml document from string
|
||||
var doc:XmlDocument = new XmlDocument();
|
||||
doc.LoadXml(xmlString);
|
||||
mElement = doc.DocumentElement;
|
||||
} else if (value is String)
|
||||
{
|
||||
// parse xml document from string
|
||||
var doc:XmlDocument = new XmlDocument();
|
||||
doc.LoadXml(value as String);
|
||||
mElement = doc.DocumentElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public function XML(value:XmlNode)
|
||||
{
|
||||
// TODO: mElement = value;
|
||||
}
|
||||
|
||||
public function addNamespace(ns:Object):XML {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function appendChild(child:Object):XML {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
/*
|
||||
public function attribute(attributeName:String):XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}*/
|
||||
|
||||
public function attribute(attributeName:String):String {
|
||||
return mElement.HasAttribute(attributeName) ? mElement.GetAttribute(attributeName) : null;
|
||||
}
|
||||
|
||||
public function attributes():XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function child(propertyName:Object):XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function childIndex():int {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function children():XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function comments():XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function contains(value:XML):Boolean {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function copy():XML {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public static function defaultSettings():Object {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function descendants():XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function descendants(name:Object):XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function elements():XMLList {
|
||||
return new XMLList(mElement.GetElementsByTagName("*"));
|
||||
}
|
||||
|
||||
public function elements(name:String):XMLList {
|
||||
return new XMLList(mElement.GetElementsByTagName(name));
|
||||
}
|
||||
|
||||
public function hasComplexContent():Boolean {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function hasOwnProperty(p:String):Boolean {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function hasSimpleContent():Boolean {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function inScopeNamespaces():Array {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function insertChildAfter(child1:Object, child2:Object):* {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function insertChildBefore(child1:Object, child2:Object):* {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function length():int {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function localName():String {
|
||||
return mElement.LocalName;
|
||||
}
|
||||
|
||||
public function name():QName {
|
||||
return new QName(mElement.NamespaceURI, mElement.Name);
|
||||
}
|
||||
|
||||
public function @namespace(prefix:String = null):* {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function namespaceDeclarations():Array {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function nodeKind():String {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function normalize():XML {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function parent():* {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function prependChild(value:Object):XML {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function processingInstructions(name:String):XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function propertyIsEnumerable(p:String):Boolean {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function removeNamespace(ns:Namespace):XML {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function replace(propertyName:Object, value:XML):XML {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function setChildren(value:Object):XML {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function setLocalName(name:String):void {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function setName(name:String):void {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function setNamespace(ns:Namespace):void {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function setSettings(... rest):void {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function settings():Object {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function text():XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function toJSON(k:String):* {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function toString():String {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function toXMLString():String {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function valueOf():Object {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
/*
|
||||
public static implicit operator String (xml:XML) {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package {
|
||||
|
||||
public /*final*/ dynamic class XMLList
|
||||
{
|
||||
public function XMLList (value:*=null)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
/*
|
||||
import System.Xml.*;
|
||||
import System.Collections.*;
|
||||
import System.Collections.Generic.*;
|
||||
import System.Linq.*;
|
||||
|
||||
public class XMLList implements IEnumerable.<XML> {
|
||||
|
||||
var mList:List.<XML> = new List.<XML>();
|
||||
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
|
||||
public function XMLList(value:Object) {
|
||||
if (value == null) {
|
||||
// empty
|
||||
}
|
||||
else {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
internal function XMLList(value:XmlNodeList)
|
||||
{
|
||||
// create list of XML from node list
|
||||
|
||||
for each ( var node:XmlNode in value) {
|
||||
if (node is XmlElement) {
|
||||
mList.Add(new XML(node));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal function XMLList ()
|
||||
{
|
||||
}
|
||||
|
||||
public function attribute(attributeName:String):String {
|
||||
if (mList.Count != 1)
|
||||
throw new System.NotImplementedException();
|
||||
|
||||
return mList[0].attribute(attributeName);
|
||||
}
|
||||
|
||||
public function attributes():XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function child(propertyName:Object):XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function children():XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function comments():XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function contains(value:XML):Boolean {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function copy():XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function descendants():XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function descendants(name:Object):XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function elements():XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function elements(name:String):XMLList {
|
||||
if (mList.Count == 0)
|
||||
return new XMLList();
|
||||
|
||||
if (mList.Count != 1)
|
||||
throw new System.NotImplementedException();
|
||||
|
||||
return mList[0].elements(name);
|
||||
}
|
||||
|
||||
public function hasComplexContent():Boolean {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function hasOwnProperty(p:String):Boolean {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function hasSimpleContent():Boolean {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function length():int {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function normalize():XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function parent():Object {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function processingInstructions(name:String = "*"):XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function propertyIsEnumerable(p:String):Boolean {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function text():XMLList {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function toString():String {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function toXMLString():String {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function valueOf():Object {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public indexer this(index:int):XML {
|
||||
get { throw new System.NotImplementedException(); }
|
||||
}
|
||||
|
||||
public static implicit operator String (list:XMLList) {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
function IEnumerable.<XML>.GetEnumerator() : IEnumerator.<XML> {
|
||||
return mList.GetEnumerator();
|
||||
}
|
||||
|
||||
function IEnumerable.GetEnumerator() : IEnumerator {
|
||||
return mList.GetEnumerator();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using System;
|
||||
|
||||
namespace _root
|
||||
{
|
||||
|
||||
//
|
||||
// Conversions (must be in C# to avoid conflicts).
|
||||
//
|
||||
|
||||
public static class String_fn
|
||||
{
|
||||
public static string String (object o)
|
||||
{
|
||||
return o.ToString();
|
||||
}
|
||||
|
||||
public static string String (string s)
|
||||
{
|
||||
return s;
|
||||
}
|
||||
|
||||
public static string String (int i)
|
||||
{
|
||||
return i.ToString ();
|
||||
}
|
||||
|
||||
public static string String (uint u)
|
||||
{
|
||||
return u.ToString ();
|
||||
}
|
||||
|
||||
public static string String (double d)
|
||||
{
|
||||
return d.ToString ();
|
||||
}
|
||||
|
||||
public static string String (bool b)
|
||||
{
|
||||
return b.ToString ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class Number_fn
|
||||
{
|
||||
// Inlineable method
|
||||
public static double Number (string s)
|
||||
{
|
||||
double d;
|
||||
double.TryParse(s, out d);
|
||||
return d;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class int_fn
|
||||
{
|
||||
// Inlineable method
|
||||
public static int @int (string s)
|
||||
{
|
||||
int i;
|
||||
int.TryParse(s, out i);
|
||||
return i;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class uint_fn
|
||||
{
|
||||
|
||||
// Inlineable method
|
||||
public static uint @uint (string s)
|
||||
{
|
||||
uint u;
|
||||
uint.TryParse(s, out u);
|
||||
return u;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class Boolean_fn
|
||||
{
|
||||
|
||||
// Not inlinable.. but required to get correct results in flash.
|
||||
public static bool Boolean (object d)
|
||||
{
|
||||
if (d == null) return false;
|
||||
|
||||
TypeCode tc = Type.GetTypeCode(d.GetType());
|
||||
switch (tc) {
|
||||
case TypeCode.Boolean:
|
||||
return (bool)d;
|
||||
case TypeCode.SByte:
|
||||
return (sbyte)d != 0;
|
||||
case TypeCode.Byte:
|
||||
return (byte)d != 0;
|
||||
case TypeCode.Int16:
|
||||
return (short)d != 0;
|
||||
case TypeCode.UInt16:
|
||||
return (ushort)d != 0;
|
||||
case TypeCode.Int32:
|
||||
return (int)d != 0;
|
||||
case TypeCode.UInt32:
|
||||
return (uint)d != 0;
|
||||
case TypeCode.Int64:
|
||||
return (long)d != 0;
|
||||
case TypeCode.UInt64:
|
||||
return (ulong)d != 0;
|
||||
case TypeCode.Single:
|
||||
return (float)d != 0.0f;
|
||||
case TypeCode.Double:
|
||||
return (double)d != 0.0;
|
||||
case TypeCode.Decimal:
|
||||
return (decimal)d != 0;
|
||||
case TypeCode.String:
|
||||
var s = (string)d;
|
||||
return !string.IsNullOrEmpty(s) && s != "0" && s != "false";
|
||||
case TypeCode.Empty:
|
||||
return false;
|
||||
case TypeCode.Object:
|
||||
return d != null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Inlineable method
|
||||
public static bool Boolean (string s)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
// Copyright 2013 Zynga Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using System;
|
||||
|
||||
namespace _root
|
||||
{
|
||||
public static class @int
|
||||
{
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
|
||||
public static string toExponential(this int i, uint fractionDigits) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static string toFixed(this int i, uint fractionDigits) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static string toPrecision(this int i, uint precision) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static string toString(this int i) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static string toString(this int i, uint radix) {
|
||||
return Convert.ToString(i, (int)radix);
|
||||
}
|
||||
|
||||
public static int valueOf(this int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
//
|
||||
// Constants
|
||||
//
|
||||
|
||||
public const int MAX_VALUE = 2147483647;
|
||||
|
||||
public const int MIN_VALUE = -2147483648;
|
||||
|
||||
}
|
||||
|
||||
public static class @uint
|
||||
{
|
||||
public const uint MAX_VALUE = System.UInt32.MaxValue;
|
||||
public const uint MIN_VALUE = System.UInt32.MinValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
//
|
||||
// toplevel.play
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <[email protected]>
|
||||
//
|
||||
// Copyright 2013 Zynga Inc.
|
||||
// Copyright (C) 2013 Xamarin, Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package {
|
||||
|
||||
public function isA(obj:*, cl:Class):Boolean {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function decodeURI(uri:String):String {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function decodeURIComponent(uri:String):String {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function encodeURI(uri:String):String {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function encodeURIComponent(uri:String):String {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function escape(str:String):String {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function isFinite(num:Number):Boolean {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function isNaN (num:Number = NaN):Boolean
|
||||
{
|
||||
return System.Double.IsNaN (num);
|
||||
}
|
||||
|
||||
public function isXMLName(str:String):Boolean {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public function parseFloat(str:String):Number {
|
||||
if (!System.String.IsNullOrEmpty(str))
|
||||
{
|
||||
return System.Double.Parse(str);
|
||||
} else {
|
||||
return System.Double.NaN;
|
||||
}
|
||||
}
|
||||
|
||||
public function trace(o:System.Object):void {
|
||||
// System.Diagnostics.Debug.WriteLine(o);
|
||||
System.Console.WriteLine(o);
|
||||
}
|
||||
|
||||
public function trace(o1:System.Object, o2:System.Object):void {
|
||||
// System.Diagnostics.Debug.WriteLine("{0}{1}", o1, o2);
|
||||
System.Console.WriteLine("{0} {1}", o1, o2);
|
||||
}
|
||||
|
||||
public function trace(o1:System.Object, o2:System.Object, o3:System.Object):void {
|
||||
// System.Diagnostics.Debug.WriteLine("{0}{1}{2}", o1, o2, o3);
|
||||
System.Console.WriteLine("{0} {1} {2}", o1, o2, o3);
|
||||
}
|
||||
|
||||
public function trace(o1:System.Object, o2:System.Object, o3:System.Object, ...args):void {
|
||||
var argsStr = System.String.Concat(args);
|
||||
// System.Diagnostics.Debug.WriteLine("{0}{1}{2}{3}", o1, o2, o3, argsStr);
|
||||
System.Console.WriteLine("{0} {1} {2} {3}", o1, o2, o3, argsStr);
|
||||
}
|
||||
|
||||
public function parseInt(str:String, radix:uint = 0):int {
|
||||
if (radix != 0 && radix != 10)
|
||||
throw new System.NotImplementedException();
|
||||
|
||||
return System.Int32.Parse(str);
|
||||
}
|
||||
|
||||
public function unescape(str:String):String {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
//
|
||||
// Constants
|
||||
// Non-static in AS but why not make them static
|
||||
//
|
||||
public static const undefined : * = PlayScript.Runtime.Undefined.Value;
|
||||
public static const Infinity : Number = System.Double.PositiveInfinity;
|
||||
public static const NaN : Number = System.Double.NaN;
|
||||
|
||||
/*
|
||||
public function loadEmbed(baseObject:Object, fieldName:String):Object
|
||||
{
|
||||
// pass this off to C# code
|
||||
return PlayScript.Player.LoadEmbed(baseObject, fieldName);
|
||||
}
|
||||
|
||||
public function invokeStaticMethod(type:Class, methodName:String, args:Array):Object
|
||||
{
|
||||
// pass this off to C# code
|
||||
return PlayScript.Player.InvokeStaticMethod(type, methodName, args);
|
||||
}
|
||||
*/
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
y.output
|
||||
cs-parser.cs
|
||||
*-parser.cs
|
||||
?mcs.user
|
||||
?mcs.csproj.user
|
||||
mcs.csproj.user
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ PROGRAM_INSTALL_DIR = $(mono_libdir)/mono/4.5
|
||||
|
||||
PROGRAM_COMPILE = $(BOOT_COMPILE)
|
||||
|
||||
BUILT_SOURCES = cs-parser.cs
|
||||
BUILT_SOURCES = cs-parser.cs ps-parser.cs
|
||||
|
||||
CLEAN_FILES += y.output
|
||||
|
||||
|
||||
@@ -1177,9 +1177,7 @@ namespace Mono.CSharp {
|
||||
// At this point its the first time we know the return type that is
|
||||
// needed for the anonymous method. We create the method here.
|
||||
//
|
||||
|
||||
var invoke_mb = Delegate.GetInvokeMethod (delegate_type);
|
||||
TypeSpec return_type = invoke_mb.ReturnType;
|
||||
TypeSpec return_type = ResolveReturnType (ec, delegate_type);
|
||||
|
||||
//
|
||||
// Second: the return type of the delegate must be compatible with
|
||||
@@ -1302,6 +1300,12 @@ namespace Mono.CSharp {
|
||||
return Parameters;
|
||||
}
|
||||
|
||||
protected virtual TypeSpec ResolveReturnType (ResolveContext rc, TypeSpec delegateType)
|
||||
{
|
||||
var invoke_mb = Delegate.GetInvokeMethod (delegateType);
|
||||
return invoke_mb.ReturnType;
|
||||
}
|
||||
|
||||
protected override Expression DoResolve (ResolveContext ec)
|
||||
{
|
||||
if (ec.HasSet (ResolveContext.Options.ConstantScope)) {
|
||||
@@ -1377,10 +1381,10 @@ namespace Mono.CSharp {
|
||||
b = b.ConvertToAsyncTask (ec, ec.CurrentMemberDefinition.Parent.PartialContainer, p, return_type, delegate_type, loc);
|
||||
}
|
||||
|
||||
return CompatibleMethodFactory (return_type ?? InternalType.ErrorType, delegate_type, p, b);
|
||||
return CompatibleMethodFactory (ec, return_type ?? InternalType.ErrorType, delegate_type, p, b);
|
||||
}
|
||||
|
||||
protected virtual AnonymousMethodBody CompatibleMethodFactory (TypeSpec return_type, TypeSpec delegate_type, ParametersCompiled p, ParametersBlock b)
|
||||
protected virtual AnonymousMethodBody CompatibleMethodFactory (ResolveContext rc, TypeSpec return_type, TypeSpec delegate_type, ParametersCompiled p, ParametersBlock b)
|
||||
{
|
||||
return new AnonymousMethodBody (p, b, return_type, delegate_type, loc);
|
||||
}
|
||||
|
||||
+67
-10
@@ -353,7 +353,7 @@ namespace Mono.CSharp {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (target_type != source_type) {
|
||||
if (target_type != source_type && source_type != InternalType.ErrorType) {
|
||||
Expression resolved = ResolveConversions (ec);
|
||||
|
||||
if (resolved != this)
|
||||
@@ -392,9 +392,9 @@ namespace Mono.CSharp {
|
||||
return System.Linq.Expressions.Expression.Assign (target_object, source_object);
|
||||
}
|
||||
#endif
|
||||
protected virtual Expression ResolveConversions (ResolveContext ec)
|
||||
protected virtual Expression ResolveConversions (ResolveContext rc)
|
||||
{
|
||||
source = Convert.ImplicitConversionRequired (ec, source, target.Type, source.Location);
|
||||
source = Convert.ImplicitConversionRequiredEnhanced (rc, source, target.Type, source.Location);
|
||||
if (source == null)
|
||||
return null;
|
||||
|
||||
@@ -529,6 +529,7 @@ namespace Mono.CSharp {
|
||||
: base (mc, Options.FieldInitializerScope | Options.ConstructorScope)
|
||||
{
|
||||
this.ctor_block = constructorContext.CurrentBlock.Explicit;
|
||||
this.CurrentBlock = ctor_block;
|
||||
}
|
||||
|
||||
public override ExplicitBlock ConstructorBlock {
|
||||
@@ -545,11 +546,17 @@ namespace Mono.CSharp {
|
||||
FieldBase mc;
|
||||
|
||||
public FieldInitializer (FieldBase mc, Expression expression, Location loc)
|
||||
: base (new FieldExpr (mc.Spec, expression.Location), expression, loc)
|
||||
: base (null, expression, loc)
|
||||
{
|
||||
this.mc = mc;
|
||||
if (!mc.IsStatic)
|
||||
((FieldExpr)target).InstanceExpression = new CompilerGeneratedThis (mc.CurrentType, expression.Location);
|
||||
}
|
||||
|
||||
public bool InlineConstantInitialization { get; set; }
|
||||
|
||||
public FieldBase Field {
|
||||
get {
|
||||
return mc;
|
||||
}
|
||||
}
|
||||
|
||||
public override Location StartLocation {
|
||||
@@ -565,13 +572,27 @@ namespace Mono.CSharp {
|
||||
return null;
|
||||
|
||||
if (resolved == null) {
|
||||
var ctx = new FieldInitializerContext (mc, ec);
|
||||
resolved = base.DoResolve (ctx) as ExpressionStatement;
|
||||
if (target == null) {
|
||||
var fe = new FieldExpr (mc.Spec, source.Location);
|
||||
|
||||
if (!mc.IsStatic)
|
||||
fe.InstanceExpression = new CompilerGeneratedThis (mc.CurrentType, source.Location);
|
||||
|
||||
target = fe;
|
||||
}
|
||||
|
||||
resolved = ResolveInitializer (ec);
|
||||
}
|
||||
|
||||
return resolved;
|
||||
}
|
||||
|
||||
protected virtual ExpressionStatement ResolveInitializer (ResolveContext rc)
|
||||
{
|
||||
var ctx = new FieldInitializerContext (mc, rc);
|
||||
return base.DoResolve (ctx) as ExpressionStatement;
|
||||
}
|
||||
|
||||
public override void EmitStatement (EmitContext ec)
|
||||
{
|
||||
if (resolved == null)
|
||||
@@ -588,10 +609,46 @@ namespace Mono.CSharp {
|
||||
}
|
||||
}
|
||||
|
||||
if (resolved != this)
|
||||
if (resolved != this) {
|
||||
resolved.EmitStatement (ec);
|
||||
else
|
||||
} else {
|
||||
if (InlineConstantInitialization)
|
||||
InlineInitialization ();
|
||||
|
||||
base.EmitStatement (ec);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// For PS only which has this weird behaviour where static
|
||||
// initializer referencing another field is initialized not
|
||||
// by reference but by value but only for 1st level dependency
|
||||
//
|
||||
void InlineInitialization ()
|
||||
{
|
||||
var fe = ((FieldInitializer) resolved).Source as FieldExpr;
|
||||
if (fe == null)
|
||||
return;
|
||||
|
||||
var fb = fe.Spec.MemberDefinition as FieldBase;
|
||||
if (fb == null)
|
||||
return;
|
||||
|
||||
// TODO: Handle imported constants?
|
||||
var init = ((TypeDefinition) mc.Parent).GetFieldInitializer (fb);
|
||||
if (init == null)
|
||||
return;
|
||||
|
||||
var c = init.Source as Constant;
|
||||
if (c == null)
|
||||
return;
|
||||
|
||||
// TODO: Probably too restrictive
|
||||
if (!TypeSpecComparer.IsEqual (Field.MemberType, fb.MemberType))
|
||||
return;
|
||||
|
||||
source = c;
|
||||
return;
|
||||
}
|
||||
|
||||
public bool IsDefaultInitializer {
|
||||
|
||||
+203
-78
@@ -19,6 +19,7 @@ using System.Security;
|
||||
using System.Security.Permissions;
|
||||
using System.Text;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Mono.CompilerServices.SymbolWriter;
|
||||
|
||||
#if NET_2_1
|
||||
@@ -352,8 +353,13 @@ namespace Mono.CSharp
|
||||
|
||||
public override string GetSignatureForError ()
|
||||
{
|
||||
if (Parent != null && Parent.MemberName != null)
|
||||
return Parent.GetSignatureForError () + "." + MemberName.GetSignatureForError ();
|
||||
if (Parent != null && Parent.MemberName != null) {
|
||||
var parent = Parent.GetSignatureForError ();
|
||||
if (string.IsNullOrEmpty (parent))
|
||||
return MemberName.GetSignatureForError ();
|
||||
|
||||
return parent + "." + MemberName.GetSignatureForError ();
|
||||
}
|
||||
|
||||
return MemberName.GetSignatureForError ();
|
||||
}
|
||||
@@ -491,8 +497,9 @@ namespace Mono.CSharp
|
||||
// Holds a list of fields that have initializers
|
||||
protected List<FieldInitializer> initialized_fields;
|
||||
|
||||
// Holds a list of static fields that have initializers
|
||||
protected List<FieldInitializer> initialized_static_fields;
|
||||
// Holds a list of static initializers
|
||||
// TODO: It's both Statement and ExpressionStatement
|
||||
protected List<object> static_initializers;
|
||||
|
||||
Dictionary<MethodSpec, Method> hoisted_base_call_proxies;
|
||||
|
||||
@@ -682,6 +689,8 @@ namespace Mono.CSharp
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsPlayScriptType { get; set; }
|
||||
|
||||
bool ITypeDefinition.IsTypeForwarder {
|
||||
get {
|
||||
return false;
|
||||
@@ -935,17 +944,22 @@ namespace Mono.CSharp
|
||||
}
|
||||
|
||||
public virtual void RegisterFieldForInitialization (MemberCore field, FieldInitializer expression)
|
||||
{
|
||||
RegisterFieldForInitialization (field, expression, (field.ModFlags & Modifiers.STATIC) != 0);
|
||||
}
|
||||
|
||||
public void RegisterFieldForInitialization (MemberCore field, FieldInitializer expression, bool staticInitializer)
|
||||
{
|
||||
if (IsPartialPart)
|
||||
PartialContainer.RegisterFieldForInitialization (field, expression);
|
||||
|
||||
if ((field.ModFlags & Modifiers.STATIC) != 0){
|
||||
if (initialized_static_fields == null) {
|
||||
HasStaticFieldInitializer = true;
|
||||
initialized_static_fields = new List<FieldInitializer> (4);
|
||||
if (staticInitializer) {
|
||||
if (static_initializers == null) {
|
||||
HasStaticInitializer = true;
|
||||
static_initializers = new List<object> ();
|
||||
}
|
||||
|
||||
initialized_static_fields.Add (expression);
|
||||
static_initializers.Add (expression);
|
||||
} else {
|
||||
if (initialized_fields == null)
|
||||
initialized_fields = new List<FieldInitializer> (4);
|
||||
@@ -954,40 +968,91 @@ namespace Mono.CSharp
|
||||
}
|
||||
}
|
||||
|
||||
public void ResolveFieldInitializers (BlockContext ec)
|
||||
public FieldInitializer GetFieldInitializer (MemberCore field)
|
||||
{
|
||||
if ((field.ModFlags & Modifiers.STATIC) != 0) {
|
||||
if (static_initializers == null)
|
||||
return null;
|
||||
|
||||
foreach (var stmt in static_initializers) {
|
||||
var fi = stmt as FieldInitializer;
|
||||
if (fi == null)
|
||||
continue;
|
||||
|
||||
if (fi.Field == field)
|
||||
return fi;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (initialized_fields == null)
|
||||
return null;
|
||||
|
||||
return initialized_fields.Find (l => l.Field == field);
|
||||
|
||||
}
|
||||
|
||||
public virtual void RegisterInitialization (Statement statement, bool firstIfPossible = false)
|
||||
{
|
||||
if (static_initializers == null)
|
||||
static_initializers = new List<object> ();
|
||||
|
||||
HasStaticInitializer = true;
|
||||
if (firstIfPossible)
|
||||
static_initializers.Insert (0, statement);
|
||||
else
|
||||
static_initializers.Add (statement);
|
||||
}
|
||||
|
||||
public void ResolveFieldInitializers (BlockContext bc)
|
||||
{
|
||||
Debug.Assert (!IsPartialPart);
|
||||
|
||||
if (ec.IsStatic) {
|
||||
if (initialized_static_fields == null)
|
||||
if (bc.IsStatic) {
|
||||
if (static_initializers == null)
|
||||
return;
|
||||
|
||||
bool has_complex_initializer = !ec.Module.Compiler.Settings.Optimize;
|
||||
bool has_complex_initializer = !bc.Module.Compiler.Settings.Optimize;
|
||||
int i;
|
||||
ExpressionStatement [] init = new ExpressionStatement [initialized_static_fields.Count];
|
||||
for (i = 0; i < initialized_static_fields.Count; ++i) {
|
||||
FieldInitializer fi = initialized_static_fields [i];
|
||||
ExpressionStatement s = fi.ResolveStatement (ec);
|
||||
if (s == null) {
|
||||
s = EmptyExpressionStatement.Instance;
|
||||
} else if (!fi.IsSideEffectFree) {
|
||||
has_complex_initializer |= true;
|
||||
var init = new Statement [static_initializers.Count];
|
||||
for (i = 0; i < static_initializers.Count; ++i) {
|
||||
var s = static_initializers[i];
|
||||
FieldInitializer fi = s as FieldInitializer;
|
||||
Statement stmt;
|
||||
|
||||
if (fi != null) {
|
||||
var se = fi.ResolveStatement (bc);
|
||||
if (se == null) {
|
||||
stmt = new EmptyStatement (fi.Location);
|
||||
} else {
|
||||
stmt = new StatementExpression (se);
|
||||
if (!fi.IsSideEffectFree)
|
||||
has_complex_initializer |= true;
|
||||
}
|
||||
} else {
|
||||
// It's safe to use current context no partial types support in PS
|
||||
stmt = (Statement) s;
|
||||
if (!stmt.Resolve (bc))
|
||||
stmt = new EmptyStatement (stmt.loc);
|
||||
}
|
||||
|
||||
init [i] = s;
|
||||
init [i] = stmt;
|
||||
}
|
||||
|
||||
for (i = 0; i < initialized_static_fields.Count; ++i) {
|
||||
FieldInitializer fi = initialized_static_fields [i];
|
||||
//
|
||||
// Need special check to not optimize code like this
|
||||
// static int a = b = 5;
|
||||
// static int b = 0;
|
||||
//
|
||||
if (!has_complex_initializer && fi.IsDefaultInitializer)
|
||||
continue;
|
||||
for (i = 0; i < static_initializers.Count; ++i) {
|
||||
FieldInitializer fi = static_initializers[i] as FieldInitializer;
|
||||
if (fi != null) {
|
||||
//
|
||||
// Need special check to not optimize code like this
|
||||
// static int a = b = 5;
|
||||
// static int b = 0;
|
||||
//
|
||||
if (!has_complex_initializer && fi.IsDefaultInitializer)
|
||||
continue;
|
||||
}
|
||||
|
||||
ec.CurrentBlock.AddScopeStatement (new StatementExpression (init [i]));
|
||||
bc.CurrentBlock.AddScopeStatement (init [i]);
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -998,17 +1063,17 @@ namespace Mono.CSharp
|
||||
|
||||
for (int i = 0; i < initialized_fields.Count; ++i) {
|
||||
FieldInitializer fi = initialized_fields [i];
|
||||
ExpressionStatement s = fi.ResolveStatement (ec);
|
||||
ExpressionStatement s = fi.ResolveStatement (bc);
|
||||
if (s == null)
|
||||
continue;
|
||||
|
||||
//
|
||||
// Field is re-initialized to its default value => removed
|
||||
//
|
||||
if (fi.IsDefaultInitializer && ec.Module.Compiler.Settings.Optimize)
|
||||
if (fi.IsDefaultInitializer && bc.Module.Compiler.Settings.Optimize)
|
||||
continue;
|
||||
|
||||
ec.CurrentBlock.AddScopeStatement (new StatementExpression (s));
|
||||
bc.CurrentBlock.AddScopeStatement (new StatementExpression (s));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1081,6 +1146,24 @@ namespace Mono.CSharp
|
||||
type_bases = baseTypes;
|
||||
}
|
||||
|
||||
public void AddBaseType (FullNamedExpression baseType)
|
||||
{
|
||||
if (type_bases == null)
|
||||
type_bases = new List<FullNamedExpression> ();
|
||||
|
||||
type_bases.Add (baseType);
|
||||
}
|
||||
|
||||
public virtual void AddBaseTypes (List<FullNamedExpression> baseTypes)
|
||||
{
|
||||
if (type_bases == null) {
|
||||
type_bases = baseTypes;
|
||||
return;
|
||||
}
|
||||
|
||||
type_bases.AddRange (baseTypes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function computes the Base class and also the
|
||||
/// list of interfaces that the class or struct @c implements.
|
||||
@@ -1242,6 +1325,11 @@ namespace Mono.CSharp
|
||||
//
|
||||
int type_size = Kind == MemberKind.Struct && first_nonstatic_field == null && !(this is StateMachine) ? 1 : 0;
|
||||
|
||||
if (IsPlayScriptType && Parent is CompilationSourceFile) {
|
||||
// TODO: Package in this file could be missing
|
||||
Parent = Parent.Containers.First (l => l is PlayScript.Package).Containers[0];
|
||||
}
|
||||
|
||||
var parent_def = Parent as TypeDefinition;
|
||||
if (parent_def == null) {
|
||||
var sb = new StringBuilder ();
|
||||
@@ -2199,7 +2287,7 @@ namespace Mono.CSharp
|
||||
|
||||
containers = null;
|
||||
initialized_fields = null;
|
||||
initialized_static_fields = null;
|
||||
static_initializers = null;
|
||||
type_bases = null;
|
||||
OptAttributes = null;
|
||||
}
|
||||
@@ -2451,7 +2539,7 @@ namespace Mono.CSharp
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasStaticFieldInitializer {
|
||||
public bool HasStaticInitializer {
|
||||
get {
|
||||
return (cached_method & CachedMethods.HasStaticFieldInitializer) != 0;
|
||||
}
|
||||
@@ -2578,7 +2666,7 @@ namespace Mono.CSharp
|
||||
|
||||
public override void Emit ()
|
||||
{
|
||||
if (!has_static_constructor && HasStaticFieldInitializer) {
|
||||
if (!has_static_constructor && HasStaticInitializer) {
|
||||
var c = DefineDefaultConstructor (true);
|
||||
c.Define ();
|
||||
}
|
||||
@@ -2600,22 +2688,28 @@ namespace Mono.CSharp
|
||||
|
||||
public sealed class Class : ClassOrStruct
|
||||
{
|
||||
const Modifiers AllowedModifiers =
|
||||
Modifiers.NEW |
|
||||
Modifiers.PUBLIC |
|
||||
Modifiers.PROTECTED |
|
||||
Modifiers.INTERNAL |
|
||||
Modifiers.PRIVATE |
|
||||
Modifiers.ABSTRACT |
|
||||
Modifiers.SEALED |
|
||||
Modifiers.STATIC |
|
||||
Modifiers.UNSAFE;
|
||||
|
||||
public Class (TypeContainer parent, MemberName name, Modifiers mod, Attributes attrs)
|
||||
public Class (TypeContainer parent, MemberName name, Modifiers mod, Attributes attrs, bool playScriptType = false)
|
||||
: base (parent, name, attrs, MemberKind.Class)
|
||||
{
|
||||
var allowed =
|
||||
Modifiers.NEW |
|
||||
Modifiers.PUBLIC |
|
||||
Modifiers.PROTECTED |
|
||||
Modifiers.INTERNAL |
|
||||
Modifiers.PRIVATE |
|
||||
Modifiers.ABSTRACT |
|
||||
Modifiers.SEALED |
|
||||
Modifiers.STATIC |
|
||||
Modifiers.UNSAFE;
|
||||
|
||||
var accmods = IsTopLevel ? Modifiers.INTERNAL : Modifiers.PRIVATE;
|
||||
this.ModFlags = ModifiersExtensions.Check (AllowedModifiers, mod, accmods, Location, Report);
|
||||
if (playScriptType) {
|
||||
IsPlayScriptType = true;
|
||||
allowed &= Modifiers.AccessibilityMask;
|
||||
allowed |= Modifiers.DYNAMIC | Modifiers.SEALED;
|
||||
}
|
||||
|
||||
ModFlags = ModifiersExtensions.Check (allowed, mod, accmods, Location, Report);
|
||||
spec = new TypeSpec (Kind, null, this, null, ModFlags);
|
||||
}
|
||||
|
||||
@@ -2721,7 +2815,13 @@ namespace Mono.CSharp
|
||||
if ((ModFlags & Modifiers.METHOD_EXTENSION) != 0)
|
||||
Module.PredefinedAttributes.Extension.EmitAttribute (TypeBuilder);
|
||||
|
||||
if (base_type != null && base_type.HasDynamicElement) {
|
||||
if (IsPlayScriptType) {
|
||||
if ((ModFlags & Modifiers.DYNAMIC) != 0) {
|
||||
Module.PlayscriptAttributes.DynamicClass.EmitAttribute (TypeBuilder);
|
||||
} else {
|
||||
Module.PlayscriptAttributes.PlayScript.EmitAttribute (TypeBuilder);
|
||||
}
|
||||
} else if (base_type != null && base_type.HasDynamicElement) {
|
||||
Module.PredefinedAttributes.Dynamic.EmitAttribute (TypeBuilder, base_type, Location);
|
||||
}
|
||||
}
|
||||
@@ -3137,8 +3237,8 @@ namespace Mono.CSharp
|
||||
readonly Modifiers explicit_mod_flags;
|
||||
public MethodAttributes flags;
|
||||
|
||||
public InterfaceMemberBase (TypeDefinition parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, MemberName name, Attributes attrs)
|
||||
: base (parent, type, mod, allowed_mod, Modifiers.PRIVATE, name, attrs)
|
||||
public InterfaceMemberBase (TypeDefinition parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, Modifiers defaultModifiers, MemberName name, Attributes attrs)
|
||||
: base (parent, type, mod, allowed_mod, defaultModifiers, name, attrs)
|
||||
{
|
||||
IsInterface = parent.Kind == MemberKind.Interface;
|
||||
IsExplicitImpl = (MemberName.ExplicitInterface != null);
|
||||
@@ -3168,27 +3268,7 @@ namespace Mono.CSharp
|
||||
|
||||
if ((ModFlags & Modifiers.OVERRIDE) != 0) {
|
||||
if (base_member == null) {
|
||||
if (candidate == null) {
|
||||
if (this is Method && ((Method)this).ParameterInfo.IsEmpty && MemberName.Name == Destructor.MetadataName && MemberName.Arity == 0) {
|
||||
Report.Error (249, Location, "Do not override `{0}'. Use destructor syntax instead",
|
||||
"object.Finalize()");
|
||||
} else {
|
||||
Report.Error (115, Location, "`{0}' is marked as an override but no suitable {1} found to override",
|
||||
GetSignatureForError (), SimpleName.GetMemberType (this));
|
||||
}
|
||||
} else {
|
||||
Report.SymbolRelatedToPreviousError (candidate);
|
||||
if (this is Event)
|
||||
Report.Error (72, Location, "`{0}': cannot override because `{1}' is not an event",
|
||||
GetSignatureForError (), TypeManager.GetFullNameSignature (candidate));
|
||||
else if (this is PropertyBase)
|
||||
Report.Error (544, Location, "`{0}': cannot override because `{1}' is not a property",
|
||||
GetSignatureForError (), TypeManager.GetFullNameSignature (candidate));
|
||||
else
|
||||
Report.Error (505, Location, "`{0}': cannot override because `{1}' is not a method",
|
||||
GetSignatureForError (), TypeManager.GetFullNameSignature (candidate));
|
||||
}
|
||||
|
||||
Error_OverrideWithoutBase (candidate);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3484,6 +3564,30 @@ namespace Mono.CSharp
|
||||
base_member.GetSignatureForError ());
|
||||
}
|
||||
|
||||
protected virtual void Error_OverrideWithoutBase (MemberSpec candidate)
|
||||
{
|
||||
if (candidate == null) {
|
||||
if (this is Method && ((Method) this).ParameterInfo.IsEmpty && MemberName.Name == Destructor.MetadataName && MemberName.Arity == 0) {
|
||||
Report.Error (249, Location, "Do not override `{0}'. Use destructor syntax instead",
|
||||
"object.Finalize()");
|
||||
} else {
|
||||
Report.Error (115, Location, "`{0}' is marked as an override but no suitable {1} found to override",
|
||||
GetSignatureForError (), SimpleName.GetMemberType (this));
|
||||
}
|
||||
} else {
|
||||
Report.SymbolRelatedToPreviousError (candidate);
|
||||
if (this is Event)
|
||||
Report.Error (72, Location, "`{0}': cannot override because `{1}' is not an event",
|
||||
GetSignatureForError (), TypeManager.GetFullNameSignature (candidate));
|
||||
else if (this is PropertyBase)
|
||||
Report.Error (544, Location, "`{0}': cannot override because `{1}' is not a property",
|
||||
GetSignatureForError (), TypeManager.GetFullNameSignature (candidate));
|
||||
else
|
||||
Report.Error (505, Location, "`{0}': cannot override because `{1}' is not a method",
|
||||
GetSignatureForError (), TypeManager.GetFullNameSignature (candidate));
|
||||
}
|
||||
}
|
||||
|
||||
protected void Error_StaticReturnType ()
|
||||
{
|
||||
Report.Error (722, Location,
|
||||
@@ -3510,9 +3614,9 @@ namespace Mono.CSharp
|
||||
//
|
||||
// Returns full metadata method name
|
||||
//
|
||||
public string GetFullName (MemberName name)
|
||||
public override string GetFullName (MemberName name)
|
||||
{
|
||||
return GetFullName (name.Name);
|
||||
return GetFullName (base.GetFullName (name));
|
||||
}
|
||||
|
||||
public string GetFullName (string name)
|
||||
@@ -3578,6 +3682,9 @@ namespace Mono.CSharp
|
||||
get {
|
||||
return member_type;
|
||||
}
|
||||
set {
|
||||
member_type = value;
|
||||
}
|
||||
}
|
||||
|
||||
public FullNamedExpression TypeExpression {
|
||||
@@ -3680,6 +3787,20 @@ namespace Mono.CSharp
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// Returns full metadata method name
|
||||
//
|
||||
public virtual string GetFullName (MemberName name)
|
||||
{
|
||||
if (name.Left != null) {
|
||||
StringBuilder sb = new StringBuilder ();
|
||||
name.CreateMetadataName (sb);
|
||||
return sb.ToString ();
|
||||
}
|
||||
|
||||
return name.Name;
|
||||
}
|
||||
|
||||
public override string GetSignatureForDocumentation ()
|
||||
{
|
||||
return Parent.GetSignatureForDocumentation () + "." + MemberName.Basename;
|
||||
@@ -3687,8 +3808,12 @@ namespace Mono.CSharp
|
||||
|
||||
protected virtual bool ResolveMemberType ()
|
||||
{
|
||||
if (member_type != null)
|
||||
if (member_type != null) {
|
||||
if (type_expr == null)
|
||||
return true;
|
||||
|
||||
throw new InternalErrorException ("Multi-resolve");
|
||||
}
|
||||
|
||||
member_type = type_expr.ResolveAsType (this);
|
||||
return member_type != null;
|
||||
|
||||
+12
-4
@@ -9,6 +9,8 @@
|
||||
// Copyright 2003-2008 Novell, Inc.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
#if STATIC
|
||||
using IKVM.Reflection;
|
||||
#else
|
||||
@@ -57,6 +59,7 @@ namespace Mono.CSharp {
|
||||
|
||||
Parent.MemberCache.AddMember (spec);
|
||||
|
||||
// TODO: I think this is too late for registration. Constant can be referenced before it's initialized
|
||||
if ((field_attr & FieldAttributes.InitOnly) != 0)
|
||||
Parent.PartialContainer.RegisterFieldForInitialization (this,
|
||||
new FieldInitializer (this, initializer, Location));
|
||||
@@ -64,9 +67,11 @@ namespace Mono.CSharp {
|
||||
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;
|
||||
var c = d.Field;
|
||||
if (c.TypeExpression == null)
|
||||
c.MemberType = member_type;
|
||||
|
||||
((ConstInitializer) c.Initializer).Name = d.Name.Value;
|
||||
c.Define ();
|
||||
Parent.PartialContainer.Members.Add (c);
|
||||
}
|
||||
@@ -120,6 +125,9 @@ namespace Mono.CSharp {
|
||||
public ConstSpec (TypeSpec declaringType, IMemberDefinition definition, TypeSpec memberType, FieldInfo fi, Modifiers mod, Expression value)
|
||||
: base (declaringType, definition, memberType, fi, mod)
|
||||
{
|
||||
if (value == null)
|
||||
throw new ArgumentNullException ("value");
|
||||
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@@ -179,7 +187,7 @@ namespace Mono.CSharp {
|
||||
return expr;
|
||||
}
|
||||
|
||||
protected virtual Expression DoResolveInitializer (ResolveContext rc)
|
||||
Expression DoResolveInitializer (ResolveContext rc)
|
||||
{
|
||||
if (in_transit) {
|
||||
field.Compiler.Report.Error (110, expr.Location,
|
||||
|
||||
+6
-1
@@ -458,6 +458,11 @@ namespace Mono.CSharp {
|
||||
// It exists only as hint not to call Resolve on constants
|
||||
return true;
|
||||
}
|
||||
|
||||
public override Constant ResolveAsPlayScriptConstant (ResolveContext rc)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class IntegralConstant : Constant
|
||||
@@ -2184,7 +2189,7 @@ namespace Mono.CSharp {
|
||||
}
|
||||
|
||||
// Exlude internal compiler types
|
||||
if (targetType.Kind == MemberKind.InternalCompilerType && targetType.BuiltinType != BuiltinTypeSpec.Type.Dynamic)
|
||||
if (targetType.Kind == MemberKind.InternalCompilerType && targetType.BuiltinType != BuiltinTypeSpec.Type.Dynamic && targetType.BuiltinType != BuiltinTypeSpec.Type.Object)
|
||||
return null;
|
||||
|
||||
if (!IsLiteral && !Convert.ImplicitStandardConversionExists (this, targetType))
|
||||
|
||||
@@ -440,6 +440,8 @@ namespace Mono.CSharp
|
||||
get { return (flags & Options.ConstantCheckState) != 0; }
|
||||
}
|
||||
|
||||
public PlayScript.WithContext DefaultObjectContext { get; set; }
|
||||
|
||||
public bool DoFlowAnalysis {
|
||||
get { return (flags & Options.DoFlowAnalysis) != 0; }
|
||||
}
|
||||
@@ -457,6 +459,12 @@ namespace Mono.CSharp
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsPlayScriptType {
|
||||
get {
|
||||
return CurrentType.MemberDefinition.IsPlayScriptType;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsStatic {
|
||||
get {
|
||||
return MemberContext.IsStatic;
|
||||
|
||||
+71
-20
@@ -227,7 +227,17 @@ namespace Mono.CSharp {
|
||||
//
|
||||
// From any class-type S to any class-type T, provided S is derived from T
|
||||
//
|
||||
return TypeSpec.IsBaseClass (expr_type, target_type, true);
|
||||
if (TypeSpec.IsBaseClass (expr_type, target_type, true))
|
||||
return true;
|
||||
|
||||
// PS builtin types erasure
|
||||
switch (target_type.BuiltinType) {
|
||||
case BuiltinTypeSpec.Type.String:
|
||||
case BuiltinTypeSpec.Type.Type:
|
||||
return target_type.BuiltinType == expr_type.BuiltinType;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -336,9 +346,9 @@ namespace Mono.CSharp {
|
||||
// from the null literal to any reference-type.
|
||||
//
|
||||
if (expr_type == InternalType.NullLiteral) {
|
||||
// Exlude internal compiler types
|
||||
// Exclude internal compiler types
|
||||
if (target_type.Kind == MemberKind.InternalCompilerType)
|
||||
return target_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic;
|
||||
return target_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic || target_type.BuiltinType == BuiltinTypeSpec.Type.Object;
|
||||
|
||||
return TypeSpec.IsReferenceType (target_type);
|
||||
}
|
||||
@@ -363,6 +373,9 @@ namespace Mono.CSharp {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (expr_type.BuiltinType == BuiltinTypeSpec.Type.Object)
|
||||
return target_type.BuiltinType == BuiltinTypeSpec.Type.Object || target_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1347,25 +1360,35 @@ namespace Mono.CSharp {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (expr_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
|
||||
switch (target_type.Kind) {
|
||||
case MemberKind.ArrayType:
|
||||
case MemberKind.Class:
|
||||
if (target_type.BuiltinType == BuiltinTypeSpec.Type.Object)
|
||||
return EmptyCast.Create (expr, target_type);
|
||||
if (expr_type.BuiltinType != BuiltinTypeSpec.Type.None) {
|
||||
switch (expr_type.BuiltinType) {
|
||||
case BuiltinTypeSpec.Type.String:
|
||||
case BuiltinTypeSpec.Type.Type:
|
||||
if (expr_type.BuiltinType == target_type.BuiltinType)
|
||||
return expr;
|
||||
|
||||
goto case MemberKind.Struct;
|
||||
case MemberKind.Struct:
|
||||
case MemberKind.Delegate:
|
||||
case MemberKind.Enum:
|
||||
case MemberKind.Interface:
|
||||
case MemberKind.TypeParameter:
|
||||
Arguments args = new Arguments (1);
|
||||
args.Add (new Argument (expr));
|
||||
return new DynamicConversion (target_type, explicit_cast ? CSharpBinderFlags.ConvertExplicit : 0, args, loc).Resolve (ec);
|
||||
break;
|
||||
|
||||
case BuiltinTypeSpec.Type.Dynamic:
|
||||
switch (target_type.Kind) {
|
||||
case MemberKind.ArrayType:
|
||||
case MemberKind.Class:
|
||||
if (target_type.BuiltinType == BuiltinTypeSpec.Type.Object)
|
||||
return EmptyCast.Create (expr, target_type);
|
||||
|
||||
goto case MemberKind.Struct;
|
||||
case MemberKind.Struct:
|
||||
case MemberKind.Delegate:
|
||||
case MemberKind.Enum:
|
||||
case MemberKind.Interface:
|
||||
case MemberKind.TypeParameter:
|
||||
Arguments args = new Arguments (1);
|
||||
args.Add (new Argument (expr));
|
||||
return new DynamicConversion (target_type, explicit_cast ? CSharpBinderFlags.ConvertExplicit : 0, args, loc).Resolve (ec);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (target_type.IsNullableType)
|
||||
@@ -1452,6 +1475,18 @@ namespace Mono.CSharp {
|
||||
if (expr_type.IsStruct && TypeSpecComparer.IsEqual (expr_type, target_type))
|
||||
return expr_type == target_type ? expr : EmptyCast.Create (expr, target_type);
|
||||
|
||||
//
|
||||
// PS builtin types unification
|
||||
//
|
||||
switch (expr_type.BuiltinType) {
|
||||
case BuiltinTypeSpec.Type.String:
|
||||
case BuiltinTypeSpec.Type.Type:
|
||||
if (expr_type.BuiltinType == target_type.BuiltinType)
|
||||
return expr;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1471,6 +1506,22 @@ namespace Mono.CSharp {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Expression ImplicitConversionRequiredEnhanced (ResolveContext rc, Expression source, TypeSpec targetType, Location loc)
|
||||
{
|
||||
Expression e = ImplicitConversion (rc, source, targetType, loc);
|
||||
if (e != null)
|
||||
return e;
|
||||
|
||||
if (rc.IsPlayScriptType) {
|
||||
e = PlayScript.Convert.ImplicitConversion (rc, source, targetType);
|
||||
if (e != null)
|
||||
return e;
|
||||
}
|
||||
|
||||
source.Error_ValueCannotBeConverted (rc, targetType, false);
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs the explicit numeric conversions
|
||||
///
|
||||
|
||||
+29
-11
@@ -1043,7 +1043,9 @@ constant_declarator
|
||||
: COMMA IDENTIFIER constant_initializer
|
||||
{
|
||||
var lt = (LocatedToken) $2;
|
||||
$$ = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), (ConstInitializer) $3);
|
||||
var field = new Const (current_type, null, current_field.ModFlags, new MemberName (lt.Value, lt.Location), current_field.OptAttributes);
|
||||
|
||||
$$ = new FieldDeclarator (field, new SimpleMemberName (lt.Value, lt.Location), (ConstInitializer) $3);
|
||||
lbag.AddLocation ($$, GetLocation ($1));
|
||||
}
|
||||
;
|
||||
@@ -1145,6 +1147,9 @@ opt_field_initializer
|
||||
{
|
||||
--lexer.parsing_block;
|
||||
current_field.Initializer = (Expression) $3;
|
||||
current_type.RegisterFieldForInitialization (current_field,
|
||||
new FieldInitializer (current_field, (Expression) $3, GetLocation ($1)));
|
||||
|
||||
lbag.AppendToMember (current_field, GetLocation ($1));
|
||||
end_block (lexer.Location);
|
||||
current_local_parameters = null;
|
||||
@@ -1171,7 +1176,9 @@ field_declarator
|
||||
: COMMA IDENTIFIER
|
||||
{
|
||||
var lt = (LocatedToken) $2;
|
||||
$$ = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), null);
|
||||
var field = new Field (current_type, null, current_field.ModFlags, new MemberName (lt.Value, lt.Location), current_field.OptAttributes);
|
||||
|
||||
$$ = new FieldDeclarator (field, new SimpleMemberName (lt.Value, lt.Location), null);
|
||||
lbag.AddLocation ($$, GetLocation ($1));
|
||||
}
|
||||
| COMMA IDENTIFIER ASSIGN
|
||||
@@ -1181,9 +1188,14 @@ field_declarator
|
||||
variable_initializer
|
||||
{
|
||||
--lexer.parsing_block;
|
||||
var lt = (LocatedToken) $2;
|
||||
$$ = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), (Expression) $5);
|
||||
lbag.AddLocation ($$, GetLocation ($1), GetLocation ($3));
|
||||
var lt = (LocatedToken) $2;
|
||||
var field = new Field (current_type, null, current_field.ModFlags, new MemberName (lt.Value, lt.Location), current_field.OptAttributes);
|
||||
var decl = new FieldDeclarator (field, new SimpleMemberName (lt.Value, lt.Location), (Expression) $5);
|
||||
current_type.RegisterFieldForInitialization (field,
|
||||
new FieldInitializer (field, (Expression) $5, GetLocation ($1)));
|
||||
|
||||
lbag.AddLocation (decl, GetLocation ($1), GetLocation ($3));
|
||||
$$ = decl;
|
||||
}
|
||||
;
|
||||
|
||||
@@ -1206,8 +1218,10 @@ fixed_field_declarators
|
||||
fixed_field_declarator
|
||||
: COMMA IDENTIFIER fixed_field_size
|
||||
{
|
||||
var lt = (LocatedToken) $2;
|
||||
$$ = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), (ConstInitializer) $3);
|
||||
var lt = (LocatedToken) $2;
|
||||
var field = new FixedField (current_type, null, current_field.ModFlags, new MemberName (lt.Value, lt.Location), current_field.OptAttributes);
|
||||
|
||||
$$ = new FieldDeclarator (field, new SimpleMemberName (lt.Value, lt.Location), (ConstInitializer) $3);
|
||||
lbag.AddLocation ($$, GetLocation ($1));
|
||||
}
|
||||
;
|
||||
@@ -2421,11 +2435,11 @@ opt_event_declarators
|
||||
event_declarators
|
||||
: event_declarator
|
||||
{
|
||||
current_event_field.AddDeclarator ((FieldDeclarator) $1);
|
||||
current_event_field.AddDeclarator ((EventDeclarator) $1);
|
||||
}
|
||||
| event_declarators event_declarator
|
||||
{
|
||||
current_event_field.AddDeclarator ((FieldDeclarator) $2);
|
||||
current_event_field.AddDeclarator ((EventDeclarator) $2);
|
||||
}
|
||||
;
|
||||
|
||||
@@ -2433,7 +2447,9 @@ event_declarator
|
||||
: COMMA IDENTIFIER
|
||||
{
|
||||
var lt = (LocatedToken) $2;
|
||||
$$ = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), null);
|
||||
var field = new EventField (current_type, null, current_event_field.ModFlags, new MemberName (lt.Value, lt.Location), current_event_field.OptAttributes);
|
||||
|
||||
$$ = new EventDeclarator (field, new SimpleMemberName (lt.Value, lt.Location), null);
|
||||
lbag.AddLocation ($$, GetLocation ($1));
|
||||
}
|
||||
| COMMA IDENTIFIER ASSIGN
|
||||
@@ -2444,7 +2460,9 @@ event_declarator
|
||||
{
|
||||
--lexer.parsing_block;
|
||||
var lt = (LocatedToken) $2;
|
||||
$$ = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), (Expression) $5);
|
||||
var field = new EventField (current_type, null, current_event_field.ModFlags, new MemberName (lt.Value, lt.Location), current_event_field.OptAttributes);
|
||||
|
||||
$$ = new EventDeclarator (field, new SimpleMemberName (lt.Value, lt.Location), (Expression) $5);
|
||||
lbag.AddLocation ($$, GetLocation ($1), GetLocation ($3));
|
||||
}
|
||||
;
|
||||
|
||||
+57
-1
@@ -112,6 +112,12 @@ namespace Mono.CSharp {
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string LookupName {
|
||||
get {
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateMetadataName (StringBuilder sb)
|
||||
{
|
||||
if (Left != null)
|
||||
@@ -137,7 +143,7 @@ namespace Mono.CSharp {
|
||||
return Left.GetSignatureForDocumentation () + "." + s;
|
||||
}
|
||||
|
||||
public string GetSignatureForError ()
|
||||
public virtual string GetSignatureForError ()
|
||||
{
|
||||
string s = TypeParameters == null ? null : "<" + TypeParameters.GetSignatureForError () + ">";
|
||||
s = Name + s;
|
||||
@@ -1294,4 +1300,54 @@ namespace Mono.CSharp {
|
||||
{
|
||||
TypeSpec MemberType { get; }
|
||||
}
|
||||
|
||||
class AliasMemberDefinition : IMemberDefinition
|
||||
{
|
||||
readonly string name;
|
||||
readonly IMemberDefinition original;
|
||||
|
||||
public AliasMemberDefinition (string name, IMemberDefinition original)
|
||||
{
|
||||
this.name = name;
|
||||
this.original = original;
|
||||
}
|
||||
|
||||
public bool? CLSAttributeValue {
|
||||
get {
|
||||
return original.CLSAttributeValue;
|
||||
}
|
||||
}
|
||||
|
||||
public string Name {
|
||||
get {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsImported {
|
||||
get {
|
||||
return original.IsImported;
|
||||
}
|
||||
}
|
||||
|
||||
public string[] ConditionalConditions ()
|
||||
{
|
||||
return original.ConditionalConditions ();
|
||||
}
|
||||
|
||||
public ObsoleteAttribute GetAttributeObsolete ()
|
||||
{
|
||||
return original.GetAttributeObsolete ();
|
||||
}
|
||||
|
||||
public void SetIsAssigned ()
|
||||
{
|
||||
original.SetIsAssigned ();
|
||||
}
|
||||
|
||||
public void SetIsUsed ()
|
||||
{
|
||||
original.SetIsUsed ();
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
-2
@@ -804,7 +804,7 @@ namespace Mono.CSharp {
|
||||
//
|
||||
class DelegateInvocation : ExpressionStatement
|
||||
{
|
||||
readonly Expression InstanceExpr;
|
||||
Expression InstanceExpr;
|
||||
Arguments arguments;
|
||||
MethodSpec method;
|
||||
|
||||
@@ -834,11 +834,22 @@ namespace Mono.CSharp {
|
||||
if (del_type == null)
|
||||
return null;
|
||||
|
||||
|
||||
if (del_type == ec.Module.PlayscriptTypes.Function) {
|
||||
if (arguments == null)
|
||||
arguments = new Arguments (1);
|
||||
|
||||
arguments.Insert (0, new Argument (InstanceExpr));
|
||||
InstanceExpr = null;
|
||||
method = ec.Module.PlayScriptMembers.BinderDelegateInvoke.Resolve (loc);
|
||||
} else {
|
||||
method = Delegate.GetInvokeMethod (del_type);
|
||||
}
|
||||
|
||||
//
|
||||
// Do only core overload resolution the rest of the checks has been
|
||||
// done on primary expression
|
||||
//
|
||||
method = Delegate.GetInvokeMethod (del_type);
|
||||
var res = new OverloadResolver (new MemberSpec[] { method }, OverloadResolver.Restrictions.DelegateInvoke, loc);
|
||||
var valid = res.ResolveMember<MethodSpec> (ec, ref arguments);
|
||||
if (valid == null && !res.BestCandidateIsDynamic)
|
||||
|
||||
+7
-2
@@ -166,8 +166,13 @@ namespace Mono.CSharp
|
||||
var file = new CompilationSourceFile (module, sourceFile);
|
||||
module.AddTypeContainer (file);
|
||||
|
||||
CSharpParser parser = new CSharpParser (reader, file, report, session);
|
||||
parser.parse ();
|
||||
if (sourceFile.IsPlayScript) {
|
||||
var parser = new PlayScript.PlayScriptParser (reader, file, report, session);
|
||||
parser.parse ();
|
||||
} else {
|
||||
var parser = new CSharpParser (reader, file, report, session);
|
||||
parser.parse ();
|
||||
}
|
||||
}
|
||||
|
||||
public static int Main (string[] args)
|
||||
|
||||
+87
-24
@@ -238,6 +238,11 @@ namespace Mono.CSharp {
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual Constant ResolveAsPlayScriptConstant (ResolveContext rc)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void ErrorIsInaccesible (IMemberContext rc, string member, Location loc)
|
||||
{
|
||||
rc.Module.Compiler.Report.Error (122, loc, "`{0}' is inaccessible due to its protection level", member);
|
||||
@@ -301,6 +306,13 @@ namespace Mono.CSharp {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ec.IsPlayScriptType) {
|
||||
ec.Report.ErrorPlayScript (1067, loc, "Implicit coercion of a value of type `{0}' to an unrelated type `{1}'.",
|
||||
from_type, to_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ec.Report.DisableReporting ();
|
||||
bool expl_exists = Convert.ExplicitConversion (ec, this, target, Location.Null) != null;
|
||||
ec.Report.EnableReporting ();
|
||||
@@ -437,8 +449,7 @@ namespace Mono.CSharp {
|
||||
{
|
||||
if (eclass != ExprClass.Unresolved) {
|
||||
if ((flags & ExprClassToResolveFlags) == 0) {
|
||||
Error_UnexpectedKind (ec, flags, loc);
|
||||
return null;
|
||||
return ResolveUnexpectedKind (ec, flags);
|
||||
}
|
||||
|
||||
return this;
|
||||
@@ -452,8 +463,7 @@ namespace Mono.CSharp {
|
||||
return null;
|
||||
|
||||
if ((flags & e.ExprClassToResolveFlags) == 0) {
|
||||
e.Error_UnexpectedKind (ec, flags, loc);
|
||||
return null;
|
||||
return e.ResolveUnexpectedKind (ec, flags);
|
||||
}
|
||||
|
||||
if (e.type == null)
|
||||
@@ -535,6 +545,12 @@ namespace Mono.CSharp {
|
||||
return c;
|
||||
}
|
||||
|
||||
protected virtual Expression ResolveUnexpectedKind (ResolveContext rc, ResolveFlags flags)
|
||||
{
|
||||
Error_UnexpectedKind (rc, flags, loc);
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType)
|
||||
{
|
||||
rc.Module.Compiler.Report.Error (182, loc,
|
||||
@@ -733,7 +749,8 @@ namespace Mono.CSharp {
|
||||
None = 0,
|
||||
InvocableOnly = 1,
|
||||
ExactArity = 1 << 2,
|
||||
ReadAccess = 1 << 3
|
||||
ReadAccess = 1 << 3,
|
||||
PlayScriptConversion = 1 << 4
|
||||
}
|
||||
|
||||
//
|
||||
@@ -2910,6 +2927,14 @@ namespace Mono.CSharp {
|
||||
loc = l;
|
||||
}
|
||||
|
||||
protected override Expression ResolveUnexpectedKind (ResolveContext rc, ResolveFlags flags)
|
||||
{
|
||||
if (rc.IsPlayScriptType)
|
||||
return new PlayScript.ImplicitTypeOf (this, loc).Resolve (rc);
|
||||
|
||||
return base.ResolveUnexpectedKind (rc, flags);
|
||||
}
|
||||
|
||||
public sealed override TypeSpec ResolveAsType (IMemberContext ec)
|
||||
{
|
||||
return type;
|
||||
@@ -3211,7 +3236,7 @@ namespace Mono.CSharp {
|
||||
}
|
||||
|
||||
InstanceExpression = new This (loc);
|
||||
if (this is FieldExpr && rc.CurrentBlock.ParametersBlock.TopBlock.ThisVariable != null) {
|
||||
if (this is FieldExpr && rc.CurrentBlock != null && rc.CurrentBlock.ParametersBlock.TopBlock.ThisVariable != null) {
|
||||
using (rc.Set (ResolveContext.Options.OmitStructFlowAnalysis)) {
|
||||
InstanceExpression = InstanceExpression.Resolve (rc);
|
||||
}
|
||||
@@ -4637,12 +4662,19 @@ namespace Mono.CSharp {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (p_mod != Parameter.Modifier.PARAMS) {
|
||||
p_mod = (pd.FixedParameters[i].ModFlags & ~Parameter.Modifier.PARAMS) | (cpd.FixedParameters[i].ModFlags & Parameter.Modifier.PARAMS);
|
||||
if ((p_mod & Parameter.Modifier.VariableArgumentsMask) == 0) {
|
||||
p_mod = (pd.FixedParameters[i].ModFlags & ~Parameter.Modifier.VariableArgumentsMask) |
|
||||
(cpd.FixedParameters[i].ModFlags & Parameter.Modifier.VariableArgumentsMask);
|
||||
pt = ptypes [i];
|
||||
} else if (!params_expanded_form) {
|
||||
params_expanded_form = true;
|
||||
pt = ((ElementTypeSpec) pt).Element;
|
||||
|
||||
var array = pt as ArrayContainer;
|
||||
if (array != null)
|
||||
pt = array.Element;
|
||||
else
|
||||
pt = ec.Module.PlayscriptTypes.Object;
|
||||
|
||||
i -= 2;
|
||||
continue;
|
||||
}
|
||||
@@ -4673,9 +4705,12 @@ namespace Mono.CSharp {
|
||||
//
|
||||
// It can be applicable in expanded form (when not doing exact match like for delegates)
|
||||
//
|
||||
if (score != 0 && (p_mod & Parameter.Modifier.PARAMS) != 0 && (restrictions & Restrictions.CovariantDelegate) == 0) {
|
||||
if (score != 0 && (p_mod & Parameter.Modifier.VariableArgumentsMask) != 0 && (restrictions & Restrictions.CovariantDelegate) == 0) {
|
||||
if (!params_expanded_form) {
|
||||
pt = ((ElementTypeSpec) pt).Element;
|
||||
if (p_mod == Parameter.Modifier.PARAMS)
|
||||
pt = ((ArrayContainer) pt).Element;
|
||||
else
|
||||
pt = ec.Module.PlayscriptTypes.Object;
|
||||
}
|
||||
|
||||
if (score > 0)
|
||||
@@ -4699,9 +4734,14 @@ namespace Mono.CSharp {
|
||||
//
|
||||
// When params parameter has no argument it will be provided later if the method is the best candidate
|
||||
//
|
||||
if (arg_count + 1 == pd.Count && (cpd.FixedParameters [arg_count].ModFlags & Parameter.Modifier.PARAMS) != 0)
|
||||
// ActionScript has different logic for params style arguments when argument count matches. It still
|
||||
// created an Array with 1 element even if argument type is convertible to array
|
||||
//
|
||||
if ((arg_count + 1 == pd.Count && cpd.HasParams) ||
|
||||
(arg_count > 0 && arg_count == param_count && pd.FixedParameters[param_count - 1].ModFlags == Parameter.Modifier.RestArray))
|
||||
params_expanded_form = true;
|
||||
|
||||
|
||||
//
|
||||
// Restore original arguments for dynamic binder to keep the intention of original source code
|
||||
//
|
||||
@@ -5283,18 +5323,22 @@ namespace Mono.CSharp {
|
||||
ArrayInitializer params_initializers = null;
|
||||
bool has_unsafe_arg = pm.MemberType.IsPointer;
|
||||
int arg_count = args == null ? 0 : args.Count;
|
||||
bool playscript_params = false;
|
||||
|
||||
for (; a_idx < arg_count; a_idx++, ++a_pos) {
|
||||
a = args[a_idx];
|
||||
if (p_mod != Parameter.Modifier.PARAMS) {
|
||||
if ((p_mod & Parameter.Modifier.VariableArgumentsMask) == 0) {
|
||||
p_mod = pd.FixedParameters[a_idx].ModFlags;
|
||||
pt = ptypes[a_idx];
|
||||
has_unsafe_arg |= pt.IsPointer;
|
||||
|
||||
if (p_mod == Parameter.Modifier.PARAMS) {
|
||||
if (chose_params_expanded) {
|
||||
params_initializers = new ArrayInitializer (arg_count - a_idx, a.Expr.Location);
|
||||
pt = TypeManager.GetElementType (pt);
|
||||
if (chose_params_expanded && (p_mod & Parameter.Modifier.VariableArgumentsMask) != 0) {
|
||||
params_initializers = new ArrayInitializer (arg_count - a_idx, a.Expr.Location);
|
||||
if (p_mod == Parameter.Modifier.PARAMS) {
|
||||
pt = ((ArrayContainer) pt).Element;
|
||||
} else {
|
||||
playscript_params = true;
|
||||
pt = ec.Module.PlayscriptTypes.Object;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5393,8 +5437,14 @@ namespace Mono.CSharp {
|
||||
args = new Arguments (1);
|
||||
|
||||
pt = ptypes[pd.Count - 1];
|
||||
pt = TypeManager.GetElementType (pt);
|
||||
has_unsafe_arg |= pt.IsPointer;
|
||||
var array = pt as ArrayContainer;
|
||||
if (array != null) {
|
||||
pt = array.Element;
|
||||
has_unsafe_arg |= pt.IsPointer;
|
||||
} else {
|
||||
playscript_params = true;
|
||||
}
|
||||
|
||||
params_initializers = new ArrayInitializer (0, loc);
|
||||
}
|
||||
|
||||
@@ -5402,8 +5452,13 @@ namespace Mono.CSharp {
|
||||
// Append an array argument with all params arguments
|
||||
//
|
||||
if (params_initializers != null) {
|
||||
args.Add (new Argument (
|
||||
new ArrayCreation (new TypeExpression (pt, loc), params_initializers, loc).Resolve (ec)));
|
||||
Expression array_init;
|
||||
if (playscript_params)
|
||||
array_init = new PlayScript.ArrayCreation (params_initializers);
|
||||
else
|
||||
array_init = new ArrayCreation (new TypeExpression (pt, loc), params_initializers, loc);
|
||||
|
||||
args.Add (new Argument (array_init.Resolve (ec)));
|
||||
arg_count++;
|
||||
}
|
||||
|
||||
@@ -6022,7 +6077,6 @@ namespace Mono.CSharp {
|
||||
Error_TypeArgumentsCannotBeUsed (ec, "field", GetSignatureForError (), loc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Expression that evaluates to a Property.
|
||||
@@ -6030,7 +6084,7 @@ namespace Mono.CSharp {
|
||||
// This is not an LValue because we need to re-write the expression. We
|
||||
// can not take data from the stack and store it.
|
||||
//
|
||||
sealed class PropertyExpr : PropertyOrIndexerExpr<PropertySpec>
|
||||
public sealed class PropertyExpr : PropertyOrIndexerExpr<PropertySpec>
|
||||
{
|
||||
Arguments arguments;
|
||||
|
||||
@@ -6289,13 +6343,22 @@ namespace Mono.CSharp {
|
||||
return this;
|
||||
}
|
||||
|
||||
public override Constant ResolveAsPlayScriptConstant (ResolveContext rc)
|
||||
{
|
||||
var prop = best_candidate.MemberDefinition as PlayScript.IConstantProperty;
|
||||
if (prop != null)
|
||||
return prop.Initializer.ResolveAsPlayScriptConstant (rc);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public override void SetTypeArguments (ResolveContext ec, TypeArguments ta)
|
||||
{
|
||||
Error_TypeArgumentsCannotBeUsed (ec, "property", GetSignatureForError (), loc);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class PropertyOrIndexerExpr<T> : MemberExpr, IDynamicAssign where T : PropertySpec
|
||||
public abstract class PropertyOrIndexerExpr<T> : MemberExpr, IDynamicAssign where T : PropertySpec
|
||||
{
|
||||
// getter and setter can be different for base calls
|
||||
MethodSpec getter, setter;
|
||||
|
||||
+142
-37
@@ -1339,27 +1339,32 @@ namespace Mono.CSharp
|
||||
|
||||
protected override Expression DoResolve (ResolveContext ec)
|
||||
{
|
||||
probe_type_expr = ProbeType.ResolveAsType (ec);
|
||||
if (probe_type_expr == null)
|
||||
return null;
|
||||
|
||||
expr = expr.Resolve (ec);
|
||||
if (expr == null)
|
||||
return null;
|
||||
|
||||
return ResolveProbeType (ec);
|
||||
}
|
||||
|
||||
protected virtual Expression ResolveProbeType (ResolveContext rc)
|
||||
{
|
||||
probe_type_expr = ProbeType.ResolveAsType (rc);
|
||||
if (probe_type_expr == null)
|
||||
return null;
|
||||
|
||||
if (probe_type_expr.IsStatic) {
|
||||
ec.Report.Error (-244, loc, "The `{0}' operator cannot be applied to an operand of a static type",
|
||||
rc.Report.Error (-244, loc, "The `{0}' operator cannot be applied to an operand of a static type",
|
||||
OperatorName);
|
||||
}
|
||||
|
||||
|
||||
if (expr.Type.IsPointer || probe_type_expr.IsPointer) {
|
||||
ec.Report.Error (244, loc, "The `{0}' operator cannot be applied to an operand of pointer type",
|
||||
rc.Report.Error (244, loc, "The `{0}' operator cannot be applied to an operand of pointer type",
|
||||
OperatorName);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (expr.Type == InternalType.AnonymousMethod) {
|
||||
ec.Report.Error (837, loc, "The `{0}' operator cannot be applied to a lambda expression or anonymous method",
|
||||
rc.Report.Error (837, loc, "The `{0}' operator cannot be applied to a lambda expression or anonymous method",
|
||||
OperatorName);
|
||||
return null;
|
||||
}
|
||||
@@ -1447,8 +1452,9 @@ namespace Mono.CSharp
|
||||
|
||||
protected override Expression DoResolve (ResolveContext ec)
|
||||
{
|
||||
if (base.DoResolve (ec) == null)
|
||||
return null;
|
||||
var pexpr = base.DoResolve (ec);
|
||||
if (pexpr != this)
|
||||
return pexpr;
|
||||
|
||||
TypeSpec d = expr.Type;
|
||||
bool d_is_nullable = false;
|
||||
@@ -2281,20 +2287,24 @@ namespace Mono.CSharp
|
||||
|
||||
LeftShift = 5 | ShiftMask,
|
||||
RightShift = 6 | ShiftMask,
|
||||
UnsignedRightShift = 7 | ShiftMask, // PlayScript Unsigned Right Shift
|
||||
|
||||
LessThan = 7 | ComparisonMask | RelationalMask,
|
||||
GreaterThan = 8 | ComparisonMask | RelationalMask,
|
||||
LessThanOrEqual = 9 | ComparisonMask | RelationalMask,
|
||||
GreaterThanOrEqual = 10 | ComparisonMask | RelationalMask,
|
||||
Equality = 11 | ComparisonMask | EqualityMask,
|
||||
Inequality = 12 | ComparisonMask | EqualityMask,
|
||||
LessThan = 8 | ComparisonMask | RelationalMask,
|
||||
GreaterThan = 9 | ComparisonMask | RelationalMask,
|
||||
LessThanOrEqual = 10 | ComparisonMask | RelationalMask,
|
||||
GreaterThanOrEqual = 11 | ComparisonMask | RelationalMask,
|
||||
Equality = 12 | ComparisonMask | EqualityMask,
|
||||
Inequality = 13 | ComparisonMask | EqualityMask,
|
||||
StrictEquality = 14 | ComparisonMask | EqualityMask | NoUserVersion, // PlayScript Strict Equality
|
||||
StrictInequality = 15 | ComparisonMask | EqualityMask | NoUserVersion, // PlayScript Strict Inequality
|
||||
|
||||
BitwiseAnd = 13 | BitwiseMask,
|
||||
ExclusiveOr = 14 | BitwiseMask,
|
||||
BitwiseOr = 15 | BitwiseMask,
|
||||
|
||||
LogicalAnd = 16 | LogicalMask,
|
||||
LogicalOr = 17 | LogicalMask,
|
||||
BitwiseAnd = 16 | BitwiseMask,
|
||||
ExclusiveOr = 17 | BitwiseMask,
|
||||
BitwiseOr = 18 | BitwiseMask,
|
||||
|
||||
LogicalAnd = 19 | LogicalMask,
|
||||
LogicalOr = 20 | LogicalMask,
|
||||
|
||||
//
|
||||
// Operator masks
|
||||
@@ -2312,6 +2322,7 @@ namespace Mono.CSharp
|
||||
|
||||
DecomposedMask = 1 << 19,
|
||||
NullableMask = 1 << 20,
|
||||
NoUserVersion = 1 << 21
|
||||
}
|
||||
|
||||
[Flags]
|
||||
@@ -2403,6 +2414,9 @@ namespace Mono.CSharp
|
||||
case Operator.RightShift:
|
||||
s = ">>";
|
||||
break;
|
||||
case Operator.UnsignedRightShift:
|
||||
s = ">>>";
|
||||
break;
|
||||
case Operator.LessThan:
|
||||
s = "<";
|
||||
break;
|
||||
@@ -2418,9 +2432,15 @@ namespace Mono.CSharp
|
||||
case Operator.Equality:
|
||||
s = "==";
|
||||
break;
|
||||
case Operator.StrictEquality:
|
||||
s = "===";
|
||||
break;
|
||||
case Operator.Inequality:
|
||||
s = "!=";
|
||||
break;
|
||||
case Operator.StrictInequality:
|
||||
s = "!==";
|
||||
break;
|
||||
case Operator.BitwiseAnd:
|
||||
s = "&";
|
||||
break;
|
||||
@@ -2513,7 +2533,7 @@ namespace Mono.CSharp
|
||||
case Operator.Subtraction:
|
||||
return IsCompound ? "SubtractAssign" : "Subtract";
|
||||
default:
|
||||
throw new NotImplementedException ("Unknown expression type operator " + oper.ToString ());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2642,10 +2662,12 @@ namespace Mono.CSharp
|
||||
break;
|
||||
|
||||
case Operator.Equality:
|
||||
case Operator.StrictEquality:
|
||||
opcode = OpCodes.Ceq;
|
||||
break;
|
||||
|
||||
case Operator.Inequality:
|
||||
case Operator.StrictInequality:
|
||||
ec.Emit (OpCodes.Ceq);
|
||||
ec.EmitInt (0);
|
||||
|
||||
@@ -2756,9 +2778,11 @@ namespace Mono.CSharp
|
||||
return ResolveOperatorPointer (rc, l, r);
|
||||
|
||||
// User operators
|
||||
expr = ResolveUserOperator (rc, left, right);
|
||||
if (expr != null)
|
||||
return expr;
|
||||
if ((oper & Operator.NoUserVersion) == 0) {
|
||||
expr = ResolveUserOperator (rc, left, right);
|
||||
if (expr != null)
|
||||
return expr;
|
||||
}
|
||||
|
||||
|
||||
bool lenum = l.IsEnum;
|
||||
@@ -2820,7 +2844,14 @@ namespace Mono.CSharp
|
||||
// Equality operators are more complicated
|
||||
//
|
||||
if ((oper & Operator.EqualityMask) != 0) {
|
||||
return ResolveEquality (rc, l, r, primitives_only);
|
||||
expr = ResolveEquality (rc, l, r, primitives_only);
|
||||
if (primitives_only)
|
||||
return expr;
|
||||
|
||||
if (oper == Operator.StrictEquality || oper == Operator.StrictInequality)
|
||||
return PlayScript.BinaryOperators.ResolveOperator (rc, this, left, right);
|
||||
|
||||
return expr;
|
||||
}
|
||||
|
||||
expr = ResolveOperatorPredefined (rc, rc.BuiltinTypes.OperatorsBinaryStandard, primitives_only);
|
||||
@@ -3336,8 +3367,15 @@ namespace Mono.CSharp
|
||||
Expression DoResolveCore (ResolveContext ec, Expression left_orig, Expression right_orig)
|
||||
{
|
||||
Expression expr = ResolveOperator (ec);
|
||||
if (expr == null)
|
||||
if (expr == null) {
|
||||
if (ec.IsPlayScriptType) {
|
||||
expr = PlayScript.BinaryOperators.ResolveOperator (ec, this, left_orig, right_orig);
|
||||
if (expr != null)
|
||||
return expr;
|
||||
}
|
||||
|
||||
Error_OperatorCannotBeApplied (ec, left_orig, right_orig);
|
||||
}
|
||||
|
||||
if (left == null || right == null)
|
||||
throw new InternalErrorException ("Invalid conversion");
|
||||
@@ -3396,6 +3434,10 @@ namespace Mono.CSharp
|
||||
return SLE.Expression.RightShift (le, re);
|
||||
case Operator.Subtraction:
|
||||
return is_checked ? SLE.Expression.SubtractChecked (le, re) : SLE.Expression.Subtract (le, re);
|
||||
case Operator.StrictEquality:
|
||||
return PlayScript.Expressions.StrictEqual (le, re);
|
||||
case Operator.StrictInequality:
|
||||
return PlayScript.Expressions.StrictNotEqual (le, re);
|
||||
default:
|
||||
throw new NotImplementedException (oper.ToString ());
|
||||
}
|
||||
@@ -3798,7 +3840,7 @@ namespace Mono.CSharp
|
||||
if (TypeSpec.IsReferenceType (r))
|
||||
return this;
|
||||
|
||||
if (r.Kind == MemberKind.InternalCompilerType)
|
||||
if (r.Kind == MemberKind.InternalCompilerType && r.BuiltinType != BuiltinTypeSpec.Type.Object)
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -3820,7 +3862,7 @@ namespace Mono.CSharp
|
||||
if (TypeSpec.IsReferenceType (l))
|
||||
return this;
|
||||
|
||||
if (l.Kind == MemberKind.InternalCompilerType)
|
||||
if (l.Kind == MemberKind.InternalCompilerType && l.BuiltinType != BuiltinTypeSpec.Type.Object)
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -4432,6 +4474,7 @@ namespace Mono.CSharp
|
||||
|
||||
switch (oper){
|
||||
case Operator.Equality:
|
||||
case Operator.StrictEquality:
|
||||
if (on_true)
|
||||
ec.Emit (OpCodes.Beq, target);
|
||||
else
|
||||
@@ -4439,6 +4482,7 @@ namespace Mono.CSharp
|
||||
break;
|
||||
|
||||
case Operator.Inequality:
|
||||
case Operator.StrictInequality:
|
||||
if (on_true)
|
||||
ec.Emit (OpCodes.Bne_Un, target);
|
||||
else
|
||||
@@ -4605,9 +4649,6 @@ namespace Mono.CSharp
|
||||
{
|
||||
Arguments binder_args = new Arguments (4);
|
||||
|
||||
MemberAccess sle = new MemberAccess (new MemberAccess (
|
||||
new QualifiedAliasMember (QualifiedAliasMember.GlobalAlias, "System", loc), "Linq", loc), "Expressions", loc);
|
||||
|
||||
CSharpBinderFlags flags = 0;
|
||||
if (ec.HasSet (ResolveContext.Options.CheckedScope))
|
||||
flags = CSharpBinderFlags.CheckedContext;
|
||||
@@ -4616,12 +4657,30 @@ namespace Mono.CSharp
|
||||
flags |= CSharpBinderFlags.BinaryOperationLogical;
|
||||
|
||||
binder_args.Add (new Argument (new EnumConstant (new IntLiteral (ec.BuiltinTypes, (int) flags, loc), ec.Module.PredefinedTypes.BinderFlags.Resolve ())));
|
||||
binder_args.Add (new Argument (new MemberAccess (new MemberAccess (sle, "ExpressionType", loc), GetOperatorExpressionTypeName (), loc)));
|
||||
binder_args.Add (new Argument (CreateExpressionType (ec)));
|
||||
binder_args.Add (new Argument (new TypeOf (ec.CurrentType, loc)));
|
||||
binder_args.Add (new Argument (new ImplicitlyTypedArrayCreation (args.CreateDynamicBinderArguments (ec), loc)));
|
||||
|
||||
return new Invocation (new MemberAccess (new TypeExpression (ec.Module.PredefinedTypes.Binder.TypeSpec, loc), "BinaryOperation", loc), binder_args);
|
||||
}
|
||||
|
||||
Expression CreateExpressionType (ResolveContext rc)
|
||||
{
|
||||
var et = rc.Module.PredefinedTypes.ExpressionType.Resolve ();
|
||||
var tname = GetOperatorExpressionTypeName ();
|
||||
if (tname == null) {
|
||||
switch (oper) {
|
||||
case Operator.StrictEquality:
|
||||
return new EnumConstant (new IntConstant (rc.BuiltinTypes, 0x80000, loc), et);
|
||||
case Operator.StrictInequality:
|
||||
return new EnumConstant (new IntConstant (rc.BuiltinTypes, 0x80001, loc), et);
|
||||
default:
|
||||
throw new NotImplementedException ("Unknown expression type operator " + oper.ToString ());
|
||||
}
|
||||
}
|
||||
|
||||
return new MemberAccess (new TypeExpression (et, loc), GetOperatorExpressionTypeName (), loc);
|
||||
}
|
||||
|
||||
public override Expression CreateExpressionTree (ResolveContext ec)
|
||||
{
|
||||
@@ -5617,7 +5676,12 @@ namespace Mono.CSharp
|
||||
if (variable_info.IsAssigned (rc))
|
||||
return;
|
||||
|
||||
rc.Report.Error (165, loc, "Use of unassigned local variable `{0}'", Name);
|
||||
//
|
||||
// No flow-analysis for local variables in PS
|
||||
//
|
||||
if (!rc.IsPlayScriptType)
|
||||
rc.Report.Error (165, loc, "Use of unassigned local variable `{0}'", Name);
|
||||
|
||||
variable_info.SetAssigned (rc);
|
||||
}
|
||||
|
||||
@@ -5692,6 +5756,10 @@ namespace Mono.CSharp
|
||||
if (eclass == ExprClass.Unresolved)
|
||||
DoResolveBase (ec);
|
||||
|
||||
if (local_info.IsConstant) {
|
||||
ec.Report.ErrorPlayScript (1049, loc, "Illegal assignment to a variable `{0}' specified as constant", Name);
|
||||
}
|
||||
|
||||
return base.DoResolveLValue (ec, rhs);
|
||||
}
|
||||
|
||||
@@ -6561,7 +6629,7 @@ namespace Mono.CSharp
|
||||
}
|
||||
|
||||
if (type is TypeParameterSpec)
|
||||
return DoEmitTypeParameter (ec);
|
||||
return DoEmitTypeParameter (ec);
|
||||
|
||||
ec.MarkCallEntry (loc);
|
||||
ec.Emit (OpCodes.Newobj, method);
|
||||
@@ -8640,7 +8708,7 @@ namespace Mono.CSharp
|
||||
const MemberKind dot_kinds = MemberKind.Class | MemberKind.Struct | MemberKind.Delegate | MemberKind.Enum |
|
||||
MemberKind.Interface | MemberKind.TypeParameter | MemberKind.ArrayType;
|
||||
|
||||
return (type.Kind & dot_kinds) != 0 || type.BuiltinType == BuiltinTypeSpec.Type.Dynamic;
|
||||
return (type.Kind & dot_kinds) != 0 || type.BuiltinType == BuiltinTypeSpec.Type.Dynamic || type.BuiltinType == BuiltinTypeSpec.Type.Object;
|
||||
}
|
||||
|
||||
public override Expression LookupNameExpression (ResolveContext rc, MemberLookupRestrictions restrictions)
|
||||
@@ -8656,7 +8724,7 @@ namespace Mono.CSharp
|
||||
//
|
||||
using (rc.Set (ResolveContext.Options.OmitStructFlowAnalysis)) {
|
||||
if (sn != null) {
|
||||
expr = sn.LookupNameExpression (rc, MemberLookupRestrictions.ReadAccess | MemberLookupRestrictions.ExactArity);
|
||||
expr = sn.LookupNameExpression (rc, MemberLookupRestrictions.ReadAccess | MemberLookupRestrictions.ExactArity | MemberLookupRestrictions.PlayScriptConversion);
|
||||
|
||||
//
|
||||
// Resolve expression which does have type set as we need expression type
|
||||
@@ -8783,6 +8851,27 @@ namespace Mono.CSharp
|
||||
if (member_lookup != null)
|
||||
break;
|
||||
|
||||
if (expr_type.IsDynamicClass && !rc.IsRuntimeBinder) {
|
||||
me = expr as MemberExpr;
|
||||
if (me != null)
|
||||
me.ResolveInstanceExpression (rc, null);
|
||||
|
||||
//
|
||||
// Run defined assigned checks on expressions resolved with
|
||||
// disabled flow-analysis
|
||||
//
|
||||
/*
|
||||
if (sn != null) {
|
||||
var vr = expr as VariableReference;
|
||||
if (vr != null)
|
||||
vr.VerifyAssigned (rc);
|
||||
}
|
||||
*/
|
||||
Arguments args = new Arguments (1);
|
||||
args.Add (new Argument (new StringLiteral (rc.BuiltinTypes, Name, loc)));
|
||||
return new PlayScript.DynamicClassMemberAccess (expr, args, loc);
|
||||
}
|
||||
|
||||
lookup_arity = 0;
|
||||
restrictions &= ~MemberLookupRestrictions.InvocableOnly;
|
||||
errorMode = true;
|
||||
@@ -9184,6 +9273,10 @@ namespace Mono.CSharp
|
||||
return new IndexerExpr (indexers, type, this);
|
||||
}
|
||||
|
||||
if (type.IsDynamicClass) {
|
||||
return new PlayScript.DynamicClassMemberAccess (this);
|
||||
}
|
||||
|
||||
if (type != InternalType.ErrorType) {
|
||||
ec.Report.Error (21, loc, "Cannot apply indexing with [] to an expression of type `{0}'",
|
||||
type.GetSignatureForError ());
|
||||
@@ -10481,6 +10574,13 @@ namespace Mono.CSharp
|
||||
ErrorIsInaccesible (ec, member.GetSignatureForError (), loc);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (t.IsDynamicClass) {
|
||||
Arguments args = new Arguments (1);
|
||||
args.Add (new Argument (new StringLiteral (ec.BuiltinTypes, Name, loc)));
|
||||
target = new PlayScript.DynamicClassMemberAccess (ec.CurrentInitializerVariable, args, loc);
|
||||
return base.DoResolve (ec);
|
||||
}
|
||||
}
|
||||
|
||||
if (member == null) {
|
||||
@@ -10724,6 +10824,11 @@ namespace Mono.CSharp
|
||||
|
||||
if (!is_collection_initialization) {
|
||||
if (element_names.Contains (element_initializer.Name)) {
|
||||
if (ec.IsPlayScriptType) {
|
||||
initializers.RemoveAt (i--);
|
||||
continue;
|
||||
}
|
||||
|
||||
ec.Report.Error (1912, element_initializer.Location,
|
||||
"An object initializer includes more than one member `{0}' initialization",
|
||||
element_initializer.Name);
|
||||
|
||||
+49
-15
@@ -30,16 +30,22 @@ namespace Mono.CSharp
|
||||
{
|
||||
public class FieldDeclarator
|
||||
{
|
||||
public FieldDeclarator (SimpleMemberName name, Expression initializer)
|
||||
public FieldDeclarator (FieldBase field, SimpleMemberName name, Expression initializer)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Initializer = initializer;
|
||||
this.Field = field;
|
||||
this.Field.Initializer = initializer;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
public FieldBase Field { get; private set; }
|
||||
public SimpleMemberName Name { get; private set; }
|
||||
public Expression Initializer { get; private set; }
|
||||
public Expression Initializer {
|
||||
get {
|
||||
return Field.Initializer;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -74,6 +80,12 @@ namespace Mono.CSharp
|
||||
Report.Error (681, Location, "The modifier 'abstract' is not valid on fields. Try using a property instead");
|
||||
}
|
||||
|
||||
protected FieldBase (TypeDefinition parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, Modifiers defaultModifiers,
|
||||
MemberName name, Attributes attrs)
|
||||
: base (parent, type, mod, allowed_mod, defaultModifiers, name, attrs)
|
||||
{
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
public override AttributeTargets AttributeTargets {
|
||||
@@ -255,7 +267,8 @@ namespace Mono.CSharp
|
||||
Report.Error (625, Location, "`{0}': Instance field types marked with StructLayout(LayoutKind.Explicit) must have a FieldOffset attribute", GetSignatureForError ());
|
||||
}
|
||||
|
||||
ConstraintChecker.Check (this, member_type, type_expr.Location);
|
||||
if (type_expr != null)
|
||||
ConstraintChecker.Check (this, member_type, type_expr.Location);
|
||||
|
||||
base.Emit ();
|
||||
}
|
||||
@@ -285,7 +298,7 @@ namespace Mono.CSharp
|
||||
//
|
||||
public class FieldSpec : MemberSpec, IInterfaceMemberSpec
|
||||
{
|
||||
FieldInfo metaInfo;
|
||||
protected FieldInfo metaInfo;
|
||||
TypeSpec memberType;
|
||||
|
||||
public FieldSpec (TypeSpec declaringType, IMemberDefinition definition, TypeSpec memberType, FieldInfo info, Modifiers modifiers)
|
||||
@@ -333,6 +346,14 @@ namespace Mono.CSharp
|
||||
return metaInfo;
|
||||
}
|
||||
|
||||
public void SetMetaInfo (FieldInfo info)
|
||||
{
|
||||
if (this.metaInfo != null)
|
||||
throw new InternalErrorException ("MetaInfo reset");
|
||||
|
||||
this.metaInfo = info;
|
||||
}
|
||||
|
||||
public override MemberSpec InflateMember (TypeParameterInflator inflator)
|
||||
{
|
||||
var fs = (FieldSpec) base.InflateMember (inflator);
|
||||
@@ -414,9 +435,10 @@ namespace Mono.CSharp
|
||||
GetSignatureForError ());
|
||||
} else if (declarators != null) {
|
||||
foreach (var d in declarators) {
|
||||
var f = new FixedField (Parent, d.GetFieldTypeExpression (this), ModFlags, new MemberName (d.Name.Value, d.Name.Location), OptAttributes);
|
||||
f.initializer = d.Initializer;
|
||||
((ConstInitializer) f.initializer).Name = d.Name.Value;
|
||||
var f = d.Field;
|
||||
f.MemberType = member_type;
|
||||
|
||||
((ConstInitializer) f.Initializer).Name = d.Name.Value;
|
||||
f.Define ();
|
||||
Parent.PartialContainer.Members.Add (f);
|
||||
}
|
||||
@@ -583,6 +605,12 @@ namespace Mono.CSharp
|
||||
{
|
||||
}
|
||||
|
||||
protected Field (TypeDefinition parent, FullNamedExpression type, Modifiers mod, Modifiers amod, Modifiers defaultModifiers,
|
||||
MemberName name, Attributes attrs)
|
||||
: base (parent, type, mod, amod, defaultModifiers, name, attrs)
|
||||
{
|
||||
}
|
||||
|
||||
bool CanBeVolatile ()
|
||||
{
|
||||
switch (MemberType.BuiltinType) {
|
||||
@@ -626,8 +654,9 @@ namespace Mono.CSharp
|
||||
required_modifier = new MetaType[] { mod.GetMetaInfo () };
|
||||
}
|
||||
|
||||
var full_name = GetFullName (MemberName);
|
||||
FieldBuilder = Parent.TypeBuilder.DefineField (
|
||||
Name, member_type.GetMetaInfo (), required_modifier, null, ModifiersExtensions.FieldAttr (ModFlags));
|
||||
full_name, member_type.GetMetaInfo (), required_modifier, null, ModifiersExtensions.FieldAttr (ModFlags));
|
||||
|
||||
spec = new FieldSpec (Parent.Definition, this, MemberType, FieldBuilder, ModFlags);
|
||||
|
||||
@@ -636,18 +665,23 @@ namespace Mono.CSharp
|
||||
// need them for definitive assignment checks
|
||||
//
|
||||
if ((ModFlags & Modifiers.BACKING_FIELD) == 0 || Parent.Kind == MemberKind.Struct) {
|
||||
Parent.MemberCache.AddMember (spec);
|
||||
Parent.MemberCache.AddMember (spec, full_name);
|
||||
}
|
||||
|
||||
if (initializer != null) {
|
||||
Parent.RegisterFieldForInitialization (this, new FieldInitializer (this, initializer, TypeExpression.Location));
|
||||
if (initializer == null && Parent.IsPlayScriptType && MemberType == Module.PlayscriptTypes.Number) {
|
||||
var fi = new FieldInitializer (this, new DoubleConstant (Compiler.BuiltinTypes, double.NaN, Location.Null), Location.Null);
|
||||
if (IsStatic) {
|
||||
Parent.PartialContainer.RegisterInitialization (new StatementExpression (fi), true);
|
||||
} else {
|
||||
Parent.PartialContainer.RegisterFieldForInitialization (this, fi, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (declarators != null) {
|
||||
foreach (var d in declarators) {
|
||||
var f = new Field (Parent, d.GetFieldTypeExpression (this), ModFlags, new MemberName (d.Name.Value, d.Name.Location), OptAttributes);
|
||||
if (d.Initializer != null)
|
||||
f.initializer = d.Initializer;
|
||||
var f = d.Field;
|
||||
if (f.TypeExpression == null)
|
||||
f.MemberType = member_type;
|
||||
|
||||
f.Define ();
|
||||
Parent.PartialContainer.Members.Add (f);
|
||||
|
||||
@@ -474,6 +474,12 @@ namespace Mono.CSharp {
|
||||
}
|
||||
}
|
||||
|
||||
bool ITypeDefinition.IsPlayScriptType {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsMethodTypeParameter {
|
||||
get {
|
||||
return spec.IsMethodOwned;
|
||||
|
||||
+3
-1
@@ -381,7 +381,7 @@ namespace Mono.CSharp
|
||||
// For now the "default config" is harcoded into the compiler
|
||||
// we can move this outside later
|
||||
//
|
||||
var default_references = new List<string> (4);
|
||||
var default_references = new List<string> (8);
|
||||
|
||||
default_references.Add ("System.dll");
|
||||
default_references.Add ("System.Xml.dll");
|
||||
@@ -389,6 +389,8 @@ namespace Mono.CSharp
|
||||
|
||||
if (corlib != null && corlib.GetName ().Version.Major >= 4) {
|
||||
default_references.Add ("Microsoft.CSharp.dll");
|
||||
|
||||
default_references.Add ("PlayScript.Core");
|
||||
}
|
||||
|
||||
return default_references.ToArray ();
|
||||
|
||||
+72
-10
@@ -6,7 +6,7 @@
|
||||
// Dual licensed under the terms of the MIT X11 or GNU GPL
|
||||
//
|
||||
// Copyright 2009-2011 Novell, Inc
|
||||
// Copyright 2011-2012 Xamarin, Inc (http://www.xamarin.com)
|
||||
// Copyright 2011-2013 Xamarin, Inc (http://www.xamarin.com)
|
||||
//
|
||||
|
||||
using System;
|
||||
@@ -123,6 +123,7 @@ namespace Mono.CSharp
|
||||
protected readonly ModuleContainer module;
|
||||
|
||||
public static readonly string CompilerServicesNamespace = "System.Runtime.CompilerServices";
|
||||
public static readonly string PlayScriptCompilerNamespace = "PlayScript.Runtime.CompilerServices";
|
||||
|
||||
protected MetadataImporter (ModuleContainer module)
|
||||
{
|
||||
@@ -204,6 +205,16 @@ namespace Mono.CSharp
|
||||
return new ConstSpec (declaringType, definition, field_type, fi, mod, dc);
|
||||
}
|
||||
|
||||
if (field_type == module.PlayscriptTypes.Namespace.TypeSpec) {
|
||||
var attributes = CustomAttributeData.GetCustomAttributes (fi);
|
||||
|
||||
var data = FindAttribute (attributes, "NamespaceFieldAttribute", PlayScriptCompilerNamespace);
|
||||
if (data != null) {
|
||||
string value = data.ConstructorArguments[0].Value as string;
|
||||
return new PlayScript.NamespaceFieldSpec (declaringType, definition, field_type, fi, mod, value);
|
||||
}
|
||||
}
|
||||
|
||||
mod |= Modifiers.READONLY;
|
||||
} else {
|
||||
var req_mod = fi.GetRequiredCustomModifiers ();
|
||||
@@ -497,10 +508,15 @@ namespace Mono.CSharp
|
||||
} else {
|
||||
types[i] = ImportType (p.ParameterType, new DynamicTypeReader (p));
|
||||
|
||||
if (i >= pi.Length - 2 && types[i] is ArrayContainer) {
|
||||
if (HasAttribute (CustomAttributeData.GetCustomAttributes (p), "ParamArrayAttribute", "System")) {
|
||||
if (i >= pi.Length - 2) {
|
||||
var ti = types[i];
|
||||
|
||||
if (ti is ArrayContainer && HasAttribute (CustomAttributeData.GetCustomAttributes (p), "ParamArrayAttribute", "System")) {
|
||||
mod = Parameter.Modifier.PARAMS;
|
||||
is_params = true;
|
||||
} else if (ti == module.PlayscriptTypes.Array.TypeSpec && HasAttribute (CustomAttributeData.GetCustomAttributes (p), "RestArrayParameterAttribute", PlayScriptCompilerNamespace)) {
|
||||
mod = Parameter.Modifier.RestArray;
|
||||
is_params = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -633,7 +649,24 @@ namespace Mono.CSharp
|
||||
}
|
||||
|
||||
PropertySpec spec = null;
|
||||
if (!param.IsEmpty) {
|
||||
ImportedMemberDefinition imd = new ImportedMemberDefinition (pi, type, this);
|
||||
|
||||
if (param.IsEmpty) {
|
||||
if (get != null && set == null && declaringType.MemberDefinition.IsPlayScriptType) {
|
||||
var attributes = CustomAttributeData.GetCustomAttributes (pi);
|
||||
|
||||
var data = FindAttribute (attributes, "ConstantFieldAttribute", PlayScriptCompilerNamespace);
|
||||
if (data != null) {
|
||||
var pc = new PlayScript.ImportedPropertyConstant (pi, type, this);
|
||||
if (data.ConstructorArguments.Count == 1) {
|
||||
pc.Initializer = Constant.CreateConstantFromValue (type,
|
||||
data.ConstructorArguments[0].Value, Location.Null);
|
||||
}
|
||||
|
||||
imd = pc;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (is_valid_property) {
|
||||
var index_name = declaringType.MemberDefinition.GetAttributeDefaultMember ();
|
||||
if (index_name == null) {
|
||||
@@ -672,7 +705,7 @@ namespace Mono.CSharp
|
||||
}
|
||||
|
||||
if (spec == null)
|
||||
spec = new PropertySpec (MemberKind.Property, declaringType, new ImportedMemberDefinition (pi, type, this), type, pi, mod);
|
||||
spec = new PropertySpec (MemberKind.Property, declaringType, imd, type, pi, mod);
|
||||
|
||||
if (!is_valid_property) {
|
||||
spec.IsNotCSharpCompatible = true;
|
||||
@@ -898,8 +931,21 @@ namespace Mono.CSharp
|
||||
bts.SetDefinition (definition, type, mod);
|
||||
}
|
||||
|
||||
if (spec == null)
|
||||
if (spec == null) {
|
||||
if (kind == MemberKind.Class && declaringType == null) {
|
||||
var attributes = CustomAttributeData.GetCustomAttributes (type);
|
||||
// TODO: Add assembly level attribute to speed this up?
|
||||
|
||||
if (HasAttribute (attributes, "DynamicClassAttribute", PlayScriptCompilerNamespace)) {
|
||||
definition.IsPlayScriptType = true;
|
||||
mod |= Modifiers.DYNAMIC;
|
||||
} else if (HasAttribute (attributes, "PlayScriptAttribute", PlayScriptCompilerNamespace)) {
|
||||
definition.IsPlayScriptType = true;
|
||||
}
|
||||
}
|
||||
|
||||
spec = new TypeSpec (kind, declaringType, definition, type, mod);
|
||||
}
|
||||
|
||||
import_cache.Add (type, spec);
|
||||
|
||||
@@ -988,17 +1034,22 @@ namespace Mono.CSharp
|
||||
// they can be assembly specific therefore we do check based on names only
|
||||
//
|
||||
public static bool HasAttribute (IList<CustomAttributeData> attributesData, string attrName, string attrNamespace)
|
||||
{
|
||||
return FindAttribute (attributesData, attrName, attrNamespace) != null;
|
||||
}
|
||||
|
||||
static CustomAttributeData FindAttribute (IList<CustomAttributeData> attributesData, string attrName, string attrNamespace)
|
||||
{
|
||||
if (attributesData.Count == 0)
|
||||
return false;
|
||||
return null;
|
||||
|
||||
foreach (var attr in attributesData) {
|
||||
var dt = attr.Constructor.DeclaringType;
|
||||
if (dt.Name == attrName && dt.Namespace == attrNamespace)
|
||||
return true;
|
||||
return attr;
|
||||
}
|
||||
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
void ImportTypeBase (TypeSpec spec, MetaType type)
|
||||
@@ -1012,6 +1063,9 @@ namespace Mono.CSharp
|
||||
else
|
||||
base_type = CreateType (type.BaseType);
|
||||
|
||||
if (base_type == null && spec.MemberDefinition.IsPlayScriptType)
|
||||
base_type = module.PlayscriptTypes.Object;
|
||||
|
||||
spec.BaseType = base_type;
|
||||
}
|
||||
|
||||
@@ -1034,7 +1088,7 @@ namespace Mono.CSharp
|
||||
if (t.MemberType == MemberTypes.NestedType)
|
||||
continue;
|
||||
|
||||
if (t.Name[0] == '<')
|
||||
if (t.Name[0] == '<' && (t.Attributes & TypeAttributes.Public) == 0)
|
||||
continue;
|
||||
|
||||
var it = CreateType (t, null, new DynamicTypeReader (t), true);
|
||||
@@ -1797,6 +1851,8 @@ namespace Mono.CSharp
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsPlayScriptType { get; set; }
|
||||
|
||||
public override string Name {
|
||||
get {
|
||||
if (name == null) {
|
||||
@@ -2230,6 +2286,12 @@ namespace Mono.CSharp
|
||||
}
|
||||
}
|
||||
|
||||
bool ITypeDefinition.IsPlayScriptType {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public string Namespace {
|
||||
get {
|
||||
return null;
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ namespace Mono.CSharp {
|
||||
return Parameters;
|
||||
}
|
||||
|
||||
protected override AnonymousMethodBody CompatibleMethodFactory (TypeSpec returnType, TypeSpec delegateType, ParametersCompiled p, ParametersBlock b)
|
||||
protected override AnonymousMethodBody CompatibleMethodFactory (ResolveContext rc, TypeSpec returnType, TypeSpec delegateType, ParametersCompiled p, ParametersBlock b)
|
||||
{
|
||||
return new LambdaMethod (p, b, returnType, delegateType, loc);
|
||||
}
|
||||
|
||||
@@ -329,5 +329,13 @@ namespace Mono.CSharp
|
||||
{
|
||||
return visitor.Visit (this);
|
||||
}
|
||||
|
||||
public override Constant ConvertImplicitly (TypeSpec type)
|
||||
{
|
||||
if (this.type.BuiltinType == type.BuiltinType)
|
||||
return this;
|
||||
|
||||
return base.ConvertImplicitly (type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,12 @@ using System.Linq;
|
||||
|
||||
namespace Mono.CSharp
|
||||
{
|
||||
public enum SourceFileType
|
||||
{
|
||||
CSharp = 0,
|
||||
PlayScript
|
||||
}
|
||||
|
||||
//
|
||||
// This is one single source file.
|
||||
//
|
||||
@@ -58,6 +64,7 @@ namespace Mono.CSharp
|
||||
public readonly string FullPathName;
|
||||
public readonly int Index;
|
||||
public bool AutoGenerated;
|
||||
readonly SourceFileType FileType;
|
||||
|
||||
SourceFileEntry file;
|
||||
byte[] algGuid, checksum;
|
||||
@@ -68,6 +75,9 @@ namespace Mono.CSharp
|
||||
this.Index = index;
|
||||
this.Name = name;
|
||||
this.FullPathName = path;
|
||||
|
||||
if (name.EndsWith (".play", StringComparison.Ordinal) || name.EndsWith (".as", StringComparison.Ordinal))
|
||||
FileType = SourceFileType.PlayScript;
|
||||
}
|
||||
|
||||
public byte[] Checksum {
|
||||
@@ -82,6 +92,12 @@ namespace Mono.CSharp
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsPlayScript {
|
||||
get {
|
||||
return FileType == SourceFileType.PlayScript;
|
||||
}
|
||||
}
|
||||
|
||||
public SourceFileEntry SourceFileEntry {
|
||||
get {
|
||||
return file;
|
||||
|
||||
@@ -139,7 +139,10 @@
|
||||
</Compile>
|
||||
<Compile Include="parameter.cs" />
|
||||
<Compile Include="pending.cs" />
|
||||
<Compile Include="playscript.cs" />
|
||||
<Compile Include="property.cs" />
|
||||
<Compile Include="ps-parser.cs" />
|
||||
<Compile Include="ps-tokenizer.cs" />
|
||||
<Compile Include="reflection.cs" />
|
||||
<Compile Include="report.cs" />
|
||||
<Compile Include="settings.cs">
|
||||
|
||||
@@ -6,6 +6,7 @@ assembly.cs
|
||||
async.cs
|
||||
attribute.cs
|
||||
cs-tokenizer.cs
|
||||
ps-tokenizer.cs
|
||||
cfold.cs
|
||||
class.cs
|
||||
codegen.cs
|
||||
@@ -40,6 +41,7 @@ namespace.cs
|
||||
nullable.cs
|
||||
parameter.cs
|
||||
pending.cs
|
||||
playscript.cs
|
||||
property.cs
|
||||
reflection.cs
|
||||
report.cs
|
||||
|
||||
+16
-4
@@ -187,9 +187,16 @@ namespace Mono.CSharp {
|
||||
member_hash = new Dictionary<string, IList<MemberSpec>> (capacity);
|
||||
}
|
||||
|
||||
public MemberCache (MemberCache cache)
|
||||
: this (cache.member_hash.Count)
|
||||
public MemberCache (MemberCache cache, bool copyMembers = false)
|
||||
{
|
||||
var mh = cache.member_hash;
|
||||
|
||||
if (copyMembers) {
|
||||
member_hash = new Dictionary<string, IList<MemberSpec>> (mh);
|
||||
} else {
|
||||
member_hash = new Dictionary<string, IList<MemberSpec>> (mh.Count);
|
||||
}
|
||||
|
||||
this.state = cache.state;
|
||||
}
|
||||
|
||||
@@ -280,7 +287,7 @@ namespace Mono.CSharp {
|
||||
{
|
||||
// Explicit names cannot be looked-up but can be used for
|
||||
// collision checking (no name mangling needed)
|
||||
if (imb.IsExplicitImpl)
|
||||
if (imb.IsExplicitImpl || imb.MemberName.Left != null)
|
||||
AddMember (exlicitName, ms, false);
|
||||
else
|
||||
AddMember (ms);
|
||||
@@ -294,6 +301,11 @@ namespace Mono.CSharp {
|
||||
AddMember (GetLookupName (ms), ms, false);
|
||||
}
|
||||
|
||||
public void AddMember (MemberSpec member, string name)
|
||||
{
|
||||
AddMember (name, member, false);
|
||||
}
|
||||
|
||||
void AddMember (string name, MemberSpec member, bool removeHiddenMembers)
|
||||
{
|
||||
if (member.Kind == MemberKind.Operator) {
|
||||
@@ -901,7 +913,7 @@ namespace Mono.CSharp {
|
||||
if (mc is Constructor)
|
||||
return mc.IsStatic ? Constructor.TypeConstructorName : Constructor.ConstructorName;
|
||||
|
||||
return mc.MemberName.Name;
|
||||
return mc.MemberName.LookupName;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
+23
-10
@@ -47,9 +47,9 @@ namespace Mono.CSharp {
|
||||
protected ToplevelBlock block;
|
||||
protected MethodSpec spec;
|
||||
|
||||
public MethodCore (TypeDefinition parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod,
|
||||
public MethodCore (TypeDefinition parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, Modifiers defaultModifiers,
|
||||
MemberName name, Attributes attrs, ParametersCompiled parameters)
|
||||
: base (parent, type, mod, allowed_mod, name, attrs)
|
||||
: base (parent, type, mod, allowed_mod, defaultModifiers, name, attrs)
|
||||
{
|
||||
this.parameters = parameters;
|
||||
}
|
||||
@@ -535,7 +535,13 @@ namespace Mono.CSharp {
|
||||
|
||||
protected MethodOrOperator (TypeDefinition parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, MemberName name,
|
||||
Attributes attrs, ParametersCompiled parameters)
|
||||
: base (parent, type, mod, allowed_mod, name, attrs, parameters)
|
||||
: base (parent, type, mod, allowed_mod, Modifiers.PRIVATE, name, attrs, parameters)
|
||||
{
|
||||
}
|
||||
|
||||
protected MethodOrOperator (TypeDefinition parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, Modifiers defaultModifiers, MemberName name,
|
||||
Attributes attrs, ParametersCompiled parameters)
|
||||
: base (parent, type, mod, allowed_mod, defaultModifiers, name, attrs, parameters)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -848,9 +854,9 @@ namespace Mono.CSharp {
|
||||
{
|
||||
}
|
||||
|
||||
protected Method (TypeDefinition parent, FullNamedExpression return_type, Modifiers mod, Modifiers amod,
|
||||
protected Method (TypeDefinition parent, FullNamedExpression return_type, Modifiers mod, Modifiers amod, Modifiers defaultModifiers,
|
||||
MemberName name, ParametersCompiled parameters, Attributes attrs)
|
||||
: base (parent, return_type, mod, amod, name, attrs, parameters)
|
||||
: base (parent, return_type, mod, amod, defaultModifiers, name, attrs, parameters)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1522,7 +1528,7 @@ namespace Mono.CSharp {
|
||||
public class Constructor : MethodCore, IMethodData, IMethodDefinition
|
||||
{
|
||||
public ConstructorBuilder ConstructorBuilder;
|
||||
public ConstructorInitializer Initializer;
|
||||
public ExpressionStatement Initializer;
|
||||
SecurityType declarative_security;
|
||||
bool has_compliant_args;
|
||||
SourceMethodBuilder debug_builder;
|
||||
@@ -1545,7 +1551,12 @@ namespace Mono.CSharp {
|
||||
public static readonly string TypeConstructorName = ".cctor";
|
||||
|
||||
public Constructor (TypeDefinition parent, string name, Modifiers mod, Attributes attrs, ParametersCompiled args, Location loc)
|
||||
: base (parent, null, mod, AllowedModifiers, new MemberName (name, loc), attrs, args)
|
||||
: this (parent, name, mod, Modifiers.PRIVATE, attrs, args, loc)
|
||||
{
|
||||
}
|
||||
|
||||
public Constructor (TypeDefinition parent, string name, Modifiers mod, Modifiers defaultModifiers, Attributes attrs, ParametersCompiled args, Location loc)
|
||||
: base (parent, null, mod, AllowedModifiers, defaultModifiers, new MemberName (name, loc), attrs, args)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1582,9 +1593,11 @@ namespace Mono.CSharp {
|
||||
if ((ModFlags & Modifiers.STATIC) != 0)
|
||||
return parameters.IsEmpty;
|
||||
|
||||
return parameters.IsEmpty &&
|
||||
(Initializer is ConstructorBaseInitializer) &&
|
||||
(Initializer.Arguments == null);
|
||||
if (!parameters.IsEmpty)
|
||||
return false;
|
||||
|
||||
var init = Initializer as ConstructorBaseInitializer;
|
||||
return init != null && init.Arguments == null;
|
||||
}
|
||||
|
||||
public override void Accept (StructuralVisitor visitor)
|
||||
|
||||
@@ -38,7 +38,8 @@ namespace Mono.CSharp
|
||||
VOLATILE = 0x1000,
|
||||
UNSAFE = 0x2000,
|
||||
ASYNC = 0x4000,
|
||||
TOP = 0x8000,
|
||||
DYNAMIC = 0x8000, // Playscript only
|
||||
TOP = 0x10000,
|
||||
|
||||
//
|
||||
// Compiler specific flags
|
||||
@@ -111,6 +112,8 @@ namespace Mono.CSharp
|
||||
s = "unsafe"; break;
|
||||
case Modifiers.ASYNC:
|
||||
s = "async"; break;
|
||||
case Modifiers.DYNAMIC:
|
||||
s = "dynamic"; break;
|
||||
}
|
||||
|
||||
return s;
|
||||
|
||||
@@ -121,12 +121,16 @@ namespace Mono.CSharp
|
||||
readonly Dictionary<string, RootNamespace> alias_ns;
|
||||
|
||||
ModuleBuilder builder;
|
||||
ConstructorBuilder initializer;
|
||||
|
||||
bool has_extenstion_method;
|
||||
|
||||
PredefinedAttributes predefined_attributes;
|
||||
PredefinedTypes predefined_types;
|
||||
PredefinedMembers predefined_members;
|
||||
PlayScript.PredefinedAttributes playscript_attributes;
|
||||
PlayScript.PredefinedTypes playscript_types;
|
||||
PlayScript.PredefinedMembers playscript_members;
|
||||
|
||||
public Binary.PredefinedOperator[] OperatorsBinaryEqualityLifted;
|
||||
public Binary.PredefinedOperator[] OperatorsBinaryLifted;
|
||||
@@ -269,6 +273,24 @@ namespace Mono.CSharp
|
||||
}
|
||||
}
|
||||
|
||||
internal PlayScript.PredefinedAttributes PlayscriptAttributes {
|
||||
get {
|
||||
return playscript_attributes;
|
||||
}
|
||||
}
|
||||
|
||||
internal PlayScript.PredefinedTypes PlayscriptTypes {
|
||||
get {
|
||||
return playscript_types;
|
||||
}
|
||||
}
|
||||
|
||||
internal PlayScript.PredefinedMembers PlayScriptMembers {
|
||||
get {
|
||||
return playscript_members;
|
||||
}
|
||||
}
|
||||
|
||||
internal Dictionary<TypeSpec, ReferenceContainer> ReferenceTypesCache {
|
||||
get {
|
||||
return reference_types;
|
||||
@@ -412,6 +434,18 @@ namespace Mono.CSharp
|
||||
return true;
|
||||
}
|
||||
|
||||
public ConstructorBuilder DefineModuleInitializer ()
|
||||
{
|
||||
#if STATIC
|
||||
if (initializer == null)
|
||||
initializer = builder.__DefineModuleInitializer (MethodAttributes.Assembly);
|
||||
|
||||
return initializer;
|
||||
#else
|
||||
throw new NotImplementedException ();
|
||||
#endif
|
||||
}
|
||||
|
||||
public override bool DefineContainer ()
|
||||
{
|
||||
DefineNamespace ();
|
||||
@@ -449,6 +483,9 @@ namespace Mono.CSharp
|
||||
foreach (var at in atypes.Value)
|
||||
at.EmitContainer ();
|
||||
}
|
||||
|
||||
if (initializer != null)
|
||||
builder.CreateGlobalFunctions ();
|
||||
}
|
||||
|
||||
internal override void GenerateDocComment (DocumentationBuilder builder)
|
||||
@@ -563,6 +600,11 @@ namespace Mono.CSharp
|
||||
|
||||
OperatorsBinaryEqualityLifted = Binary.CreateEqualityLiftedOperatorsTable (this);
|
||||
OperatorsBinaryLifted = Binary.CreateStandardLiftedOperatorsTable (this);
|
||||
|
||||
playscript_attributes = new PlayScript.PredefinedAttributes (this);
|
||||
playscript_types = new PlayScript.PredefinedTypes (this);
|
||||
playscript_types.PopulateImplicitMembers (this);
|
||||
playscript_members = new PlayScript.PredefinedMembers (this);
|
||||
}
|
||||
|
||||
public override bool IsClsComplianceRequired ()
|
||||
|
||||
+26
-1
@@ -427,6 +427,24 @@ namespace Mono.CSharp {
|
||||
return texpr;
|
||||
}
|
||||
|
||||
// TODO: REMOVE me
|
||||
public ATypeNameExpression MakeTypeNameExpression (Location loc)
|
||||
{
|
||||
string[] names = Name.Split (new[] { '.' });
|
||||
|
||||
ATypeNameExpression exp = null;
|
||||
for (var i = 0; i < names.Length; i++) {
|
||||
var name = names[i];
|
||||
if (exp == null) {
|
||||
exp = new SimpleName (name, loc);
|
||||
} else {
|
||||
exp = new MemberAccess (exp, name, loc);
|
||||
}
|
||||
}
|
||||
|
||||
return exp;
|
||||
}
|
||||
|
||||
//
|
||||
// Completes types with the given `prefix'
|
||||
//
|
||||
@@ -821,6 +839,9 @@ namespace Mono.CSharp {
|
||||
get {
|
||||
return clauses;
|
||||
}
|
||||
protected set {
|
||||
clauses = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override string[] ValidAttributeTargets {
|
||||
@@ -831,7 +852,7 @@ namespace Mono.CSharp {
|
||||
|
||||
#endregion
|
||||
|
||||
public void AddUsing (UsingNamespace un)
|
||||
public void AddUsing (UsingNamespace un, bool forceAppend = false) // TODO: remove the change
|
||||
{
|
||||
if (DeclarationFound){
|
||||
Compiler.Report.Error (1529, un.Location, "A using clause must precede all other namespace elements except extern alias declarations");
|
||||
@@ -880,6 +901,10 @@ namespace Mono.CSharp {
|
||||
public override void AddTypeContainer (TypeContainer tc)
|
||||
{
|
||||
string name = tc.Basename;
|
||||
if (name == null) {
|
||||
containers.Add (tc);
|
||||
return;
|
||||
}
|
||||
|
||||
var mn = tc.MemberName;
|
||||
while (mn.Left != null) {
|
||||
|
||||
+35
-14
@@ -216,10 +216,12 @@ namespace Mono.CSharp {
|
||||
CallerMemberName = 1 << 4,
|
||||
CallerLineNumber = 1 << 5,
|
||||
CallerFilePath = 1 << 6,
|
||||
RestArray = 1 << 7,
|
||||
|
||||
RefOutMask = REF | OUT,
|
||||
ModifierMask = PARAMS | REF | OUT | This,
|
||||
CallerMask = CallerMemberName | CallerLineNumber | CallerFilePath
|
||||
ModifierMask = PARAMS | REF | OUT | This | RestArray,
|
||||
CallerMask = CallerMemberName | CallerLineNumber | CallerFilePath,
|
||||
VariableArgumentsMask = PARAMS | RestArray
|
||||
}
|
||||
|
||||
static readonly string[] attribute_targets = new string[] { "param" };
|
||||
@@ -303,6 +305,9 @@ namespace Mono.CSharp {
|
||||
get {
|
||||
return texpr;
|
||||
}
|
||||
protected set {
|
||||
texpr = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override string[] ValidAttributeTargets {
|
||||
@@ -604,6 +609,8 @@ namespace Mono.CSharp {
|
||||
return "ref";
|
||||
case Modifier.This:
|
||||
return "this";
|
||||
case Modifier.RestArray:
|
||||
return "...";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
@@ -1066,7 +1073,7 @@ namespace Mono.CSharp {
|
||||
int count = parameters.Length;
|
||||
|
||||
for (int i = 0; i < count; i++){
|
||||
has_params |= (parameters [i].ModFlags & Parameter.Modifier.PARAMS) != 0;
|
||||
has_params |= (parameters [i].ModFlags & Parameter.Modifier.VariableArgumentsMask) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1328,35 +1335,49 @@ namespace Mono.CSharp {
|
||||
//
|
||||
public class DefaultParameterValueExpression : CompositeExpression
|
||||
{
|
||||
bool resolved;
|
||||
|
||||
public DefaultParameterValueExpression (Expression expr)
|
||||
: base (expr)
|
||||
{
|
||||
}
|
||||
|
||||
protected override Expression DoResolve (ResolveContext rc)
|
||||
{
|
||||
return base.DoResolve (rc);
|
||||
}
|
||||
|
||||
public void Resolve (ResolveContext rc, Parameter p)
|
||||
{
|
||||
if (resolved)
|
||||
return;
|
||||
|
||||
resolved = true;
|
||||
|
||||
var expr = Resolve (rc);
|
||||
if (expr == null)
|
||||
return;
|
||||
|
||||
expr = Child;
|
||||
|
||||
if (!(expr is Constant || expr is DefaultValueExpression || (expr is New && ((New) expr).IsDefaultStruct))) {
|
||||
rc.Report.Error (1736, Location,
|
||||
"The expression being assigned to optional parameter `{0}' must be a constant or default value",
|
||||
p.Name);
|
||||
if (!(expr is Constant || (expr is New && ((New) expr).IsDefaultStruct))) {
|
||||
if (rc.IsPlayScriptType) {
|
||||
expr = expr.ResolveAsPlayScriptConstant (rc);
|
||||
if (expr == null) {
|
||||
rc.Report.ErrorPlayScript (1047, Location,
|
||||
"Parameter initializer is not a compile-time constant.");
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
} else if (!(expr is DefaultValueExpression)) {
|
||||
rc.Report.Error (1736, Location,
|
||||
"The expression being assigned to optional parameter `{0}' must be a constant or default value",
|
||||
p.Name);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var parameter_type = p.Type;
|
||||
if (type == parameter_type)
|
||||
if (type == parameter_type) {
|
||||
this.expr = expr;
|
||||
return;
|
||||
}
|
||||
|
||||
var res = Convert.ImplicitConversionStandard (rc, expr, parameter_type, Location);
|
||||
if (res != null) {
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
+30
-10
@@ -36,7 +36,7 @@ namespace Mono.CSharp
|
||||
public abstract class PropertyBasedMember : InterfaceMemberBase
|
||||
{
|
||||
protected PropertyBasedMember (TypeDefinition parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, MemberName name, Attributes attrs)
|
||||
: base (parent, type, mod, allowed_mod, name, attrs)
|
||||
: base (parent, type, mod, allowed_mod, Modifiers.PRIVATE, name, attrs)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -406,7 +406,7 @@ namespace Mono.CSharp
|
||||
}
|
||||
|
||||
PropertyMethod get, set, first;
|
||||
PropertyBuilder PropertyBuilder;
|
||||
protected PropertyBuilder PropertyBuilder;
|
||||
|
||||
public PropertyBase (TypeDefinition parent, FullNamedExpression type, Modifiers mod_flags, Modifiers allowed_mod, MemberName name, Attributes attrs)
|
||||
: base (parent, type, mod_flags, allowed_mod, name, attrs)
|
||||
@@ -915,6 +915,28 @@ namespace Mono.CSharp
|
||||
}
|
||||
}
|
||||
|
||||
public class EventDeclarator
|
||||
{
|
||||
public EventDeclarator (EventField field, SimpleMemberName name, Expression initializer)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Field = field;
|
||||
this.Field.Initializer = Initializer;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
public EventField Field { get; private set; }
|
||||
public SimpleMemberName Name { get; private set; }
|
||||
public Expression Initializer {
|
||||
get {
|
||||
return Field.Initializer;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event is declared like field.
|
||||
/// </summary>
|
||||
@@ -1027,7 +1049,7 @@ namespace Mono.CSharp
|
||||
|
||||
Expression initializer;
|
||||
Field backing_field;
|
||||
List<FieldDeclarator> declarators;
|
||||
List<EventDeclarator> declarators;
|
||||
|
||||
public EventField (TypeDefinition parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs)
|
||||
: base (parent, type, mod_flags, name, attrs)
|
||||
@@ -1038,7 +1060,7 @@ namespace Mono.CSharp
|
||||
|
||||
#region Properties
|
||||
|
||||
public List<FieldDeclarator> Declarators {
|
||||
public List<EventDeclarator> Declarators {
|
||||
get {
|
||||
return this.declarators;
|
||||
}
|
||||
@@ -1073,10 +1095,10 @@ namespace Mono.CSharp
|
||||
visitor.Visit (this);
|
||||
}
|
||||
|
||||
public void AddDeclarator (FieldDeclarator declarator)
|
||||
public void AddDeclarator (EventDeclarator declarator)
|
||||
{
|
||||
if (declarators == null)
|
||||
declarators = new List<FieldDeclarator> (2);
|
||||
declarators = new List<EventDeclarator> (2);
|
||||
|
||||
declarators.Add (declarator);
|
||||
|
||||
@@ -1114,10 +1136,8 @@ namespace Mono.CSharp
|
||||
|
||||
var t = new TypeExpression (MemberType, TypeExpression.Location);
|
||||
foreach (var d in declarators) {
|
||||
var ef = new EventField (Parent, t, mod_flags_src, new MemberName (d.Name.Value, d.Name.Location), OptAttributes);
|
||||
|
||||
if (d.Initializer != null)
|
||||
ef.initializer = d.Initializer;
|
||||
var ef = d.Field;
|
||||
ef.member_type = member_type;
|
||||
|
||||
ef.Define ();
|
||||
Parent.PartialContainer.Members.Add (ef);
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
+50
-2
@@ -231,6 +231,22 @@ namespace Mono.CSharp {
|
||||
printer.Print (msg, settings.ShowFullPaths);
|
||||
}
|
||||
|
||||
public void WarningPlayScript (int code, Location loc, string format, string arg)
|
||||
{
|
||||
WarningPlayScript (code, loc, string.Format (format, arg));
|
||||
}
|
||||
|
||||
public void WarningPlayScript (int code, Location loc, string error)
|
||||
{
|
||||
if (reporting_disabled > 0)
|
||||
return;
|
||||
|
||||
var msg = new PlayScript.WarningMessage (code, loc, error, extra_information);
|
||||
extra_information.Clear ();
|
||||
|
||||
printer.Print (msg, settings.ShowFullPaths);
|
||||
}
|
||||
|
||||
public void Warning (int code, int level, Location loc, string format, string arg)
|
||||
{
|
||||
Warning (code, level, loc, String.Format (format, arg));
|
||||
@@ -278,9 +294,35 @@ namespace Mono.CSharp {
|
||||
if (reporting_disabled > 0)
|
||||
return;
|
||||
|
||||
ErrorMessage msg = new ErrorMessage (code, loc, error, extra_information);
|
||||
var msg = new ErrorMessage (code, loc, error, extra_information);
|
||||
extra_information.Clear ();
|
||||
|
||||
ProcessErrorMessage (msg);
|
||||
}
|
||||
|
||||
public void ErrorPlayScript (int code, Location loc, string format, params string[] args)
|
||||
{
|
||||
ErrorPlayScript (code, loc, string.Format (format, args));
|
||||
}
|
||||
|
||||
public void ErrorPlayScript (int code, Location loc, string format, string arg)
|
||||
{
|
||||
ErrorPlayScript (code, loc, string.Format (format, arg));
|
||||
}
|
||||
|
||||
public void ErrorPlayScript (int code, Location loc, string error)
|
||||
{
|
||||
if (reporting_disabled > 0)
|
||||
return;
|
||||
|
||||
var msg = new PlayScript.ErrorMessage (code, loc, error, extra_information);
|
||||
extra_information.Clear ();
|
||||
|
||||
ProcessErrorMessage (msg);
|
||||
}
|
||||
|
||||
void ProcessErrorMessage (AbstractMessage msg)
|
||||
{
|
||||
printer.Print (msg, settings.ShowFullPaths);
|
||||
|
||||
if (settings.Stacktrace)
|
||||
@@ -489,6 +531,12 @@ namespace Mono.CSharp {
|
||||
|
||||
public abstract bool IsWarning { get; }
|
||||
|
||||
public virtual string LanguagePrefix {
|
||||
get {
|
||||
return "CS";
|
||||
}
|
||||
}
|
||||
|
||||
public Location Location {
|
||||
get { return location; }
|
||||
}
|
||||
@@ -594,7 +642,7 @@ namespace Mono.CSharp {
|
||||
txt.Append (" ");
|
||||
}
|
||||
|
||||
txt.AppendFormat ("{0} CS{1:0000}: {2}", msg.MessageType, msg.Code, msg.Text);
|
||||
txt.AppendFormat ("{0} {3}{1:0000}: {2}", msg.MessageType, msg.Code, msg.Text, msg.LanguagePrefix);
|
||||
|
||||
if (!msg.IsWarning)
|
||||
output.WriteLine (FormatText (txt.ToString ()));
|
||||
|
||||
+149
-70
@@ -866,6 +866,11 @@ namespace Mono.CSharp {
|
||||
if (ec.CurrentIterator != null) {
|
||||
Error_ReturnFromIterator (ec);
|
||||
} else if (ec.ReturnType != InternalType.ErrorType) {
|
||||
if (ec.ReturnType == ec.Module.PlayscriptTypes.UndefinedType) {
|
||||
expr = new PlayScript.SimpleName ("undefined", loc).Resolve (ec);
|
||||
return true;
|
||||
}
|
||||
|
||||
ec.Report.Error (126, loc,
|
||||
"An object of a type convertible to `{0}' is required for the return statement",
|
||||
ec.ReturnType.GetSignatureForError ());
|
||||
@@ -973,7 +978,7 @@ namespace Mono.CSharp {
|
||||
return false;
|
||||
|
||||
if (expr.Type != block_return_type && expr.Type != InternalType.ErrorType) {
|
||||
expr = Convert.ImplicitConversionRequired (ec, expr, block_return_type, loc);
|
||||
expr = Convert.ImplicitConversionRequiredEnhanced (ec, expr, block_return_type, loc);
|
||||
|
||||
if (expr == null) {
|
||||
if (am != null && block_return_type == ec.ReturnType) {
|
||||
@@ -1475,6 +1480,12 @@ namespace Mono.CSharp {
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
public virtual TypeSpec ResolveType (BlockContext bc, TypeSpec type)
|
||||
{
|
||||
Variable.Type = type;
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
public class BlockVariable : Statement
|
||||
@@ -1492,9 +1503,10 @@ namespace Mono.CSharp {
|
||||
this.loc = type_expr.Location;
|
||||
}
|
||||
|
||||
protected BlockVariable (LocalVariable li)
|
||||
protected BlockVariable (LocalVariable li, Location loc)
|
||||
{
|
||||
this.li = li;
|
||||
this.loc = loc;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
@@ -1514,6 +1526,12 @@ namespace Mono.CSharp {
|
||||
}
|
||||
}
|
||||
|
||||
public Location Location {
|
||||
get {
|
||||
return loc;
|
||||
}
|
||||
}
|
||||
|
||||
public FullNamedExpression TypeExpression {
|
||||
get {
|
||||
return type_expr;
|
||||
@@ -1606,13 +1624,14 @@ namespace Mono.CSharp {
|
||||
}
|
||||
|
||||
if (type == null) {
|
||||
type = type_expr.ResolveAsType (bc);
|
||||
type = ResolveType (bc);
|
||||
if (type == null)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (li.IsConstant && !type.IsConstantCompatible) {
|
||||
Const.Error_InvalidConstantType (type, loc, bc.Report);
|
||||
}
|
||||
|
||||
if (li.IsConstant && !type.IsConstantCompatible) {
|
||||
Const.Error_InvalidConstantType (type, loc, bc.Report);
|
||||
}
|
||||
|
||||
if (type.IsStatic)
|
||||
@@ -1635,7 +1654,8 @@ namespace Mono.CSharp {
|
||||
|
||||
if (declarators != null) {
|
||||
foreach (var d in declarators) {
|
||||
d.Variable.Type = li.Type;
|
||||
d.ResolveType (bc, li.Type);
|
||||
|
||||
if (eval_global) {
|
||||
CreateEvaluatorVariable (bc, d.Variable);
|
||||
} else if (type != InternalType.ErrorType) {
|
||||
@@ -1645,7 +1665,7 @@ namespace Mono.CSharp {
|
||||
if (d.Initializer != null && resolveDeclaratorInitializers) {
|
||||
d.Initializer = ResolveInitializer (bc, d.Variable, d.Initializer);
|
||||
// d.Variable.DefinitelyAssigned
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1658,6 +1678,16 @@ namespace Mono.CSharp {
|
||||
return a.ResolveStatement (bc);
|
||||
}
|
||||
|
||||
public virtual TypeSpec ResolveType (BlockContext bc)
|
||||
{
|
||||
type = TypeExpression.ResolveAsType (bc);
|
||||
if (type == null)
|
||||
return null;
|
||||
|
||||
li.Type = type;
|
||||
return type;
|
||||
}
|
||||
|
||||
protected override void DoEmit (EmitContext ec)
|
||||
{
|
||||
li.CreateBuilder (ec);
|
||||
@@ -1761,6 +1791,7 @@ namespace Mono.CSharp {
|
||||
UsingVariable = 1 << 7,
|
||||
// DefinitelyAssigned = 1 << 8,
|
||||
IsLocked = 1 << 9,
|
||||
GlobalScope = 1 << 10,
|
||||
|
||||
ReadonlyMask = ForeachVariable | FixedVariable | UsingVariable
|
||||
}
|
||||
@@ -1919,13 +1950,15 @@ namespace Mono.CSharp {
|
||||
ec.Report.Warning (219, 3, Location, "The variable `{0}' is assigned but its value is never used", Name);
|
||||
else
|
||||
ec.Report.Warning (168, 3, Location, "The variable `{0}' is declared but never used", Name);
|
||||
|
||||
flags |= Flags.Used;
|
||||
}
|
||||
|
||||
if (HoistedVariant != null)
|
||||
return;
|
||||
|
||||
if (builder != null) {
|
||||
if ((flags & Flags.CompilerGenerated) != 0)
|
||||
if ((flags & (Flags.CompilerGenerated | Flags.GlobalScope)) != 0)
|
||||
return;
|
||||
|
||||
// To avoid Used warning duplicates
|
||||
@@ -1949,8 +1982,19 @@ namespace Mono.CSharp {
|
||||
|
||||
public Expression CreateReferenceExpression (ResolveContext rc, Location loc)
|
||||
{
|
||||
if (IsConstant && const_value != null)
|
||||
return Constant.CreateConstantFromValue (Type, const_value.GetValue (), loc);
|
||||
if (IsConstant) {
|
||||
if (const_value != null)
|
||||
return Constant.CreateConstantFromValue (Type, const_value.GetValue (), loc);
|
||||
|
||||
//
|
||||
// Constant is still uninitializer need to get PS specific default value
|
||||
//
|
||||
if (rc.IsPlayScriptType) {
|
||||
var expr = PlayScript.ImplicitVariableInitializer.GetConstantValue (rc, type, loc);
|
||||
if (expr != null)
|
||||
return expr;
|
||||
}
|
||||
}
|
||||
|
||||
return new LocalVariableReference (this, loc);
|
||||
}
|
||||
@@ -3119,6 +3163,14 @@ namespace Mono.CSharp {
|
||||
if (md is StateMachineMethod) {
|
||||
unreachable = true;
|
||||
} else {
|
||||
|
||||
if (rc.ReturnType == rc.Module.PlayscriptTypes.UndefinedType) {
|
||||
var ret = new Return (null, EndLocation);
|
||||
ret.Resolve (rc);
|
||||
statements.Add (ret);
|
||||
return true;
|
||||
}
|
||||
|
||||
rc.Report.Error (161, md.Location, "`{0}': not all code paths return a value", md.GetSignatureForError ());
|
||||
return false;
|
||||
}
|
||||
@@ -5362,7 +5414,7 @@ namespace Mono.CSharp {
|
||||
LocalVariable li;
|
||||
FullNamedExpression type_expr;
|
||||
CompilerAssign assign;
|
||||
TypeSpec type;
|
||||
protected TypeSpec type;
|
||||
|
||||
public Catch (Block block, Location loc)
|
||||
{
|
||||
@@ -5384,7 +5436,7 @@ namespace Mono.CSharp {
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsGeneral {
|
||||
public virtual bool IsGeneral {
|
||||
get {
|
||||
return type_expr == null;
|
||||
}
|
||||
@@ -5442,34 +5494,46 @@ namespace Mono.CSharp {
|
||||
public override bool Resolve (BlockContext ec)
|
||||
{
|
||||
using (ec.With (ResolveContext.Options.CatchScope, true)) {
|
||||
if (type_expr != null) {
|
||||
type = type_expr.ResolveAsType (ec);
|
||||
if (type == null)
|
||||
return false;
|
||||
if (!ResolveType (ec))
|
||||
return false;
|
||||
|
||||
if (type.BuiltinType != BuiltinTypeSpec.Type.Exception && !TypeSpec.IsBaseClass (type, ec.BuiltinTypes.Exception, false)) {
|
||||
ec.Report.Error (155, loc, "The type caught or thrown must be derived from System.Exception");
|
||||
} else if (li != null) {
|
||||
li.Type = type;
|
||||
li.PrepareForFlowAnalysis (ec);
|
||||
if (li != null) {
|
||||
li.Type = type;
|
||||
li.PrepareForFlowAnalysis (ec);
|
||||
|
||||
// source variable is at the top of the stack
|
||||
Expression source = new EmptyExpression (li.Type);
|
||||
if (li.Type.IsGenericParameter)
|
||||
source = new UnboxCast (source, li.Type);
|
||||
// source variable is at the top of the stack
|
||||
Expression source = new EmptyExpression (li.Type);
|
||||
if (li.Type.IsGenericParameter)
|
||||
source = new UnboxCast (source, li.Type);
|
||||
|
||||
//
|
||||
// Uses Location.Null to hide from symbol file
|
||||
//
|
||||
assign = new CompilerAssign (new LocalVariableReference (li, Location.Null), source, Location.Null);
|
||||
Block.AddScopeStatement (new StatementExpression (assign, Location.Null));
|
||||
}
|
||||
}
|
||||
//
|
||||
// Uses Location.Null to hide from symbol file
|
||||
//
|
||||
assign = new CompilerAssign (new LocalVariableReference (li, Location.Null), source, Location.Null);
|
||||
Block.AddScopeStatement (new StatementExpression (assign, Location.Null));
|
||||
}
|
||||
|
||||
return Block.Resolve (ec);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual bool ResolveType (BlockContext bc)
|
||||
{
|
||||
if (type_expr == null)
|
||||
return true;
|
||||
|
||||
type = type_expr.ResolveAsType (bc);
|
||||
if (type == null)
|
||||
return false;
|
||||
|
||||
if (type.BuiltinType != BuiltinTypeSpec.Type.Exception && !TypeSpec.IsBaseClass (type, bc.BuiltinTypes.Exception, false)) {
|
||||
bc.Report.Error (155, loc, "The type caught or thrown must be derived from System.Exception");
|
||||
type = bc.Module.Compiler.BuiltinTypes.Exception;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void CloneTo (CloneContext clonectx, Statement t)
|
||||
{
|
||||
Catch target = (Catch) t;
|
||||
@@ -5619,6 +5683,12 @@ namespace Mono.CSharp {
|
||||
continue;
|
||||
|
||||
if (resolved_type == ct || TypeSpec.IsBaseClass (resolved_type, ct, true)) {
|
||||
//
|
||||
// All sort of weird things are allowed in PS
|
||||
//
|
||||
if (clauses[ii] is PlayScript.Catch)
|
||||
continue;
|
||||
|
||||
ec.Report.Error (160, c.loc,
|
||||
"A previous catch clause already catches all exceptions of this or a super type `{0}'",
|
||||
ct.GetSignatureForError ());
|
||||
@@ -5676,15 +5746,13 @@ namespace Mono.CSharp {
|
||||
}
|
||||
|
||||
public VariableDeclaration (LocalVariable li, Location loc)
|
||||
: base (li)
|
||||
: base (li, loc)
|
||||
{
|
||||
this.loc = loc;
|
||||
}
|
||||
|
||||
public VariableDeclaration (Expression expr)
|
||||
: base (null)
|
||||
: base (null, expr.Location)
|
||||
{
|
||||
loc = expr.Location;
|
||||
Initializer = expr;
|
||||
}
|
||||
|
||||
@@ -5936,7 +6004,7 @@ namespace Mono.CSharp {
|
||||
/// </summary>
|
||||
public class Foreach : Statement
|
||||
{
|
||||
abstract class IteratorStatement : Statement
|
||||
protected abstract class IteratorStatement : Statement
|
||||
{
|
||||
protected readonly Foreach for_each;
|
||||
|
||||
@@ -6105,7 +6173,7 @@ namespace Mono.CSharp {
|
||||
}
|
||||
}
|
||||
|
||||
sealed class CollectionForeach : IteratorStatement, OverloadResolver.IErrorHandler
|
||||
protected sealed class CollectionForeach : IteratorStatement, OverloadResolver.IErrorHandler
|
||||
{
|
||||
class RuntimeDispose : Using.VariableDeclaration
|
||||
{
|
||||
@@ -6147,6 +6215,7 @@ namespace Mono.CSharp {
|
||||
}
|
||||
|
||||
LocalVariable variable;
|
||||
Expression variable_ref;
|
||||
Expression expr;
|
||||
Statement statement;
|
||||
ExpressionStatement init;
|
||||
@@ -6160,6 +6229,13 @@ namespace Mono.CSharp {
|
||||
this.expr = expr;
|
||||
}
|
||||
|
||||
public CollectionForeach (Foreach @foreach, LocalVariableReference variableReference, Expression expr)
|
||||
: base (@foreach)
|
||||
{
|
||||
this.variable_ref = variableReference;
|
||||
this.expr = expr;
|
||||
}
|
||||
|
||||
void Error_WrongEnumerator (ResolveContext rc, MethodSpec enumerator)
|
||||
{
|
||||
rc.Report.SymbolRelatedToPreviousError (enumerator);
|
||||
@@ -6290,7 +6366,7 @@ namespace Mono.CSharp {
|
||||
}
|
||||
|
||||
var get_enumerator = get_enumerator_mg.BestCandidate;
|
||||
enumerator_variable = TemporaryVariableReference.Create (get_enumerator.ReturnType, variable.Block, loc);
|
||||
enumerator_variable = TemporaryVariableReference.Create (get_enumerator.ReturnType, for_each.body, loc);
|
||||
enumerator_variable.Resolve (ec);
|
||||
|
||||
// Prepare bool MoveNext ()
|
||||
@@ -6311,37 +6387,39 @@ namespace Mono.CSharp {
|
||||
if (current_pe == null)
|
||||
return false;
|
||||
|
||||
VarExpr ve = for_each.type as VarExpr;
|
||||
if (variable != null) {
|
||||
VarExpr ve = for_each.type as VarExpr;
|
||||
|
||||
if (ve != null) {
|
||||
if (is_dynamic) {
|
||||
// Source type is dynamic, set element type to dynamic too
|
||||
variable.Type = ec.BuiltinTypes.Dynamic;
|
||||
if (ve != null) {
|
||||
if (is_dynamic) {
|
||||
// Source type is dynamic, set element type to dynamic too
|
||||
variable.Type = ec.BuiltinTypes.Dynamic;
|
||||
} else {
|
||||
// Infer implicitly typed local variable from foreach enumerable type
|
||||
variable.Type = current_pe.Type;
|
||||
}
|
||||
} else {
|
||||
// Infer implicitly typed local variable from foreach enumerable type
|
||||
variable.Type = current_pe.Type;
|
||||
}
|
||||
} else {
|
||||
if (is_dynamic) {
|
||||
// Explicit cast of dynamic collection elements has to be done at runtime
|
||||
current_pe = EmptyCast.Create (current_pe, ec.BuiltinTypes.Dynamic);
|
||||
if (is_dynamic) {
|
||||
// Explicit cast of dynamic collection elements has to be done at runtime
|
||||
current_pe = EmptyCast.Create (current_pe, ec.BuiltinTypes.Dynamic);
|
||||
}
|
||||
|
||||
variable.Type = for_each.type.ResolveAsType (ec);
|
||||
|
||||
if (variable.Type == null)
|
||||
return false;
|
||||
|
||||
current_pe = Convert.ExplicitConversion (ec, current_pe, variable.Type, loc);
|
||||
if (current_pe == null)
|
||||
return false;
|
||||
}
|
||||
|
||||
variable.Type = for_each.type.ResolveAsType (ec);
|
||||
|
||||
if (variable.Type == null)
|
||||
return false;
|
||||
|
||||
current_pe = Convert.ExplicitConversion (ec, current_pe, variable.Type, loc);
|
||||
if (current_pe == null)
|
||||
variable_ref = new LocalVariableReference (variable, loc).Resolve (ec);
|
||||
if (variable_ref == null)
|
||||
return false;
|
||||
}
|
||||
|
||||
var variable_ref = new LocalVariableReference (variable, loc).Resolve (ec);
|
||||
if (variable_ref == null)
|
||||
return false;
|
||||
|
||||
for_each.body.AddScopeStatement (new StatementExpression (new CompilerAssign (variable_ref, current_pe, Location.Null), for_each.type.Location));
|
||||
for_each.body.AddScopeStatement (new StatementExpression (new CompilerAssign (variable_ref, current_pe, Location.Null), Location.Null));
|
||||
|
||||
var init = new Invocation (get_enumerator_mg, null);
|
||||
|
||||
@@ -6422,11 +6500,11 @@ namespace Mono.CSharp {
|
||||
#endregion
|
||||
}
|
||||
|
||||
Expression type;
|
||||
LocalVariable variable;
|
||||
Expression expr;
|
||||
Statement statement;
|
||||
Block body;
|
||||
protected Expression type;
|
||||
protected LocalVariable variable;
|
||||
protected Expression expr;
|
||||
protected Statement statement;
|
||||
protected Block body;
|
||||
|
||||
public Foreach (Expression type, LocalVariable var, Expression expr, Statement stmt, Block body, Location l)
|
||||
{
|
||||
@@ -6493,7 +6571,8 @@ namespace Mono.CSharp {
|
||||
if (!(statement is Block))
|
||||
ec.BeginCompilerScope ();
|
||||
|
||||
variable.CreateBuilder (ec);
|
||||
if (variable != null)
|
||||
variable.CreateBuilder (ec);
|
||||
|
||||
statement.Emit (ec);
|
||||
|
||||
|
||||
@@ -220,6 +220,7 @@ namespace Mono.CSharp
|
||||
public readonly PredefinedType CallSite;
|
||||
public readonly PredefinedType CallSiteGeneric;
|
||||
public readonly PredefinedType BinderFlags;
|
||||
public readonly PredefinedType ExpressionType;
|
||||
|
||||
//
|
||||
// C# 5.0
|
||||
@@ -276,6 +277,7 @@ namespace Mono.CSharp
|
||||
CallSiteGeneric = new PredefinedType (module, MemberKind.Class, "System.Runtime.CompilerServices", "CallSite", 1);
|
||||
Binder = new PredefinedType (module, MemberKind.Class, "Microsoft.CSharp.RuntimeBinder", "Binder");
|
||||
BinderFlags = new PredefinedType (module, MemberKind.Enum, "Microsoft.CSharp.RuntimeBinder", "CSharpBinderFlags");
|
||||
ExpressionType = new PredefinedType (module, MemberKind.Enum, "System.Linq.Expressions", "ExpressionType");
|
||||
|
||||
Action = new PredefinedType (module, MemberKind.Delegate, "System", "Action");
|
||||
AsyncVoidMethodBuilder = new PredefinedType (module, MemberKind.Struct, "System.Runtime.CompilerServices", "AsyncVoidMethodBuilder");
|
||||
@@ -318,6 +320,8 @@ namespace Mono.CSharp
|
||||
if (ExpressionGeneric.Define ())
|
||||
ExpressionGeneric.TypeSpec.IsExpressionTreeType = true;
|
||||
|
||||
ExpressionType.Define ();
|
||||
|
||||
Task.Define ();
|
||||
if (TaskGeneric.Define ())
|
||||
TaskGeneric.TypeSpec.IsGenericTask = true;
|
||||
|
||||
+25
-3
@@ -190,6 +190,15 @@ namespace Mono.CSharp
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Only used by PlayScript dynamic classes
|
||||
//
|
||||
public bool IsDynamicClass {
|
||||
get {
|
||||
return (Modifiers & Modifiers.DYNAMIC) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Returns true for instances of Expression<T>
|
||||
//
|
||||
@@ -647,7 +656,7 @@ namespace Mono.CSharp
|
||||
//
|
||||
// Null is considered to be a reference type
|
||||
//
|
||||
return t == InternalType.NullLiteral || t.BuiltinType == BuiltinTypeSpec.Type.Dynamic;
|
||||
return t == InternalType.NullLiteral || t.BuiltinType == BuiltinTypeSpec.Type.Dynamic || t.BuiltinType == BuiltinTypeSpec.Type.Object;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
@@ -942,10 +951,10 @@ namespace Mono.CSharp
|
||||
switch (Name) {
|
||||
case "Int32": return "int";
|
||||
case "Int64": return "long";
|
||||
case "String": return "string";
|
||||
case "String": return ns.Length == 0 ? name : "string";
|
||||
case "Boolean": return "bool";
|
||||
case "Void": return "void";
|
||||
case "Object": return "object";
|
||||
case "Object": return ns.Length == 0 ? name : "object";
|
||||
case "UInt32": return "uint";
|
||||
case "Int16": return "short";
|
||||
case "UInt16": return "ushort";
|
||||
@@ -1413,6 +1422,7 @@ namespace Mono.CSharp
|
||||
bool IsPartial { get; }
|
||||
bool IsComImport { get; }
|
||||
bool IsTypeForwarder { get; }
|
||||
bool IsPlayScriptType { get; }
|
||||
int TypeParametersCount { get; }
|
||||
TypeParameterSpec[] TypeParameters { get; }
|
||||
|
||||
@@ -1478,6 +1488,12 @@ namespace Mono.CSharp
|
||||
}
|
||||
}
|
||||
|
||||
bool ITypeDefinition.IsPlayScriptType {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool ITypeDefinition.IsTypeForwarder {
|
||||
get {
|
||||
return false;
|
||||
@@ -1614,6 +1630,12 @@ namespace Mono.CSharp
|
||||
}
|
||||
}
|
||||
|
||||
bool ITypeDefinition.IsPlayScriptType {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override string Name {
|
||||
get {
|
||||
throw new NotSupportedException ();
|
||||
|
||||
@@ -68,6 +68,9 @@ qcheck2:
|
||||
gen-mt-tests:
|
||||
$(TESTER) -mode:nunit -files:'v2' -compiler:$(COMPILER) -issues:known-issues-mt -compiler-options:"-lib:$(topdir)/class/lib/monotouch projects/MonoTouch/ivt.cs"
|
||||
|
||||
playscript:
|
||||
$(TESTER) -mode:pos -files:'*-???.play' -compiler:$(COMPILER) -issues:known-issues-$(PROFILE) -log:$(PROFILE).log -il:ver-il-$(PROFILE).xml $(DEFINES) $(TOPTIONS)
|
||||
|
||||
test-local:
|
||||
@:
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package
|
||||
{
|
||||
public class HelloWorld
|
||||
{
|
||||
public static function Main():void
|
||||
{
|
||||
trace ("Hello World!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package {
|
||||
public function testFunction (obj:*, cl:Class):Boolean
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// Compiler options: test-ps-002-2.play
|
||||
|
||||
package
|
||||
{
|
||||
public class Test
|
||||
{
|
||||
public static function Main():int
|
||||
{
|
||||
testFunction ("arg", null);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package
|
||||
{
|
||||
public class BasicTypes
|
||||
{
|
||||
var f_obj:Object = null;
|
||||
var f_str:String = "string";
|
||||
var f_n:Number = 9.3;
|
||||
var f_i:int = -3;
|
||||
var f_ui:uint = 44;
|
||||
var f_b:Boolean = true;
|
||||
var f_any:* = 9;
|
||||
|
||||
public static function Main():void
|
||||
{
|
||||
var obj:Object = null;
|
||||
var str1:String = "string";
|
||||
var n:Number = 9.3;
|
||||
var i:int = -3;
|
||||
var ui:uint = 44;
|
||||
var b:Boolean = true;
|
||||
var any:* = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package
|
||||
{
|
||||
public function Main():int
|
||||
{
|
||||
var a:BaseClass = new TestClass ();
|
||||
if (a.p != 15)
|
||||
return 1;
|
||||
|
||||
a = new BaseClass ();
|
||||
if (a.p != 3)
|
||||
return 2;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
class BaseClass
|
||||
{
|
||||
public var p:int;
|
||||
|
||||
function BaseClass ()
|
||||
{
|
||||
p = 3;
|
||||
}
|
||||
}
|
||||
|
||||
class TestClass extends BaseClass
|
||||
{
|
||||
function TestClass ()
|
||||
{
|
||||
p *= 5;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package
|
||||
{
|
||||
internal class test
|
||||
{
|
||||
public static function Main():int
|
||||
{
|
||||
if (max (4, 30) != 30)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
internal static function max (n1:Number, n2:Number): Number
|
||||
{
|
||||
return System.Math.Max (n1, n2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package
|
||||
{
|
||||
public dynamic class TestClass
|
||||
{
|
||||
public function TestClass()
|
||||
{
|
||||
}
|
||||
|
||||
private var ui:uint;
|
||||
|
||||
internal function get Prop():uint {
|
||||
return ui;
|
||||
}
|
||||
|
||||
internal function set Prop(value:uint):void {
|
||||
ui = value;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// Compiler options: test-ps-006-2.play
|
||||
|
||||
package
|
||||
{
|
||||
public class test
|
||||
{
|
||||
public static function Main():int
|
||||
{
|
||||
//Prop = 3;
|
||||
//if (Prop != 3)
|
||||
// return 1;
|
||||
|
||||
var m:TestClass = new TestClass ();
|
||||
m.Prop = 300;
|
||||
if (m.Prop != 300)
|
||||
return 2;
|
||||
|
||||
m["Prop"] = 500;
|
||||
if (m.Prop != 500)
|
||||
return 3;
|
||||
|
||||
if (m["Prop"] != 500)
|
||||
return 4;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
var n:Number = 4;
|
||||
|
||||
function get Prop():Number {
|
||||
return n;
|
||||
}
|
||||
|
||||
function set Prop(value:Number):void {
|
||||
n = value;
|
||||
}
|
||||
*/
|
||||
@@ -0,0 +1,21 @@
|
||||
package
|
||||
{
|
||||
public dynamic class test
|
||||
{
|
||||
public static function Main():int
|
||||
{
|
||||
var dynamic:int = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function foo():void
|
||||
{
|
||||
dynamic (9);
|
||||
}
|
||||
|
||||
private function dynamic(dynamic:int):void
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package
|
||||
{
|
||||
public dynamic class test
|
||||
{
|
||||
public static function Main():int
|
||||
{
|
||||
var res:int;
|
||||
res = Local ();
|
||||
if (res != 0)
|
||||
return res + 10;
|
||||
|
||||
res = Imported ();
|
||||
if (res != 0)
|
||||
return res + 20;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static function Local ():int
|
||||
{
|
||||
var m:test = new test ();
|
||||
m["Prop"] = 500;
|
||||
if (m.Prop != 500)
|
||||
return 1;
|
||||
|
||||
if (m["Prop"] != 500)
|
||||
return 2;
|
||||
|
||||
if (m.Prop != 500)
|
||||
return 3;
|
||||
|
||||
m.Prop = 300;
|
||||
if (m.Prop != 300)
|
||||
return 4;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static function Imported ():int
|
||||
{
|
||||
var m:Array = new Array ();
|
||||
m["Prop"] = 500;
|
||||
if (m.Prop != 500)
|
||||
return 1;
|
||||
|
||||
if (m["Prop"] != 500)
|
||||
return 2;
|
||||
|
||||
if (m.Prop != 500)
|
||||
return 3;
|
||||
|
||||
m.Prop = 300;
|
||||
if (m.Prop != 300)
|
||||
return 4;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loaded 100 of 138 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user