Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invoking java functions from RASCAL

Tags:

rascal

can I invoke Java functions from Rascal. I want to write RASCAL analyser, but want access CFG nodes by calling a java function. Is this possible in Rascal. To put it simply, can I wrap the existing java application and invoke it from RASCAL

like image 518
user2940768 Avatar asked May 12 '26 08:05

user2940768


1 Answers

Sure. It works as follows.

  1. Treat your Rascal project in Eclipse as a Java project as well.
  2. Add source code and libraries and make the stuff compile.
  3. Learn about the pdb.values API (in particular IValueFactory)
  4. In Rascal write something like this:
    @javaClass{com.mypackage.MyClass}
    java int myFunction(str arg);
  1. Then in Java:
     package com.mypackage;    
     public class MyClass {
        private final IValueFactor vf;
        public MyClass(IValueFactory vf) { 
          this.vf = vf;
        }
        IValue myFunction(IString x) {
           return vf.integer(-1);
        }
     }  
like image 183
Jurgen Vinju Avatar answered May 19 '26 23:05

Jurgen Vinju



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!