How to achieve runtime code injection

I want to write a Scala function like

def functionA(objectMap:Map[String, ClassB], statements: List[String]): ClassB = {
  var retObj = new ClassB
  retObj = statements
  return retObj

Input of this function are:

  1. objectMap(Map[String, ClassB)] which is Map having objectIdentifier as key and object as Value, e.g.
    Map[{“object1”: An instance of class ClassB},
    {“object2”: An instance of class ClassB},
    {“object3”: An instance of class ClassB}]]
  2. statements (List[String]), which is Scala code coming from configuration like
    val tmpOb1 = .join()
    val tmpOb2 = .sum(tmpOb1)

Now what I want from functionA is to parse the statements, replace placeholders like <object*> from real object, taken from objectMap and execute the statements.

How can I achieve the same?

Scala Version: 2.11