Skip to content

Commit

Permalink
add "string" and "null" support (neo-project#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
lightszero authored and Erik Zhang committed May 15, 2017
1 parent f68c336 commit e7aafb7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
14 changes: 12 additions & 2 deletions src/AntShares.Compiler.MSIL/Conv_Multi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,21 @@ private int _ConvertCall(OpCode src, AntsMethod to)
}
else if (refs.ReturnType.Name == "ExecutionEngine" || refs.ReturnType.Name == "Storage")
{
if (src != null)
{
//有可能jump到此处
this.addrconv[src.addr] = this.addr;//因为没插入代码,实际是下一行
}
//donothing 語法過渡類型
return 0;
}
else
{//maybe a syscall // or other
if (src.tokenMethod == "System.Int32 System.Numerics.BigInteger::op_Explicit(System.Numerics.BigInteger)")
{
//donothing
return 0;
}
if (src.tokenMethod == "System.Int32 System.Numerics.BigInteger::op_Explicit(System.Numerics.BigInteger)")
{
//donothing
Expand All @@ -195,7 +205,7 @@ private int _ConvertCall(OpCode src, AntsMethod to)
{
return 0;
}
else if(src.tokenMethod == "System.Boolean System.Object::Equals(System.Object)")
if(src.tokenMethod.Contains("::op_Equality(")|| src.tokenMethod.Contains("::Equals("))
{
_Convert1by1(AntShares.VM.OpCode.EQUAL, src, to);
return 0;
Expand Down Expand Up @@ -329,7 +339,7 @@ private int _ConvertNewArr(ILMethod method, OpCode src, AntsMethod to)
to.body_Codes.Remove(code.addr);
this.addr--;
if (code.bytes != null)
this.addr -= code.bytes.Length;
this.addr -= code.bytes.Length;

var type = src.tokenType;
if (type != "System.Byte")
Expand Down
4 changes: 4 additions & 0 deletions src/AntShares.Compiler.MSIL/Converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,10 @@ private int ConvertCode(ILMethod method, OpCode src, AntsMethod to)
_Convert1by1(AntShares.VM.OpCode.DROP, src, to);
break;

case CodeEx.Ldnull:
_ConvertPush(new byte[0], src, to);
break;

case CodeEx.Ldc_I4:
case CodeEx.Ldc_I4_S:
_ConvertPush(src.tokenI32, src, to);
Expand Down
3 changes: 2 additions & 1 deletion src/AntShares.Compiler.MSIL/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Reflection;

namespace AntShares.Compiler.MSIL
{
Expand All @@ -17,7 +18,7 @@ public static void Main(string[] args)
//set console
Console.OutputEncoding = System.Text.Encoding.UTF8;
var log = new DefLogger();
log.Log("AntShars.Compiler.MSIL console app v0.01");
log.Log("AntShars.Compiler.MSIL console app v" + Assembly.GetEntryAssembly().GetName().Version);
if (args.Length == 0)
{
log.Log("need one param for DLL filename.");
Expand Down
2 changes: 1 addition & 1 deletion src/AntShares.Compiler.MSIL/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"authors": [ "The Antshares team" ],
"copyright": "2016-2017 The Antshares team",
"title": "AntShares.Compiler.MSIL",
"version": "1.6.4.1",
"version": "1.6.4.2",
"buildOptions": {
"emitEntryPoint": true,
"platform": "anycpu"
Expand Down

0 comments on commit e7aafb7

Please sign in to comment.