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:
parent
158e22b44f
commit
83fcfd0882
@ -128,6 +128,7 @@ namespace Twiglet.CS2J.Translator
|
|||||||
.Add ("translator-keep-parens=", v => cfg.TranslatorKeepParens = Boolean.Parse(v))
|
.Add ("translator-keep-parens=", v => cfg.TranslatorKeepParens = Boolean.Parse(v))
|
||||||
.Add ("translator-timestamp-files=", v => cfg.TranslatorAddTimeStamp = 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 ("translator-exception-is-throwable=", v => cfg.TranslatorExceptionIsThrowable = Boolean.Parse(v))
|
||||||
|
.Add ("experimental-transforms=", v => cfg.ExperimentalTransforms = Boolean.Parse(v))
|
||||||
;
|
;
|
||||||
|
|
||||||
//TODO: fix enum dump
|
//TODO: fix enum dump
|
||||||
@ -315,7 +316,7 @@ namespace Twiglet.CS2J.Translator
|
|||||||
// Add the namespace.
|
// Add the namespace.
|
||||||
XmlNamespaceManager nsmgr = new XmlNamespaceManager(Doc.NameTable);
|
XmlNamespaceManager nsmgr = new XmlNamespaceManager(Doc.NameTable);
|
||||||
nsmgr.AddNamespace("ss", "http://www.w3.org/2000/09/xmldsig#");
|
nsmgr.AddNamespace("ss", "http://www.w3.org/2000/09/xmldsig#");
|
||||||
|
|
||||||
XmlNode root = Doc.DocumentElement;
|
XmlNode root = Doc.DocumentElement;
|
||||||
XmlNodeList nodeList = root.SelectNodes("/*/ss:Signature", nsmgr);
|
XmlNodeList nodeList = root.SelectNodes("/*/ss:Signature", nsmgr);
|
||||||
// fail if no signature was found.
|
// fail if no signature was found.
|
||||||
@ -342,10 +343,10 @@ namespace Twiglet.CS2J.Translator
|
|||||||
|
|
||||||
// Suck in translation file
|
// Suck in translation file
|
||||||
Stream txStream = new FileStream(fullName, FileMode.Open, FileAccess.Read);
|
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.
|
// Create a new XML document.
|
||||||
XmlDocument xmlDoc = new XmlDocument();
|
XmlDocument xmlDoc = new XmlDocument();
|
||||||
|
|
||||||
@ -369,7 +370,7 @@ namespace Twiglet.CS2J.Translator
|
|||||||
}
|
}
|
||||||
|
|
||||||
txStream.Seek(0, SeekOrigin.Begin);
|
txStream.Seek(0, SeekOrigin.Begin);
|
||||||
}
|
}
|
||||||
TypeRepTemplate t = TypeRepTemplate.newInstance(txStream);
|
TypeRepTemplate t = TypeRepTemplate.newInstance(txStream);
|
||||||
// Fullname has form: <path>/<key>.xml
|
// Fullname has form: <path>/<key>.xml
|
||||||
AppEnv[t.TypeName+(t.TypeParams != null && t.TypeParams.Length > 0 ? "'" + t.TypeParams.Length.ToString() : "")] = t;
|
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) {
|
private static string limit(string inp) {
|
||||||
if (numLines > numLines - 1)
|
if (numLines > numLines - 1)
|
||||||
return inp;
|
return inp;
|
||||||
// TRIAL ONLY
|
// TRIAL ONLY
|
||||||
String[] lines = inp.Split(newLines, numLines+1, StringSplitOptions.None);
|
String[] lines = inp.Split(newLines, numLines+1, StringSplitOptions.None);
|
||||||
if (lines.Length <= numLines) {
|
if (lines.Length <= numLines) {
|
||||||
return inp;
|
return inp;
|
||||||
|
@ -56,6 +56,11 @@ namespace Twiglet.CS2J.Translator
|
|||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool ExperimentalTransforms
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
public CS2JSettings ()
|
public CS2JSettings ()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -88,6 +93,8 @@ namespace Twiglet.CS2J.Translator
|
|||||||
TranslatorKeepParens = true;
|
TranslatorKeepParens = true;
|
||||||
TranslatorAddTimeStamp = true;
|
TranslatorAddTimeStamp = true;
|
||||||
TranslatorExceptionIsThrowable = false;
|
TranslatorExceptionIsThrowable = false;
|
||||||
|
|
||||||
|
ExperimentalTransforms = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -631,7 +631,7 @@ scope {
|
|||||||
|
|
||||||
// We are calling a method on an expression. If it has a primitive type then cast it to
|
// We are calling a method on an expression. If it has a primitive type then cast it to
|
||||||
// the appropriate Object type.
|
// 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;
|
MethodRepTemplate methodRep = methodResult.Result as MethodRepTemplate;
|
||||||
Dictionary<string,CommonTree> myMap = new Dictionary<string,CommonTree>();
|
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
|
// We are calling a method on an expression. If it has a primitive type then cast it to
|
||||||
// the appropriate Object type.
|
// 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>();
|
Dictionary<string,CommonTree> myMap = new Dictionary<string,CommonTree>();
|
||||||
myMap["this"] = wrapExpression(e1InBox, $i1.tree.Token);
|
myMap["this"] = wrapExpression(e1InBox, $i1.tree.Token);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user