GithubHelp home page GithubHelp logo

hyzycczz / dna2oldmemory Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dna2github/dna2oldmemory

0.0 0.0 0.0 248 KB

old code and tiny utils简单脉搏波波形分析系统设计与实现

License: MIT License

Java 29.37% C# 39.99% JavaScript 7.06% HTML 2.61% Python 17.41% C 3.11% Shell 0.43% CSS 0.02%

dna2oldmemory's Introduction

dna2oldmemory简单脉搏波波形分析系统设计与实现

Migrate my old code from SourceForge

==== MobileASM (2009): A simple asm interpreter in J2ME

I developped this application with Java(TM) ME platform SDK 3.0, EA. And it is very simple software to execute assembly as script. However, I make it in a haste and the FLAGS is confusing and I have not corrected the error yet.

   // 1+2+3+...+100
   mov eax,0
   mov ecx,100
   add eax,ecx
   dec ecx
   ja  3
   print "1+2+3+...+100
   print eax
   end

==== ExpressionCalc (2011): A simple expression calculator lib in Java

I write it without using regex of Java to build an own code interpreter. And I use the CalcTree to do calculation for a complicated expression and SymbolTable supports to hold varibles.

   SymbolTableNode stn;
   SymbolTable st;
   CalcTree ct;
   LineCodeStream lcs;

   st = new SymbolTable();
   ct = new CalcTree();

   // declare variables
   stn = st.add("hello", null);
   stn.data = Double.valueOf(20.0);
   stn.type = 0;
   stn = st.add("world", null);
   stn.data = Double.valueOf(10.0);
   stn.type = 0;

   // declare functions
   stn = st.add("sqr", null);
   stn.data = Integer.valueOf(1); // function id
   stn.type = 1;
   stn = st.add("cube", null);
   stn.data = Integer.valueOf(2);
   stn.type = 1;
   stn = st.add("double", null);
   stn.data = Integer.valueOf(3);
   stn.type = 1;

   // try an expression
   lcs = new LineCodeStream(
      "hello+cube(world) - (world + 2)*sqr(2) - sqr(cube(double(2)))/hello");
   // TODO: proccess every token from lcs.getWord()
   // TODO: and add tokens to calculating tree
   double _val = 0.0;
   _val = calcTreeValue(ct.getRoot(),st);
   System.out.println(lcs.getLineCode() + " = " + _val);

For example, in SyCoExp3in1.java:

1+3.0-((((hello+f(x+5))*2+1.0)/3-3)+9)/4-3

analysis:

[ parent:(left | right) ]

-:(-:(+:(1|3.0) | /:(+:(-:(/:(+:(*:(+:(hello | ,:(f,+:(x,5))) | 2) | 1.0) | 3) | 3) | 9) | 4) ) | 3)

       -
     /   \
    -     3
   / \
  +   /
 / \  | \
 1 3  +  4
     / \
    -   9
    |\
    / 3
    |\
    + 3
   / \
  *  1.0
  |\
  + 2
 / \

hello , /
f + /
x 5

==== JVCForCsharp (2012)

New Style:

   // load jvm
   JavaConnector jvc = new JavaConnector();
   // now options can be customized.
   // jvc.InitializeJVM(new string[] { "-Djava.compiler=NONE", "-Djava.class.path=.;test.jar;", "-verbose:NONE" });
   jvc.InitializeJVM("test.jar");
   // work with jvm
   Java java = jvc.Connect();
   /*
    *   package ljy.test;
    *   public class TestMain {
    *   	public static int x = 0;
    *   	public static int a, b, c;
    *   	public static float d;
    *   	public static void main(String[] args) {
    *   		x = Integer.valueOf(args[0]) + 4;
    *   	}
    *   	public static void test(int[] args, float extra) {
    *   		a = args[0]; b = args[1]; c = (int)extra; d = extra;
    *   		x = a + b + c;
    *   	}
    *   }
    */
   JavaClass TestMainClass = java.LoadClass("ljy.test.TestMain");

   JavaStaticMethod methodMain = TestMainClass.GetStaticMethod("void", "main", "java.lang.String[]");
   JavaStaticField mInt = TestMainClass.GetStaticField("int", "x");
   JavaArray strarr = new JavaArray(new string[] { "2" });
   methodMain.VoidInvoke(strarr);
   int mVal = mInt.GetIntValue(); // get 6

   JavaStaticMethod methodTest = TestMainClass.GetStaticMethod("void", "test", "int[]", "float");
   JavaArray intarr = new JavaArray(new int[] { 5, 6 });
   methodTest.VoidInvoke(intarr, 4.4f);

   JavaStaticField aInt = TestMainClass.GetStaticField("int", "a");
   JavaStaticField bInt = TestMainClass.GetStaticField("int", "b");
   JavaStaticField cInt = TestMainClass.GetStaticField("int", "c");
   JavaStaticField dFloat = TestMainClass.GetStaticField("float", "d");
   Console.WriteLine(string.Format("x = {0}, a = {1}, b = {2}, c = {3}, d = {4}",
      mInt.GetIntValue(), aInt.GetIntValue(), bInt.GetIntValue(), cInt.GetIntValue(), 
      dFloat.GetFloatValue())); // x = 15, a = 5, b = 6, c = 4, d = 4.4

   jvc.FinalizeJVM();

Old Style:

   // load jvm
   JavaInterface.JavaConnector jvc = new JavaInterface.JavaConnector();
   jvc.InitializeJVM("testjvm.jar");
   // work with jvm
   JavaInterface.JavaENV env;
   env = jvc.GetJavaENV();
   /*
    * package ljy.csharp.jvm;
    * class Hello {
    *    public static int m = 9;
    * }
    */
   int HelloClass = env.FindClass("ljy/csharp/jvm/Hello");
   int mInt = env.GetStaticFieldID(HelloClass, "m", "I");
   // mVal will get 9
   int mVal = env.GetStaticIntField(HelloClass, mInt);
   // unload jvm
   jvc.FinalizeJVM();

   // other examples:
   // create an Integer entity
   int intclass = env.FindClass("java/lang/Integer");
   int intinitmethod = env.GetMethodID(intclass, "<init>", "(I)V");
   int test = 5;
   IntPtr testptr = NativeMemory.NewIntObject(test);
   int intentity = env.NewObjectA(intclass, intinitmethod, testptr);

   // create a Date entity to get cureent time
   int dateclass = env.FindClass("java/util/Date");
   int dateinitmethod = env.GetMethodID(dateclass, "<init>", "()V");
   int dateentity = env.NewObject(dateclass, dateinitmethod, null);
   int date_gettime = env.GetMethodID(dateclass, "getTime", "()J");
   MessageBox.Show(string.Format("Time: {0}", 
      env.CallLongMethod(dateentity, date_gettime, null)));

==== Chrome Extension for UI Automation

Extension example.

==== Artificial Inteligence Lab

  • Texas Hold'em Poker: texas_holdem_poker
  • Chinese Majiang: majiang

dna2oldmemory's People

Contributors

dependabot[bot] avatar dna2github avatar hyzycczz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.