1
0
mirror of https://github.com/twiglet/cs2j.git synced 2025-01-18 13:15:17 +01:00

Add --experimental-transforms for undercooked implementations and add boxing of primitive types (see noise added to ScormEngine for aesthetic problems)

This commit is contained in:
Kevin Glynn 2011-04-06 16:27:15 +02:00
parent 158e22b44f
commit 83fcfd0882
3 changed files with 16 additions and 8 deletions

View File

@ -128,6 +128,7 @@ namespace Twiglet.CS2J.Translator
.Add ("translator-keep-parens=", v => cfg.TranslatorKeepParens = Boolean.Parse(v))
.Add ("translator-timestamp-files=", v => cfg.TranslatorAddTimeStamp = Boolean.Parse(v))
.Add ("translator-exception-is-throwable=", v => cfg.TranslatorExceptionIsThrowable = Boolean.Parse(v))
.Add ("experimental-transforms=", v => cfg.ExperimentalTransforms = Boolean.Parse(v))
;
//TODO: fix enum dump
@ -315,7 +316,7 @@ namespace Twiglet.CS2J.Translator
// Add the namespace.
XmlNamespaceManager nsmgr = new XmlNamespaceManager(Doc.NameTable);
nsmgr.AddNamespace("ss", "http://www.w3.org/2000/09/xmldsig#");
XmlNode root = Doc.DocumentElement;
XmlNodeList nodeList = root.SelectNodes("/*/ss:Signature", nsmgr);
// fail if no signature was found.
@ -342,10 +343,10 @@ namespace Twiglet.CS2J.Translator
// Suck in translation file
Stream txStream = new FileStream(fullName, FileMode.Open, FileAccess.Read);
if (numLines < numLines - 1)
if (numLines < numLines - 1)
{
// TRIAL ONLY
// TRIAL ONLY
// Create a new XML document.
XmlDocument xmlDoc = new XmlDocument();
@ -369,7 +370,7 @@ namespace Twiglet.CS2J.Translator
}
txStream.Seek(0, SeekOrigin.Begin);
}
}
TypeRepTemplate t = TypeRepTemplate.newInstance(txStream);
// Fullname has form: <path>/<key>.xml
AppEnv[t.TypeName+(t.TypeParams != null && t.TypeParams.Length > 0 ? "'" + t.TypeParams.Length.ToString() : "")] = t;
@ -404,7 +405,7 @@ namespace Twiglet.CS2J.Translator
private static string limit(string inp) {
if (numLines > numLines - 1)
return inp;
// TRIAL ONLY
// TRIAL ONLY
String[] lines = inp.Split(newLines, numLines+1, StringSplitOptions.None);
if (lines.Length <= numLines) {
return inp;

View File

@ -56,6 +56,11 @@ namespace Twiglet.CS2J.Translator
get; set;
}
public bool ExperimentalTransforms
{
get; set;
}
public CS2JSettings ()
{
@ -88,6 +93,8 @@ namespace Twiglet.CS2J.Translator
TranslatorKeepParens = true;
TranslatorAddTimeStamp = true;
TranslatorExceptionIsThrowable = false;
ExperimentalTransforms = false;
}
}
}

View File

@ -631,7 +631,7 @@ scope {
// We are calling a method on an expression. If it has a primitive type then cast it to
// the appropriate Object type.
CommonTree e2InBox = expType.IsUnboxedType ? castToBoxedType(expType, $e2.tree, $d0.token) : $e2.tree;
CommonTree e2InBox = expType.IsUnboxedType && Cfg.ExperimentalTransforms ? castToBoxedType(expType, $e2.tree, $d0.token) : $e2.tree;
MethodRepTemplate methodRep = methodResult.Result as MethodRepTemplate;
Dictionary<string,CommonTree> myMap = new Dictionary<string,CommonTree>();
@ -679,7 +679,7 @@ scope {
// We are calling a method on an expression. If it has a primitive type then cast it to
// the appropriate Object type.
CommonTree e1InBox = $e1.dotNetType.IsUnboxedType ? castToBoxedType($e1.dotNetType, $e1.tree, $d1.token) : $e1.tree;
CommonTree e1InBox = $e1.dotNetType.IsUnboxedType && Cfg.ExperimentalTransforms ? castToBoxedType($e1.dotNetType, $e1.tree, $d1.token) : $e1.tree;
Dictionary<string,CommonTree> myMap = new Dictionary<string,CommonTree>();
myMap["this"] = wrapExpression(e1InBox, $i1.tree.Token);